From b1de9c5ff4179404ef3b5faf1fc07c737f9ae990 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:22:51 +0900 Subject: [PATCH 1/4] Update SDL2 library to 2.30.4 --- vs/sdl2/CMakeLists.txt | 229 +- vs/sdl2/LICENSE.txt | 2 +- vs/sdl2/Makefile.in | 2 +- vs/sdl2/Makefile.os2 | 14 +- vs/sdl2/Makefile.w32 | 15 +- vs/sdl2/README.md | 34 +- vs/sdl2/VisualC-WinRT/SDL-UWP.sln | 80 +- vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj | 1200 ++-- vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj.filters | 1704 +++--- vs/sdl2/VisualC/SDL/SDL.vcxproj.filters | 74 +- .../pkg-support/cmake/sdl2-config.cmake | 2 +- .../testautomation/testautomation.vcxproj | 4 +- .../tests/testsensor/testsensor.vcxproj | 408 +- vs/sdl2/VisualC/tests/testwm2/testwm2.vcxproj | 420 +- vs/sdl2/WhatsNew.txt | 19 + vs/sdl2/Xcode-iOS/Demos/src/accelerometer.c | 10 +- vs/sdl2/Xcode-iOS/Demos/src/fireworks.c | 2 +- vs/sdl2/Xcode-iOS/Demos/src/happy.c | 4 +- vs/sdl2/Xcode-iOS/Demos/src/keyboard.c | 4 +- vs/sdl2/Xcode-iOS/Demos/src/rectangles.c | 4 +- vs/sdl2/Xcode-iOS/Demos/src/touch.c | 4 +- vs/sdl2/Xcode/SDL/Info-Framework.plist | 4 +- .../Xcode/SDL/SDL.xcodeproj/project.pbxproj | 386 +- vs/sdl2/Xcode/SDL/pkg-support/SDL.info | 2 +- .../resources/CMake/sdl2-config.cmake | 17 +- .../SDL/pkg-support/resources/License.txt | 2 +- .../SDLTest/SDLTest.xcodeproj/project.pbxproj | 1122 +++- vs/sdl2/acinclude/libtool.m4 | 119 +- vs/sdl2/acinclude/ltoptions.m4 | 2 +- vs/sdl2/android-project/app/build.gradle | 20 +- .../app/src/main/AndroidManifest.xml | 3 +- .../java/org/libsdl/app/HIDDeviceManager.java | 8 + .../main/java/org/libsdl/app/SDLActivity.java | 44 +- .../org/libsdl/app/SDLControllerManager.java | 16 +- .../app/src/main/res/values/styles.xml | 5 +- vs/sdl2/android-project/build.gradle | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- vs/sdl2/build-scripts/config.guess | 70 +- vs/sdl2/build-scripts/config.sub | 237 +- .../gen_audio_channel_conversion.c | 4 +- .../gen_audio_resampler_filter.c | 4 +- vs/sdl2/build-scripts/ltmain.sh | 88 +- vs/sdl2/build-scripts/update-copyright.sh | 12 +- vs/sdl2/cmake/CheckCPUArchitecture.cmake | 84 +- vs/sdl2/cmake/macros.cmake | 22 + vs/sdl2/cmake/sdlchecks.cmake | 95 +- vs/sdl2/cmake/sdlplatform.cmake | 2 + vs/sdl2/cmake/test/main_gui.c | 2 +- vs/sdl2/configure | 449 +- vs/sdl2/configure.ac | 163 +- vs/sdl2/docs/README-android.md | 16 +- vs/sdl2/docs/README-cmake.md | 2 +- vs/sdl2/docs/README-dynapi.md | 4 +- vs/sdl2/docs/README-emscripten.md | 374 +- vs/sdl2/docs/README-gdk.md | 331 +- vs/sdl2/docs/README-git.md | 38 +- vs/sdl2/docs/README-ios.md | 2 +- vs/sdl2/docs/README-kmsbsd.md | 54 +- vs/sdl2/docs/README-macos.md | 570 +- vs/sdl2/docs/README-n3ds.md | 56 +- vs/sdl2/docs/README-ngage.md | 88 +- vs/sdl2/docs/README-os2.md | 184 +- vs/sdl2/docs/README-ps2.md | 102 +- vs/sdl2/docs/README-riscos.md | 82 +- vs/sdl2/docs/README-versions.md | 120 +- vs/sdl2/docs/README-visualc.md | 228 +- vs/sdl2/docs/README-vita.md | 66 +- vs/sdl2/docs/README-windows.md | 116 +- vs/sdl2/include/SDL.h | 2 +- vs/sdl2/include/SDL_assert.h | 4 +- vs/sdl2/include/SDL_atomic.h | 4 +- vs/sdl2/include/SDL_audio.h | 2 +- vs/sdl2/include/SDL_bits.h | 2 +- vs/sdl2/include/SDL_blendmode.h | 6 +- vs/sdl2/include/SDL_clipboard.h | 2 +- vs/sdl2/include/SDL_config.h | 2 +- vs/sdl2/include/SDL_config.h.cmake | 14 +- vs/sdl2/include/SDL_config.h.in | 9 +- vs/sdl2/include/SDL_config_android.h | 2 +- vs/sdl2/include/SDL_config_emscripten.h | 2 +- vs/sdl2/include/SDL_config_iphoneos.h | 2 +- vs/sdl2/include/SDL_config_macosx.h | 2 +- vs/sdl2/include/SDL_config_minimal.h | 2 +- vs/sdl2/include/SDL_config_ngage.h | 2 +- vs/sdl2/include/SDL_config_os2.h | 7 +- vs/sdl2/include/SDL_config_pandora.h | 2 +- vs/sdl2/include/SDL_config_windows.h | 10 +- vs/sdl2/include/SDL_config_wingdk.h | 2 +- vs/sdl2/include/SDL_config_winrt.h | 10 +- vs/sdl2/include/SDL_config_xbox.h | 2 +- vs/sdl2/include/SDL_copying.h | 2 +- vs/sdl2/include/SDL_cpuinfo.h | 2 +- vs/sdl2/include/SDL_egl.h | 2 +- vs/sdl2/include/SDL_endian.h | 2 +- vs/sdl2/include/SDL_error.h | 2 +- vs/sdl2/include/SDL_events.h | 15 +- vs/sdl2/include/SDL_filesystem.h | 6 +- vs/sdl2/include/SDL_gamecontroller.h | 32 +- vs/sdl2/include/SDL_gesture.h | 2 +- vs/sdl2/include/SDL_guid.h | 2 +- vs/sdl2/include/SDL_haptic.h | 2 +- vs/sdl2/include/SDL_hidapi.h | 2 +- vs/sdl2/include/SDL_hints.h | 269 +- vs/sdl2/include/SDL_joystick.h | 2 +- vs/sdl2/include/SDL_keyboard.h | 9 +- vs/sdl2/include/SDL_keycode.h | 2 +- vs/sdl2/include/SDL_loadso.h | 2 +- vs/sdl2/include/SDL_locale.h | 2 +- vs/sdl2/include/SDL_log.h | 6 +- vs/sdl2/include/SDL_main.h | 12 +- vs/sdl2/include/SDL_messagebox.h | 2 +- vs/sdl2/include/SDL_metal.h | 2 +- vs/sdl2/include/SDL_misc.h | 2 +- vs/sdl2/include/SDL_mouse.h | 2 +- vs/sdl2/include/SDL_mutex.h | 2 +- vs/sdl2/include/SDL_name.h | 2 +- vs/sdl2/include/SDL_opengl.h | 2 +- vs/sdl2/include/SDL_opengles.h | 2 +- vs/sdl2/include/SDL_opengles2.h | 2 +- vs/sdl2/include/SDL_pixels.h | 22 +- vs/sdl2/include/SDL_platform.h | 18 +- vs/sdl2/include/SDL_power.h | 2 +- vs/sdl2/include/SDL_quit.h | 2 +- vs/sdl2/include/SDL_rect.h | 2 +- vs/sdl2/include/SDL_render.h | 6 +- vs/sdl2/include/SDL_revision.h | 5 +- vs/sdl2/include/SDL_rwops.h | 2 +- vs/sdl2/include/SDL_scancode.h | 2 +- vs/sdl2/include/SDL_sensor.h | 2 +- vs/sdl2/include/SDL_shape.h | 2 +- vs/sdl2/include/SDL_stdinc.h | 56 +- vs/sdl2/include/SDL_surface.h | 2 +- vs/sdl2/include/SDL_system.h | 19 +- vs/sdl2/include/SDL_syswm.h | 2 +- vs/sdl2/include/SDL_test.h | 2 +- vs/sdl2/include/SDL_test_assert.h | 2 +- vs/sdl2/include/SDL_test_common.h | 2 +- vs/sdl2/include/SDL_test_compare.h | 2 +- vs/sdl2/include/SDL_test_crc32.h | 2 +- vs/sdl2/include/SDL_test_font.h | 2 +- vs/sdl2/include/SDL_test_fuzzer.h | 2 +- vs/sdl2/include/SDL_test_harness.h | 2 +- vs/sdl2/include/SDL_test_images.h | 2 +- vs/sdl2/include/SDL_test_log.h | 2 +- vs/sdl2/include/SDL_test_md5.h | 2 +- vs/sdl2/include/SDL_test_memory.h | 2 +- vs/sdl2/include/SDL_test_random.h | 2 +- vs/sdl2/include/SDL_thread.h | 2 +- vs/sdl2/include/SDL_timer.h | 2 +- vs/sdl2/include/SDL_touch.h | 2 +- vs/sdl2/include/SDL_types.h | 2 +- vs/sdl2/include/SDL_version.h | 9 +- vs/sdl2/include/SDL_video.h | 10 +- vs/sdl2/include/begin_code.h | 4 +- vs/sdl2/include/close_code.h | 2 +- vs/sdl2/sdl2.m4 | 5 +- vs/sdl2/src/SDL.c | 198 +- vs/sdl2/src/SDL_assert.c | 30 +- vs/sdl2/src/SDL_assert_c.h | 2 +- vs/sdl2/src/SDL_dataqueue.c | 26 +- vs/sdl2/src/SDL_dataqueue.h | 2 +- vs/sdl2/src/SDL_error.c | 4 +- vs/sdl2/src/SDL_error_c.h | 2 +- vs/sdl2/src/SDL_guid.c | 4 +- vs/sdl2/src/SDL_hints.c | 38 +- vs/sdl2/src/SDL_hints_c.h | 2 +- vs/sdl2/src/SDL_internal.h | 82 +- vs/sdl2/src/SDL_list.c | 6 +- vs/sdl2/src/SDL_list.h | 2 +- vs/sdl2/src/SDL_log.c | 182 +- vs/sdl2/src/SDL_log_c.h | 2 +- vs/sdl2/src/SDL_utils.c | 2 +- vs/sdl2/src/SDL_utils_c.h | 2 +- vs/sdl2/src/atomic/SDL_atomic.c | 10 +- vs/sdl2/src/atomic/SDL_spinlock.c | 10 +- vs/sdl2/src/audio/SDL_audio.c | 202 +- vs/sdl2/src/audio/SDL_audio_c.h | 2 +- .../src/audio/SDL_audio_channel_converters.h | 2 +- .../src/audio/SDL_audio_resampler_filter.h | 2 +- vs/sdl2/src/audio/SDL_audiocvt.c | 50 +- vs/sdl2/src/audio/SDL_audiodev.c | 10 +- vs/sdl2/src/audio/SDL_audiodev_c.h | 2 +- vs/sdl2/src/audio/SDL_audiotypecvt.c | 723 ++- vs/sdl2/src/audio/SDL_mixer.c | 2 +- vs/sdl2/src/audio/SDL_sysaudio.h | 2 +- vs/sdl2/src/audio/SDL_wave.c | 44 +- vs/sdl2/src/audio/SDL_wave.h | 2 +- vs/sdl2/src/audio/aaudio/SDL_aaudio.c | 181 +- vs/sdl2/src/audio/aaudio/SDL_aaudio.h | 6 +- vs/sdl2/src/audio/aaudio/SDL_aaudiofuncs.h | 4 +- vs/sdl2/src/audio/alsa/SDL_alsa_audio.c | 42 +- vs/sdl2/src/audio/alsa/SDL_alsa_audio.h | 2 +- vs/sdl2/src/audio/android/SDL_androidaudio.c | 52 +- vs/sdl2/src/audio/android/SDL_androidaudio.h | 5 +- vs/sdl2/src/audio/arts/SDL_artsaudio.c | 18 +- vs/sdl2/src/audio/arts/SDL_artsaudio.h | 2 +- vs/sdl2/src/audio/coreaudio/SDL_coreaudio.h | 10 +- vs/sdl2/src/audio/coreaudio/SDL_coreaudio.m | 41 +- .../src/audio/directsound/SDL_directsound.c | 34 +- .../src/audio/directsound/SDL_directsound.h | 2 +- vs/sdl2/src/audio/disk/SDL_diskaudio.c | 20 +- vs/sdl2/src/audio/disk/SDL_diskaudio.h | 2 +- vs/sdl2/src/audio/dsp/SDL_dspaudio.c | 12 +- vs/sdl2/src/audio/dsp/SDL_dspaudio.h | 2 +- vs/sdl2/src/audio/dummy/SDL_dummyaudio.c | 6 +- vs/sdl2/src/audio/dummy/SDL_dummyaudio.h | 2 +- .../audio/emscripten/SDL_emscriptenaudio.c | 58 +- .../audio/emscripten/SDL_emscriptenaudio.h | 2 +- vs/sdl2/src/audio/esd/SDL_esdaudio.c | 14 +- vs/sdl2/src/audio/esd/SDL_esdaudio.h | 2 +- vs/sdl2/src/audio/fusionsound/SDL_fsaudio.c | 14 +- vs/sdl2/src/audio/fusionsound/SDL_fsaudio.h | 2 +- vs/sdl2/src/audio/haiku/SDL_haikuaudio.cc | 6 +- vs/sdl2/src/audio/haiku/SDL_haikuaudio.h | 2 +- vs/sdl2/src/audio/jack/SDL_jackaudio.c | 16 +- vs/sdl2/src/audio/jack/SDL_jackaudio.h | 2 +- vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.c | 24 +- vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.h | 4 +- vs/sdl2/src/audio/nacl/SDL_naclaudio.c | 8 +- vs/sdl2/src/audio/nacl/SDL_naclaudio.h | 2 +- vs/sdl2/src/audio/nas/SDL_nasaudio.c | 18 +- vs/sdl2/src/audio/nas/SDL_nasaudio.h | 2 +- vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.c | 12 +- vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.h | 2 +- vs/sdl2/src/audio/openslES/SDL_openslES.c | 10 +- vs/sdl2/src/audio/openslES/SDL_openslES.h | 2 +- vs/sdl2/src/audio/os2/SDL_os2audio.c | 10 +- vs/sdl2/src/audio/os2/SDL_os2audio.h | 2 +- vs/sdl2/src/audio/paudio/SDL_paudio.c | 16 +- vs/sdl2/src/audio/paudio/SDL_paudio.h | 2 +- vs/sdl2/src/audio/pipewire/SDL_pipewire.c | 86 +- vs/sdl2/src/audio/pipewire/SDL_pipewire.h | 2 +- vs/sdl2/src/audio/ps2/SDL_ps2audio.c | 8 +- vs/sdl2/src/audio/ps2/SDL_ps2audio.h | 2 +- vs/sdl2/src/audio/psp/SDL_pspaudio.c | 10 +- vs/sdl2/src/audio/psp/SDL_pspaudio.h | 2 +- vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.c | 564 +- vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.h | 6 +- vs/sdl2/src/audio/qsa/SDL_qsa_audio.c | 14 +- vs/sdl2/src/audio/qsa/SDL_qsa_audio.h | 2 +- vs/sdl2/src/audio/sndio/SDL_sndioaudio.c | 28 +- vs/sdl2/src/audio/sndio/SDL_sndioaudio.h | 2 +- vs/sdl2/src/audio/sun/SDL_sunaudio.c | 16 +- vs/sdl2/src/audio/sun/SDL_sunaudio.h | 2 +- vs/sdl2/src/audio/vita/SDL_vitaaudio.c | 10 +- vs/sdl2/src/audio/vita/SDL_vitaaudio.h | 2 +- vs/sdl2/src/audio/wasapi/SDL_wasapi.c | 24 +- vs/sdl2/src/audio/wasapi/SDL_wasapi.h | 2 +- vs/sdl2/src/audio/wasapi/SDL_wasapi_win32.c | 4 +- vs/sdl2/src/audio/wasapi/SDL_wasapi_winrt.cpp | 6 +- vs/sdl2/src/audio/winmm/SDL_winmm.c | 12 +- vs/sdl2/src/audio/winmm/SDL_winmm.h | 2 +- vs/sdl2/src/core/android/SDL_android.c | 60 +- vs/sdl2/src/core/android/SDL_android.h | 6 +- .../src/core/freebsd/SDL_evdev_kbd_freebsd.c | 24 +- vs/sdl2/src/core/gdk/SDL_gdk.cpp | 44 +- vs/sdl2/src/core/gdk/SDL_gdk.h | 2 +- vs/sdl2/src/core/linux/SDL_dbus.c | 102 +- vs/sdl2/src/core/linux/SDL_dbus.h | 8 +- vs/sdl2/src/core/linux/SDL_evdev.c | 142 +- vs/sdl2/src/core/linux/SDL_evdev.h | 5 +- .../src/core/linux/SDL_evdev_capabilities.c | 4 +- .../src/core/linux/SDL_evdev_capabilities.h | 4 +- vs/sdl2/src/core/linux/SDL_evdev_kbd.c | 225 +- vs/sdl2/src/core/linux/SDL_evdev_kbd.h | 5 +- .../linux/SDL_evdev_kbd_default_accents.h | 2 +- .../core/linux/SDL_evdev_kbd_default_keymap.h | 2 +- vs/sdl2/src/core/linux/SDL_fcitx.c | 8 +- vs/sdl2/src/core/linux/SDL_fcitx.h | 2 +- vs/sdl2/src/core/linux/SDL_ibus.c | 44 +- vs/sdl2/src/core/linux/SDL_ibus.h | 2 +- vs/sdl2/src/core/linux/SDL_ime.c | 8 +- vs/sdl2/src/core/linux/SDL_ime.h | 2 +- vs/sdl2/src/core/linux/SDL_sandbox.c | 2 +- vs/sdl2/src/core/linux/SDL_sandbox.h | 2 +- vs/sdl2/src/core/linux/SDL_threadprio.c | 24 +- vs/sdl2/src/core/linux/SDL_udev.c | 190 +- vs/sdl2/src/core/linux/SDL_udev.h | 6 +- vs/sdl2/src/core/openbsd/SDL_wscons.h | 2 +- vs/sdl2/src/core/openbsd/SDL_wscons_kbd.c | 10 +- vs/sdl2/src/core/openbsd/SDL_wscons_mouse.c | 6 +- vs/sdl2/src/core/os2/SDL_os2.c | 2 +- vs/sdl2/src/core/os2/SDL_os2.h | 2 +- vs/sdl2/src/core/os2/geniconv/geniconv.c | 2 +- vs/sdl2/src/core/os2/geniconv/geniconv.h | 2 +- vs/sdl2/src/core/os2/geniconv/os2cp.c | 6 +- vs/sdl2/src/core/os2/geniconv/os2cp.h | 2 +- vs/sdl2/src/core/os2/geniconv/os2iconv.c | 10 +- vs/sdl2/src/core/os2/geniconv/sys2utf8.c | 4 +- vs/sdl2/src/core/os2/geniconv/test.c | 4 +- vs/sdl2/src/core/unix/SDL_poll.c | 2 +- vs/sdl2/src/core/unix/SDL_poll.h | 2 +- vs/sdl2/src/core/windows/SDL_directx.h | 2 +- vs/sdl2/src/core/windows/SDL_hid.c | 8 +- vs/sdl2/src/core/windows/SDL_hid.h | 2 +- vs/sdl2/src/core/windows/SDL_immdevice.c | 12 +- vs/sdl2/src/core/windows/SDL_immdevice.h | 2 +- vs/sdl2/src/core/windows/SDL_windows.c | 4 +- vs/sdl2/src/core/windows/SDL_windows.h | 14 +- vs/sdl2/src/core/windows/SDL_xinput.c | 9 +- vs/sdl2/src/core/windows/SDL_xinput.h | 57 +- .../src/core/winrt/SDL_winrtapp_common.cpp | 2 +- vs/sdl2/src/core/winrt/SDL_winrtapp_common.h | 2 +- .../src/core/winrt/SDL_winrtapp_direct3d.cpp | 30 +- .../src/core/winrt/SDL_winrtapp_direct3d.h | 4 +- vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.cpp | 6 +- vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.h | 2 +- vs/sdl2/src/cpuinfo/SDL_cpuinfo.c | 31 +- vs/sdl2/src/dynapi/SDL2.exports | 2 + vs/sdl2/src/dynapi/SDL_dynapi.c | 18 +- vs/sdl2/src/dynapi/SDL_dynapi.h | 4 +- vs/sdl2/src/dynapi/SDL_dynapi_overrides.h | 4 +- vs/sdl2/src/dynapi/SDL_dynapi_procs.h | 10 +- vs/sdl2/src/dynapi/gendynapi.pl | 2 +- vs/sdl2/src/events/SDL_clipboardevents.c | 2 +- vs/sdl2/src/events/SDL_clipboardevents_c.h | 2 +- vs/sdl2/src/events/SDL_displayevents.c | 4 +- vs/sdl2/src/events/SDL_displayevents_c.h | 2 +- vs/sdl2/src/events/SDL_dropevents.c | 2 +- vs/sdl2/src/events/SDL_dropevents_c.h | 2 +- vs/sdl2/src/events/SDL_events.c | 62 +- vs/sdl2/src/events/SDL_events_c.h | 2 +- vs/sdl2/src/events/SDL_gesture.c | 22 +- vs/sdl2/src/events/SDL_gesture_c.h | 2 +- vs/sdl2/src/events/SDL_keyboard.c | 10 +- vs/sdl2/src/events/SDL_keyboard_c.h | 2 +- vs/sdl2/src/events/SDL_keysym_to_scancode.c | 4 +- vs/sdl2/src/events/SDL_keysym_to_scancode_c.h | 2 +- vs/sdl2/src/events/SDL_mouse.c | 104 +- vs/sdl2/src/events/SDL_mouse_c.h | 5 +- vs/sdl2/src/events/SDL_quit.c | 6 +- vs/sdl2/src/events/SDL_scancode_tables.c | 4 +- vs/sdl2/src/events/SDL_scancode_tables_c.h | 2 +- vs/sdl2/src/events/SDL_touch.c | 18 +- vs/sdl2/src/events/SDL_touch_c.h | 2 +- vs/sdl2/src/events/SDL_windowevents.c | 4 +- vs/sdl2/src/events/SDL_windowevents_c.h | 2 +- vs/sdl2/src/events/blank_cursor.h | 2 +- vs/sdl2/src/events/default_cursor.h | 4 +- vs/sdl2/src/events/imKStoUCS.c | 2 +- vs/sdl2/src/events/scancodes_ascii.h | 2 +- vs/sdl2/src/events/scancodes_darwin.h | 2 +- vs/sdl2/src/events/scancodes_linux.h | 2 +- vs/sdl2/src/events/scancodes_windows.h | 2 +- vs/sdl2/src/events/scancodes_xfree86.h | 2 +- vs/sdl2/src/file/SDL_rwops.c | 96 +- .../src/file/cocoa/SDL_rwopsbundlesupport.h | 2 +- .../src/file/cocoa/SDL_rwopsbundlesupport.m | 2 +- vs/sdl2/src/file/n3ds/SDL_rwopsromfs.c | 4 +- vs/sdl2/src/file/n3ds/SDL_rwopsromfs.h | 2 +- .../filesystem/android/SDL_sysfilesystem.c | 4 +- .../src/filesystem/cocoa/SDL_sysfilesystem.m | 2 +- .../src/filesystem/dummy/SDL_sysfilesystem.c | 2 +- .../filesystem/emscripten/SDL_sysfilesystem.c | 8 +- .../src/filesystem/gdk/SDL_sysfilesystem.cpp | 138 + .../src/filesystem/haiku/SDL_sysfilesystem.cc | 10 +- .../src/filesystem/n3ds/SDL_sysfilesystem.c | 6 +- .../src/filesystem/nacl/SDL_sysfilesystem.c | 2 +- .../src/filesystem/os2/SDL_sysfilesystem.c | 2 +- .../src/filesystem/ps2/SDL_sysfilesystem.c | 6 +- .../src/filesystem/psp/SDL_sysfilesystem.c | 6 +- .../src/filesystem/riscos/SDL_sysfilesystem.c | 26 +- .../src/filesystem/unix/SDL_sysfilesystem.c | 42 +- .../src/filesystem/vita/SDL_sysfilesystem.c | 8 +- .../filesystem/windows/SDL_sysfilesystem.c | 28 +- .../filesystem/winrt/SDL_sysfilesystem.cpp | 20 +- vs/sdl2/src/haptic/SDL_haptic.c | 12 +- vs/sdl2/src/haptic/SDL_haptic_c.h | 2 +- vs/sdl2/src/haptic/SDL_syshaptic.h | 2 +- vs/sdl2/src/haptic/android/SDL_syshaptic.c | 24 +- vs/sdl2/src/haptic/darwin/SDL_syshaptic.c | 40 +- vs/sdl2/src/haptic/darwin/SDL_syshaptic_c.h | 2 +- vs/sdl2/src/haptic/dummy/SDL_syshaptic.c | 2 +- vs/sdl2/src/haptic/linux/SDL_syshaptic.c | 51 +- vs/sdl2/src/haptic/windows/SDL_dinputhaptic.c | 40 +- .../src/haptic/windows/SDL_dinputhaptic_c.h | 2 +- .../src/haptic/windows/SDL_windowshaptic.c | 18 +- .../src/haptic/windows/SDL_windowshaptic_c.h | 12 +- vs/sdl2/src/haptic/windows/SDL_xinputhaptic.c | 18 +- .../src/haptic/windows/SDL_xinputhaptic_c.h | 2 +- vs/sdl2/src/hidapi/SDL_hidapi.c | 140 +- vs/sdl2/src/hidapi/SDL_hidapi_c.h | 2 +- vs/sdl2/src/hidapi/android/hid.cpp | 6 +- vs/sdl2/src/hidapi/hidapi/hidapi.h | 2 +- vs/sdl2/src/hidapi/ios/hid.m | 64 +- vs/sdl2/src/hidapi/libusb/hid.c | 2 + vs/sdl2/src/hidapi/linux/hid.c | 6 +- vs/sdl2/src/hidapi/mac/hid.c | 4 +- vs/sdl2/src/joystick/SDL_gamecontroller.c | 408 +- vs/sdl2/src/joystick/SDL_gamecontrollerdb.h | 44 +- vs/sdl2/src/joystick/SDL_joystick.c | 1093 ++-- vs/sdl2/src/joystick/SDL_joystick_c.h | 56 +- .../src/joystick/SDL_steam_virtual_gamepad.c | 251 + .../src/joystick/SDL_steam_virtual_gamepad.h | 36 + vs/sdl2/src/joystick/SDL_sysjoystick.h | 6 +- .../src/joystick/android/SDL_sysjoystick.c | 34 +- .../src/joystick/android/SDL_sysjoystick_c.h | 2 +- vs/sdl2/src/joystick/bsd/SDL_bsdjoystick.c | 42 +- vs/sdl2/src/joystick/controller_list.h | 20 +- vs/sdl2/src/joystick/controller_type.h | 1 + .../src/joystick/darwin/SDL_iokitjoystick.c | 63 +- .../src/joystick/darwin/SDL_iokitjoystick_c.h | 3 +- vs/sdl2/src/joystick/dummy/SDL_sysjoystick.c | 8 +- .../src/joystick/emscripten/SDL_sysjoystick.c | 32 +- .../joystick/emscripten/SDL_sysjoystick_c.h | 2 +- .../src/joystick/haiku/SDL_haikujoystick.cc | 8 +- .../src/joystick/hidapi/SDL_hidapi_combined.c | 2 +- .../src/joystick/hidapi/SDL_hidapi_gamecube.c | 22 +- vs/sdl2/src/joystick/hidapi/SDL_hidapi_luna.c | 6 +- .../src/joystick/hidapi/SDL_hidapi_nintendo.h | 2 +- vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps3.c | 112 +- vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps4.c | 40 +- vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps5.c | 136 +- .../src/joystick/hidapi/SDL_hidapi_rumble.c | 4 +- .../src/joystick/hidapi/SDL_hidapi_rumble.h | 2 +- .../src/joystick/hidapi/SDL_hidapi_shield.c | 8 +- .../src/joystick/hidapi/SDL_hidapi_stadia.c | 6 +- .../src/joystick/hidapi/SDL_hidapi_steam.c | 21 +- .../joystick/hidapi/SDL_hidapi_steamdeck.c | 425 ++ .../src/joystick/hidapi/SDL_hidapi_switch.c | 102 +- vs/sdl2/src/joystick/hidapi/SDL_hidapi_wii.c | 6 +- .../src/joystick/hidapi/SDL_hidapi_xbox360.c | 6 +- .../src/joystick/hidapi/SDL_hidapi_xbox360w.c | 6 +- .../src/joystick/hidapi/SDL_hidapi_xboxone.c | 20 +- .../src/joystick/hidapi/SDL_hidapijoystick.c | 88 +- .../joystick/hidapi/SDL_hidapijoystick_c.h | 6 +- .../hidapi/steam/controller_constants.h | 89 +- .../hidapi/steam/controller_structs.h | 166 +- .../src/joystick/iphoneos/SDL_mfijoystick.m | 960 ++- .../src/joystick/iphoneos/SDL_mfijoystick_c.h | 25 +- vs/sdl2/src/joystick/linux/SDL_sysjoystick.c | 860 ++- .../src/joystick/linux/SDL_sysjoystick_c.h | 21 +- vs/sdl2/src/joystick/n3ds/SDL_sysjoystick.c | 30 +- vs/sdl2/src/joystick/os2/SDL_os2joystick.c | 1130 ++-- vs/sdl2/src/joystick/ps2/SDL_sysjoystick.c | 11 +- vs/sdl2/src/joystick/psp/SDL_sysjoystick.c | 14 +- vs/sdl2/src/joystick/sort_controllers.py | 14 +- .../src/joystick/steam/SDL_steamcontroller.c | 2 +- .../src/joystick/steam/SDL_steamcontroller.h | 2 +- vs/sdl2/src/joystick/usb_ids.h | 22 +- .../joystick/virtual/SDL_virtualjoystick.c | 36 +- .../joystick/virtual/SDL_virtualjoystick_c.h | 4 +- vs/sdl2/src/joystick/vita/SDL_sysjoystick.c | 10 +- .../src/joystick/windows/SDL_dinputjoystick.c | 59 +- .../joystick/windows/SDL_dinputjoystick_c.h | 2 +- .../joystick/windows/SDL_rawinputjoystick.c | 43 +- .../joystick/windows/SDL_rawinputjoystick_c.h | 2 +- .../windows/SDL_windows_gaming_input.c | 67 +- .../joystick/windows/SDL_windowsjoystick.c | 62 +- .../joystick/windows/SDL_windowsjoystick_c.h | 8 +- .../src/joystick/windows/SDL_xinputjoystick.c | 182 +- .../joystick/windows/SDL_xinputjoystick_c.h | 3 +- vs/sdl2/src/libm/math_libm.h | 2 +- vs/sdl2/src/loadso/dlopen/SDL_sysloadso.c | 14 +- vs/sdl2/src/loadso/dummy/SDL_sysloadso.c | 2 +- vs/sdl2/src/loadso/os2/SDL_sysloadso.c | 4 +- vs/sdl2/src/loadso/windows/SDL_sysloadso.c | 10 +- vs/sdl2/src/locale/SDL_locale.c | 6 +- vs/sdl2/src/locale/SDL_syslocale.h | 2 +- vs/sdl2/src/locale/android/SDL_syslocale.c | 2 +- vs/sdl2/src/locale/dummy/SDL_syslocale.c | 2 +- vs/sdl2/src/locale/emscripten/SDL_syslocale.c | 2 +- vs/sdl2/src/locale/haiku/SDL_syslocale.cc | 2 +- vs/sdl2/src/locale/macosx/SDL_syslocale.m | 2 +- vs/sdl2/src/locale/n3ds/SDL_syslocale.c | 11 +- vs/sdl2/src/locale/unix/SDL_syslocale.c | 8 +- vs/sdl2/src/locale/vita/SDL_syslocale.c | 2 +- vs/sdl2/src/locale/windows/SDL_syslocale.c | 6 +- vs/sdl2/src/locale/winrt/SDL_syslocale.c | 4 +- vs/sdl2/src/main/gdk/SDL_gdk_main.c | 2 +- vs/sdl2/src/main/haiku/SDL_BApp.h | 10 +- vs/sdl2/src/main/haiku/SDL_BeApp.cc | 8 +- vs/sdl2/src/main/haiku/SDL_BeApp.h | 2 +- vs/sdl2/src/main/n3ds/SDL_n3ds_main.c | 2 +- vs/sdl2/src/main/nacl/SDL_nacl_main.c | 4 +- vs/sdl2/src/main/ngage/SDL_ngage_main.cpp | 2 +- vs/sdl2/src/main/windows/SDL_windows_main.c | 6 +- vs/sdl2/src/main/windows/version.rc | 10 +- vs/sdl2/src/misc/SDL_sysurl.h | 2 +- vs/sdl2/src/misc/SDL_url.c | 4 +- vs/sdl2/src/misc/android/SDL_sysurl.c | 2 +- vs/sdl2/src/misc/dummy/SDL_sysurl.c | 2 +- vs/sdl2/src/misc/emscripten/SDL_sysurl.c | 10 +- vs/sdl2/src/misc/haiku/SDL_sysurl.cc | 2 +- vs/sdl2/src/misc/ios/SDL_sysurl.m | 2 +- vs/sdl2/src/misc/macosx/SDL_sysurl.m | 2 +- vs/sdl2/src/misc/riscos/SDL_sysurl.c | 2 +- vs/sdl2/src/misc/unix/SDL_sysurl.c | 15 +- vs/sdl2/src/misc/vita/SDL_sysurl.c | 2 +- vs/sdl2/src/misc/windows/SDL_sysurl.c | 4 +- vs/sdl2/src/misc/winrt/SDL_sysurl.cpp | 2 +- vs/sdl2/src/power/SDL_power.c | 6 +- vs/sdl2/src/power/SDL_syspower.h | 2 +- vs/sdl2/src/power/android/SDL_syspower.c | 4 +- vs/sdl2/src/power/emscripten/SDL_syspower.c | 4 +- vs/sdl2/src/power/haiku/SDL_syspower.c | 4 +- vs/sdl2/src/power/linux/SDL_syspower.c | 30 +- vs/sdl2/src/power/macosx/SDL_syspower.c | 4 +- vs/sdl2/src/power/n3ds/SDL_syspower.c | 2 +- vs/sdl2/src/power/psp/SDL_syspower.c | 4 +- vs/sdl2/src/power/uikit/SDL_syspower.h | 4 +- vs/sdl2/src/power/uikit/SDL_syspower.m | 4 +- vs/sdl2/src/power/vita/SDL_syspower.c | 4 +- vs/sdl2/src/power/windows/SDL_syspower.c | 4 +- vs/sdl2/src/power/winrt/SDL_syspower.cpp | 2 +- vs/sdl2/src/render/SDL_d3dmath.c | 6 +- vs/sdl2/src/render/SDL_d3dmath.h | 6 +- vs/sdl2/src/render/SDL_render.c | 178 +- vs/sdl2/src/render/SDL_sysrender.h | 2 +- vs/sdl2/src/render/SDL_yuv_sw.c | 4 +- vs/sdl2/src/render/SDL_yuv_sw_c.h | 2 +- vs/sdl2/src/render/direct3d/SDL_render_d3d.c | 53 +- vs/sdl2/src/render/direct3d/SDL_shaders_d3d.c | 6 +- vs/sdl2/src/render/direct3d/SDL_shaders_d3d.h | 2 +- .../src/render/direct3d11/SDL_render_d3d11.c | 83 +- .../render/direct3d11/SDL_render_winrt.cpp | 12 +- .../src/render/direct3d11/SDL_render_winrt.h | 6 +- .../src/render/direct3d11/SDL_shaders_d3d11.c | 8 +- .../src/render/direct3d11/SDL_shaders_d3d11.h | 2 +- .../src/render/direct3d12/SDL_render_d3d12.c | 141 +- .../direct3d12/SDL_render_d3d12_xbox.cpp | 153 +- .../render/direct3d12/SDL_render_d3d12_xbox.h | 31 +- .../src/render/direct3d12/SDL_shaders_d3d12.c | 6 +- .../src/render/direct3d12/SDL_shaders_d3d12.h | 2 +- .../direct3d12/SDL_shaders_d3d12_xboxone.cpp | 123 +- .../SDL_shaders_d3d12_xboxseries.cpp | 123 +- vs/sdl2/src/render/metal/SDL_render_metal.m | 24 +- vs/sdl2/src/render/opengl/SDL_glfuncs.h | 2 +- vs/sdl2/src/render/opengl/SDL_render_gl.c | 44 +- vs/sdl2/src/render/opengl/SDL_shaders_gl.c | 8 +- vs/sdl2/src/render/opengl/SDL_shaders_gl.h | 2 +- vs/sdl2/src/render/opengles/SDL_glesfuncs.h | 2 +- vs/sdl2/src/render/opengles/SDL_render_gles.c | 44 +- vs/sdl2/src/render/opengles2/SDL_gles2funcs.h | 4 +- .../src/render/opengles2/SDL_render_gles2.c | 149 +- .../src/render/opengles2/SDL_shaders_gles2.c | 8 +- .../src/render/opengles2/SDL_shaders_gles2.h | 2 +- vs/sdl2/src/render/ps2/SDL_render_ps2.c | 100 +- vs/sdl2/src/render/psp/SDL_render_psp.c | 45 +- .../src/render/software/SDL_blendfillrect.c | 12 +- .../src/render/software/SDL_blendfillrect.h | 2 +- vs/sdl2/src/render/software/SDL_blendline.c | 14 +- vs/sdl2/src/render/software/SDL_blendline.h | 2 +- vs/sdl2/src/render/software/SDL_blendpoint.c | 12 +- vs/sdl2/src/render/software/SDL_blendpoint.h | 2 +- vs/sdl2/src/render/software/SDL_draw.h | 2 +- vs/sdl2/src/render/software/SDL_drawline.c | 14 +- vs/sdl2/src/render/software/SDL_drawline.h | 2 +- vs/sdl2/src/render/software/SDL_drawpoint.c | 10 +- vs/sdl2/src/render/software/SDL_drawpoint.h | 2 +- vs/sdl2/src/render/software/SDL_render_sw.c | 78 +- vs/sdl2/src/render/software/SDL_render_sw_c.h | 2 +- vs/sdl2/src/render/software/SDL_rotate.c | 10 +- vs/sdl2/src/render/software/SDL_rotate.h | 2 +- vs/sdl2/src/render/software/SDL_triangle.c | 152 +- vs/sdl2/src/render/software/SDL_triangle.h | 2 +- .../src/render/vitagxm/SDL_render_vita_gxm.c | 33 +- .../vitagxm/SDL_render_vita_gxm_memory.c | 10 +- .../vitagxm/SDL_render_vita_gxm_memory.h | 2 +- .../vitagxm/SDL_render_vita_gxm_shaders.h | 2 +- .../vitagxm/SDL_render_vita_gxm_tools.c | 8 +- .../vitagxm/SDL_render_vita_gxm_tools.h | 2 +- .../vitagxm/SDL_render_vita_gxm_types.h | 2 +- vs/sdl2/src/sensor/SDL_sensor.c | 16 +- vs/sdl2/src/sensor/SDL_sensor_c.h | 2 +- vs/sdl2/src/sensor/SDL_syssensor.h | 2 +- .../src/sensor/android/SDL_androidsensor.c | 12 +- .../src/sensor/android/SDL_androidsensor.h | 2 +- .../sensor/coremotion/SDL_coremotionsensor.h | 2 +- .../sensor/coremotion/SDL_coremotionsensor.m | 2 +- vs/sdl2/src/sensor/dummy/SDL_dummysensor.c | 2 +- vs/sdl2/src/sensor/dummy/SDL_dummysensor.h | 2 +- vs/sdl2/src/sensor/n3ds/SDL_n3dssensor.c | 2 +- vs/sdl2/src/sensor/vita/SDL_vitasensor.c | 6 +- vs/sdl2/src/sensor/vita/SDL_vitasensor.h | 2 +- .../src/sensor/windows/SDL_windowssensor.c | 10 +- .../src/sensor/windows/SDL_windowssensor.h | 2 +- vs/sdl2/src/stdlib/SDL_crc16.c | 2 +- vs/sdl2/src/stdlib/SDL_crc32.c | 2 +- vs/sdl2/src/stdlib/SDL_getenv.c | 24 +- vs/sdl2/src/stdlib/SDL_iconv.c | 61 +- vs/sdl2/src/stdlib/SDL_malloc.c | 22 +- vs/sdl2/src/stdlib/SDL_mslibc.c | 2 +- vs/sdl2/src/stdlib/SDL_qsort.c | 20 +- vs/sdl2/src/stdlib/SDL_stdlib.c | 2 +- vs/sdl2/src/stdlib/SDL_string.c | 111 +- vs/sdl2/src/stdlib/SDL_strtokr.c | 2 +- vs/sdl2/src/stdlib/SDL_vacopy.h | 2 +- vs/sdl2/src/test/SDL_test_assert.c | 2 +- vs/sdl2/src/test/SDL_test_common.c | 145 +- vs/sdl2/src/test/SDL_test_compare.c | 30 +- vs/sdl2/src/test/SDL_test_crc32.c | 14 +- vs/sdl2/src/test/SDL_test_font.c | 10 +- vs/sdl2/src/test/SDL_test_fuzzer.c | 8 +- vs/sdl2/src/test/SDL_test_harness.c | 38 +- vs/sdl2/src/test/SDL_test_imageBlit.c | 47 +- vs/sdl2/src/test/SDL_test_imageBlitBlend.c | 77 +- vs/sdl2/src/test/SDL_test_imageFace.c | 17 +- vs/sdl2/src/test/SDL_test_imagePrimitives.c | 17 +- .../src/test/SDL_test_imagePrimitivesBlend.c | 17 +- vs/sdl2/src/test/SDL_test_log.c | 2 +- vs/sdl2/src/test/SDL_test_md5.c | 10 +- vs/sdl2/src/test/SDL_test_memory.c | 6 +- vs/sdl2/src/test/SDL_test_random.c | 8 +- vs/sdl2/src/thread/SDL_systhread.h | 2 +- vs/sdl2/src/thread/SDL_thread.c | 50 +- vs/sdl2/src/thread/SDL_thread_c.h | 22 +- vs/sdl2/src/thread/generic/SDL_syscond.c | 10 +- vs/sdl2/src/thread/generic/SDL_syscond_c.h | 4 +- vs/sdl2/src/thread/generic/SDL_sysmutex.c | 12 +- vs/sdl2/src/thread/generic/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/generic/SDL_syssem.c | 12 +- vs/sdl2/src/thread/generic/SDL_systhread.c | 2 +- vs/sdl2/src/thread/generic/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/generic/SDL_systls.c | 2 +- vs/sdl2/src/thread/n3ds/SDL_syscond.c | 10 +- vs/sdl2/src/thread/n3ds/SDL_sysmutex.c | 4 +- vs/sdl2/src/thread/n3ds/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/n3ds/SDL_syssem.c | 12 +- vs/sdl2/src/thread/n3ds/SDL_systhread.c | 28 +- vs/sdl2/src/thread/n3ds/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/ngage/SDL_sysmutex.cpp | 2 +- vs/sdl2/src/thread/ngage/SDL_syssem.cpp | 12 +- vs/sdl2/src/thread/ngage/SDL_systhread.cpp | 4 +- vs/sdl2/src/thread/ngage/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/os2/SDL_sysmutex.c | 4 +- vs/sdl2/src/thread/os2/SDL_syssem.c | 12 +- vs/sdl2/src/thread/os2/SDL_systhread.c | 6 +- vs/sdl2/src/thread/os2/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/os2/SDL_systls.c | 10 +- vs/sdl2/src/thread/os2/SDL_systls_c.h | 4 +- vs/sdl2/src/thread/ps2/SDL_syssem.c | 33 +- vs/sdl2/src/thread/ps2/SDL_systhread.c | 4 +- vs/sdl2/src/thread/ps2/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/psp/SDL_sysmutex.c | 12 +- vs/sdl2/src/thread/psp/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/psp/SDL_syssem.c | 14 +- vs/sdl2/src/thread/psp/SDL_systhread.c | 4 +- vs/sdl2/src/thread/psp/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/pthread/SDL_syscond.c | 10 +- vs/sdl2/src/thread/pthread/SDL_sysmutex.c | 26 +- vs/sdl2/src/thread/pthread/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/pthread/SDL_syssem.c | 16 +- vs/sdl2/src/thread/pthread/SDL_systhread.c | 16 +- vs/sdl2/src/thread/pthread/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/pthread/SDL_systls.c | 2 +- vs/sdl2/src/thread/stdcpp/SDL_syscond.cpp | 8 +- vs/sdl2/src/thread/stdcpp/SDL_sysmutex.cpp | 6 +- vs/sdl2/src/thread/stdcpp/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/stdcpp/SDL_systhread.cpp | 2 +- vs/sdl2/src/thread/stdcpp/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/vita/SDL_sysmutex.c | 18 +- vs/sdl2/src/thread/vita/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/vita/SDL_syssem.c | 14 +- vs/sdl2/src/thread/vita/SDL_systhread.c | 4 +- vs/sdl2/src/thread/vita/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/windows/SDL_syscond_cv.c | 22 +- vs/sdl2/src/thread/windows/SDL_sysmutex.c | 22 +- vs/sdl2/src/thread/windows/SDL_sysmutex_c.h | 2 +- vs/sdl2/src/thread/windows/SDL_syssem.c | 42 +- vs/sdl2/src/thread/windows/SDL_systhread.c | 12 +- vs/sdl2/src/thread/windows/SDL_systhread_c.h | 2 +- vs/sdl2/src/thread/windows/SDL_systls.c | 4 +- vs/sdl2/src/timer/SDL_timer.c | 12 +- vs/sdl2/src/timer/SDL_timer_c.h | 2 +- vs/sdl2/src/timer/dummy/SDL_systimer.c | 2 +- vs/sdl2/src/timer/haiku/SDL_systimer.c | 2 +- vs/sdl2/src/timer/n3ds/SDL_systimer.c | 2 +- vs/sdl2/src/timer/ngage/SDL_systimer.cpp | 2 +- vs/sdl2/src/timer/os2/SDL_systimer.c | 4 +- vs/sdl2/src/timer/ps2/SDL_systimer.c | 2 +- vs/sdl2/src/timer/psp/SDL_systimer.c | 2 +- vs/sdl2/src/timer/unix/SDL_systimer.c | 22 +- vs/sdl2/src/timer/vita/SDL_systimer.c | 2 +- vs/sdl2/src/timer/windows/SDL_systimer.c | 2 +- vs/sdl2/src/video/SDL_RLEaccel.c | 16 +- vs/sdl2/src/video/SDL_RLEaccel_c.h | 2 +- vs/sdl2/src/video/SDL_blit.c | 10 +- vs/sdl2/src/video/SDL_blit.h | 2 +- vs/sdl2/src/video/SDL_blit_0.c | 579 +- vs/sdl2/src/video/SDL_blit_1.c | 2 +- vs/sdl2/src/video/SDL_blit_A.c | 22 +- vs/sdl2/src/video/SDL_blit_N.c | 26 +- vs/sdl2/src/video/SDL_blit_auto.c | 722 +-- vs/sdl2/src/video/SDL_blit_auto.h | 2 +- vs/sdl2/src/video/SDL_blit_copy.c | 2 +- vs/sdl2/src/video/SDL_blit_copy.h | 2 +- vs/sdl2/src/video/SDL_blit_slow.c | 33 +- vs/sdl2/src/video/SDL_blit_slow.h | 2 +- vs/sdl2/src/video/SDL_bmp.c | 10 +- vs/sdl2/src/video/SDL_clipboard.c | 22 +- vs/sdl2/src/video/SDL_egl.c | 88 +- vs/sdl2/src/video/SDL_egl_c.h | 32 +- vs/sdl2/src/video/SDL_fillrect.c | 24 +- vs/sdl2/src/video/SDL_pixels.c | 43 +- vs/sdl2/src/video/SDL_pixels_c.h | 2 +- vs/sdl2/src/video/SDL_rect.c | 8 +- vs/sdl2/src/video/SDL_rect_c.h | 2 +- vs/sdl2/src/video/SDL_rect_impl.h | 51 +- vs/sdl2/src/video/SDL_shape.c | 20 +- vs/sdl2/src/video/SDL_shape_internals.h | 2 +- vs/sdl2/src/video/SDL_stretch.c | 52 +- vs/sdl2/src/video/SDL_surface.c | 204 +- vs/sdl2/src/video/SDL_sysvideo.h | 12 +- vs/sdl2/src/video/SDL_video.c | 661 +- vs/sdl2/src/video/SDL_vulkan_internal.h | 20 +- vs/sdl2/src/video/SDL_vulkan_utils.c | 18 +- vs/sdl2/src/video/SDL_yuv.c | 14 +- vs/sdl2/src/video/SDL_yuv_c.h | 2 +- .../src/video/android/SDL_androidclipboard.c | 4 +- .../src/video/android/SDL_androidclipboard.h | 2 +- vs/sdl2/src/video/android/SDL_androidevents.c | 30 +- vs/sdl2/src/video/android/SDL_androidevents.h | 2 +- vs/sdl2/src/video/android/SDL_androidgl.c | 4 +- vs/sdl2/src/video/android/SDL_androidgl.h | 2 +- .../src/video/android/SDL_androidkeyboard.c | 31 +- .../src/video/android/SDL_androidkeyboard.h | 8 +- .../src/video/android/SDL_androidmessagebox.c | 4 +- .../src/video/android/SDL_androidmessagebox.h | 4 +- vs/sdl2/src/video/android/SDL_androidmouse.c | 12 +- vs/sdl2/src/video/android/SDL_androidmouse.h | 2 +- vs/sdl2/src/video/android/SDL_androidtouch.c | 6 +- vs/sdl2/src/video/android/SDL_androidtouch.h | 2 +- vs/sdl2/src/video/android/SDL_androidvideo.c | 20 +- vs/sdl2/src/video/android/SDL_androidvideo.h | 2 +- vs/sdl2/src/video/android/SDL_androidvulkan.c | 10 +- vs/sdl2/src/video/android/SDL_androidvulkan.h | 4 +- vs/sdl2/src/video/android/SDL_androidwindow.c | 14 +- vs/sdl2/src/video/android/SDL_androidwindow.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoaevents.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoaevents.m | 21 +- vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m | 102 +- vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoametalview.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoametalview.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoamodes.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoamodes.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoamouse.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoamouse.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoaopengl.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoaopengl.m | 6 +- vs/sdl2/src/video/cocoa/SDL_cocoaopengles.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoaopengles.m | 8 +- vs/sdl2/src/video/cocoa/SDL_cocoashape.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoashape.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoavideo.h | 2 +- vs/sdl2/src/video/cocoa/SDL_cocoavideo.m | 16 +- vs/sdl2/src/video/cocoa/SDL_cocoavulkan.h | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoavulkan.m | 4 +- vs/sdl2/src/video/cocoa/SDL_cocoawindow.h | 6 +- vs/sdl2/src/video/cocoa/SDL_cocoawindow.m | 52 +- vs/sdl2/src/video/directfb/SDL_DirectFB_WM.c | 12 +- vs/sdl2/src/video/directfb/SDL_DirectFB_WM.h | 2 +- vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.c | 6 +- vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.h | 2 +- .../src/video/directfb/SDL_DirectFB_events.c | 8 +- .../src/video/directfb/SDL_DirectFB_events.h | 2 +- .../src/video/directfb/SDL_DirectFB_modes.c | 4 +- .../src/video/directfb/SDL_DirectFB_modes.h | 2 +- .../src/video/directfb/SDL_DirectFB_mouse.c | 4 +- .../src/video/directfb/SDL_DirectFB_mouse.h | 2 +- .../src/video/directfb/SDL_DirectFB_opengl.c | 24 +- .../src/video/directfb/SDL_DirectFB_opengl.h | 4 +- .../src/video/directfb/SDL_DirectFB_render.c | 4 +- .../src/video/directfb/SDL_DirectFB_render.h | 2 +- .../src/video/directfb/SDL_DirectFB_shape.c | 6 +- .../src/video/directfb/SDL_DirectFB_shape.h | 2 +- .../src/video/directfb/SDL_DirectFB_video.c | 15 +- .../src/video/directfb/SDL_DirectFB_video.h | 2 +- .../src/video/directfb/SDL_DirectFB_vulkan.c | 4 +- .../src/video/directfb/SDL_DirectFB_vulkan.h | 4 +- .../src/video/directfb/SDL_DirectFB_window.c | 12 +- .../src/video/directfb/SDL_DirectFB_window.h | 2 +- vs/sdl2/src/video/dummy/SDL_nullevents.c | 4 +- vs/sdl2/src/video/dummy/SDL_nullevents_c.h | 2 +- vs/sdl2/src/video/dummy/SDL_nullframebuffer.c | 8 +- .../src/video/dummy/SDL_nullframebuffer_c.h | 2 +- vs/sdl2/src/video/dummy/SDL_nullvideo.c | 33 +- vs/sdl2/src/video/dummy/SDL_nullvideo.h | 2 +- .../video/emscripten/SDL_emscriptenevents.c | 8 +- .../video/emscripten/SDL_emscriptenevents.h | 2 +- .../emscripten/SDL_emscriptenframebuffer.c | 8 +- .../emscripten/SDL_emscriptenframebuffer.h | 2 +- .../video/emscripten/SDL_emscriptenmouse.c | 69 +- .../video/emscripten/SDL_emscriptenmouse.h | 2 +- .../video/emscripten/SDL_emscriptenopengles.c | 4 +- .../video/emscripten/SDL_emscriptenopengles.h | 4 +- .../video/emscripten/SDL_emscriptenvideo.c | 18 +- .../video/emscripten/SDL_emscriptenvideo.h | 6 +- vs/sdl2/src/video/haiku/SDL_BApp.h | 10 +- vs/sdl2/src/video/haiku/SDL_BWin.h | 14 +- vs/sdl2/src/video/haiku/SDL_bclipboard.cc | 6 +- vs/sdl2/src/video/haiku/SDL_bclipboard.h | 2 +- vs/sdl2/src/video/haiku/SDL_bevents.cc | 4 +- vs/sdl2/src/video/haiku/SDL_bevents.h | 2 +- vs/sdl2/src/video/haiku/SDL_bframebuffer.cc | 6 +- vs/sdl2/src/video/haiku/SDL_bframebuffer.h | 2 +- vs/sdl2/src/video/haiku/SDL_bkeyboard.cc | 4 +- vs/sdl2/src/video/haiku/SDL_bkeyboard.h | 2 +- vs/sdl2/src/video/haiku/SDL_bmessagebox.cc | 12 +- vs/sdl2/src/video/haiku/SDL_bmessagebox.h | 4 +- vs/sdl2/src/video/haiku/SDL_bmodes.cc | 8 +- vs/sdl2/src/video/haiku/SDL_bmodes.h | 2 +- vs/sdl2/src/video/haiku/SDL_bopengl.cc | 12 +- vs/sdl2/src/video/haiku/SDL_bopengl.h | 4 +- vs/sdl2/src/video/haiku/SDL_bvideo.cc | 20 +- vs/sdl2/src/video/haiku/SDL_bvideo.h | 2 +- vs/sdl2/src/video/haiku/SDL_bwindow.cc | 6 +- vs/sdl2/src/video/haiku/SDL_bwindow.h | 2 +- vs/sdl2/src/video/khronos/EGL/egl.h | 4 +- vs/sdl2/src/video/khronos/EGL/eglext.h | 28 +- vs/sdl2/src/video/khronos/EGL/eglplatform.h | 6 + vs/sdl2/src/video/khronos/GLES2/gl2.h | 2 +- vs/sdl2/src/video/khronos/GLES2/gl2ext.h | 74 +- .../vk_video/vulkan_video_codec_h264std.h | 312 + .../vulkan_video_codec_h264std_decode.h | 77 + .../vulkan_video_codec_h264std_encode.h | 147 + .../vk_video/vulkan_video_codec_h265std.h | 446 ++ .../vulkan_video_codec_h265std_decode.h | 67 + .../vulkan_video_codec_h265std_encode.h | 157 + .../vk_video/vulkan_video_codecs_common.h | 36 + vs/sdl2/src/video/khronos/vulkan/vk_icd.h | 47 +- vs/sdl2/src/video/khronos/vulkan/vk_layer.h | 33 +- .../src/video/khronos/vulkan/vk_platform.h | 2 +- vs/sdl2/src/video/khronos/vulkan/vulkan.h | 11 +- .../src/video/khronos/vulkan/vulkan_android.h | 30 +- .../src/video/khronos/vulkan/vulkan_beta.h | 1102 +--- .../src/video/khronos/vulkan/vulkan_core.h | 5336 +++++++++++++++-- .../video/khronos/vulkan/vulkan_directfb.h | 3 +- .../src/video/khronos/vulkan/vulkan_fuchsia.h | 6 +- vs/sdl2/src/video/khronos/vulkan/vulkan_ggp.h | 4 +- vs/sdl2/src/video/khronos/vulkan/vulkan_ios.h | 3 +- .../src/video/khronos/vulkan/vulkan_macos.h | 3 +- .../src/video/khronos/vulkan/vulkan_metal.h | 4 +- .../src/video/khronos/vulkan/vulkan_screen.h | 56 +- vs/sdl2/src/video/khronos/vulkan/vulkan_vi.h | 3 +- .../src/video/khronos/vulkan/vulkan_wayland.h | 3 +- .../src/video/khronos/vulkan/vulkan_win32.h | 29 +- vs/sdl2/src/video/khronos/vulkan/vulkan_xcb.h | 3 +- .../src/video/khronos/vulkan/vulkan_xlib.h | 3 +- .../video/khronos/vulkan/vulkan_xlib_xrandr.h | 3 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.c | 16 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.h | 2 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.c | 4 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.h | 4 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.c | 18 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.h | 2 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.c | 18 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.h | 4 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmsym.h | 5 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.c | 84 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.h | 2 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.c | 10 +- vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.h | 4 +- vs/sdl2/src/video/n3ds/SDL_n3dsevents.c | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dsevents_c.h | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer.c | 6 +- .../src/video/n3ds/SDL_n3dsframebuffer_c.h | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dsswkb.c | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dsswkb.h | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dstouch.c | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dstouch.h | 2 +- vs/sdl2/src/video/n3ds/SDL_n3dsvideo.c | 14 +- vs/sdl2/src/video/n3ds/SDL_n3dsvideo.h | 2 +- vs/sdl2/src/video/nacl/SDL_naclevents.c | 4 +- vs/sdl2/src/video/nacl/SDL_naclevents_c.h | 2 +- vs/sdl2/src/video/nacl/SDL_naclglue.c | 4 +- vs/sdl2/src/video/nacl/SDL_naclopengles.c | 4 +- vs/sdl2/src/video/nacl/SDL_naclopengles.h | 2 +- vs/sdl2/src/video/nacl/SDL_naclvideo.c | 7 +- vs/sdl2/src/video/nacl/SDL_naclvideo.h | 2 +- vs/sdl2/src/video/nacl/SDL_naclwindow.c | 4 +- vs/sdl2/src/video/nacl/SDL_naclwindow.h | 2 +- vs/sdl2/src/video/ngage/SDL_ngageevents.cpp | 4 +- vs/sdl2/src/video/ngage/SDL_ngageevents_c.h | 2 +- .../src/video/ngage/SDL_ngageframebuffer.cpp | 8 +- .../src/video/ngage/SDL_ngageframebuffer_c.h | 2 +- vs/sdl2/src/video/ngage/SDL_ngagevideo.cpp | 11 +- vs/sdl2/src/video/ngage/SDL_ngagevideo.h | 2 +- vs/sdl2/src/video/ngage/SDL_ngagewindow.cpp | 6 +- vs/sdl2/src/video/ngage/SDL_ngagewindow.h | 2 +- .../src/video/offscreen/SDL_offscreenevents.c | 4 +- .../video/offscreen/SDL_offscreenevents_c.h | 2 +- .../offscreen/SDL_offscreenframebuffer.c | 8 +- .../offscreen/SDL_offscreenframebuffer_c.h | 2 +- .../video/offscreen/SDL_offscreenopengles.c | 4 +- .../video/offscreen/SDL_offscreenopengles.h | 4 +- .../src/video/offscreen/SDL_offscreenvideo.c | 11 +- .../src/video/offscreen/SDL_offscreenvideo.h | 2 +- .../src/video/offscreen/SDL_offscreenwindow.c | 10 +- .../src/video/offscreen/SDL_offscreenwindow.h | 4 +- vs/sdl2/src/video/os2/SDL_os2dive.c | 10 +- vs/sdl2/src/video/os2/SDL_os2messagebox.c | 26 +- vs/sdl2/src/video/os2/SDL_os2messagebox.h | 4 +- vs/sdl2/src/video/os2/SDL_os2mouse.c | 14 +- vs/sdl2/src/video/os2/SDL_os2mouse.h | 2 +- vs/sdl2/src/video/os2/SDL_os2output.h | 2 +- vs/sdl2/src/video/os2/SDL_os2util.c | 6 +- vs/sdl2/src/video/os2/SDL_os2util.h | 2 +- vs/sdl2/src/video/os2/SDL_os2video.c | 93 +- vs/sdl2/src/video/os2/SDL_os2video.h | 2 +- vs/sdl2/src/video/os2/SDL_os2vman.c | 24 +- vs/sdl2/src/video/pandora/SDL_pandora.c | 64 +- vs/sdl2/src/video/pandora/SDL_pandora.h | 2 +- .../src/video/pandora/SDL_pandora_events.c | 4 +- .../src/video/pandora/SDL_pandora_events.h | 2 +- vs/sdl2/src/video/ps2/SDL_ps2video.c | 9 +- vs/sdl2/src/video/ps2/SDL_ps2video.h | 2 +- vs/sdl2/src/video/psp/SDL_pspevents.c | 13 +- vs/sdl2/src/video/psp/SDL_pspevents_c.h | 4 +- vs/sdl2/src/video/psp/SDL_pspgl.c | 4 +- vs/sdl2/src/video/psp/SDL_pspgl_c.h | 2 +- vs/sdl2/src/video/psp/SDL_pspmouse.c | 4 +- vs/sdl2/src/video/psp/SDL_pspmouse_c.h | 2 +- vs/sdl2/src/video/psp/SDL_pspvideo.c | 25 +- vs/sdl2/src/video/psp/SDL_pspvideo.h | 2 +- vs/sdl2/src/video/qnx/gl.c | 2 +- vs/sdl2/src/video/qnx/video.c | 7 +- vs/sdl2/src/video/raspberry/SDL_rpievents.c | 4 +- vs/sdl2/src/video/raspberry/SDL_rpievents_c.h | 4 +- vs/sdl2/src/video/raspberry/SDL_rpimouse.c | 30 +- vs/sdl2/src/video/raspberry/SDL_rpimouse.h | 2 +- vs/sdl2/src/video/raspberry/SDL_rpiopengles.c | 4 +- vs/sdl2/src/video/raspberry/SDL_rpiopengles.h | 4 +- vs/sdl2/src/video/raspberry/SDL_rpivideo.c | 17 +- vs/sdl2/src/video/raspberry/SDL_rpivideo.h | 4 +- vs/sdl2/src/video/riscos/SDL_riscosdefs.h | 2 +- vs/sdl2/src/video/riscos/SDL_riscosevents.c | 6 +- vs/sdl2/src/video/riscos/SDL_riscosevents_c.h | 2 +- .../src/video/riscos/SDL_riscosframebuffer.c | 8 +- .../video/riscos/SDL_riscosframebuffer_c.h | 2 +- .../src/video/riscos/SDL_riscosmessagebox.c | 4 +- .../src/video/riscos/SDL_riscosmessagebox.h | 4 +- vs/sdl2/src/video/riscos/SDL_riscosmodes.c | 16 +- vs/sdl2/src/video/riscos/SDL_riscosmodes.h | 2 +- vs/sdl2/src/video/riscos/SDL_riscosmouse.c | 4 +- vs/sdl2/src/video/riscos/SDL_riscosmouse.h | 2 +- vs/sdl2/src/video/riscos/SDL_riscosvideo.c | 12 +- vs/sdl2/src/video/riscos/SDL_riscosvideo.h | 2 +- vs/sdl2/src/video/riscos/SDL_riscoswindow.c | 8 +- vs/sdl2/src/video/riscos/SDL_riscoswindow.h | 2 +- vs/sdl2/src/video/riscos/scancodes_riscos.h | 2 +- vs/sdl2/src/video/sdlgenblit.pl | 12 +- .../src/video/uikit/SDL_uikitappdelegate.h | 2 +- .../src/video/uikit/SDL_uikitappdelegate.m | 6 +- vs/sdl2/src/video/uikit/SDL_uikitclipboard.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitclipboard.m | 4 +- vs/sdl2/src/video/uikit/SDL_uikitevents.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitevents.m | 51 +- vs/sdl2/src/video/uikit/SDL_uikitmessagebox.h | 4 +- vs/sdl2/src/video/uikit/SDL_uikitmessagebox.m | 4 +- vs/sdl2/src/video/uikit/SDL_uikitmetalview.h | 10 +- vs/sdl2/src/video/uikit/SDL_uikitmetalview.m | 4 +- vs/sdl2/src/video/uikit/SDL_uikitmodes.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitmodes.m | 6 +- vs/sdl2/src/video/uikit/SDL_uikitopengles.h | 6 +- vs/sdl2/src/video/uikit/SDL_uikitopengles.m | 6 +- vs/sdl2/src/video/uikit/SDL_uikitopenglview.h | 4 +- vs/sdl2/src/video/uikit/SDL_uikitopenglview.m | 4 +- vs/sdl2/src/video/uikit/SDL_uikitvideo.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitvideo.m | 18 +- vs/sdl2/src/video/uikit/SDL_uikitview.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitview.m | 10 +- .../src/video/uikit/SDL_uikitviewcontroller.h | 12 +- .../src/video/uikit/SDL_uikitviewcontroller.m | 35 +- vs/sdl2/src/video/uikit/SDL_uikitvulkan.h | 4 +- vs/sdl2/src/video/uikit/SDL_uikitvulkan.m | 4 +- vs/sdl2/src/video/uikit/SDL_uikitwindow.h | 2 +- vs/sdl2/src/video/uikit/SDL_uikitwindow.m | 18 +- vs/sdl2/src/video/vita/SDL_vitaframebuffer.c | 6 +- vs/sdl2/src/video/vita/SDL_vitaframebuffer.h | 2 +- vs/sdl2/src/video/vita/SDL_vitagl_pvr.c | 8 +- vs/sdl2/src/video/vita/SDL_vitagl_pvr_c.h | 2 +- vs/sdl2/src/video/vita/SDL_vitagles.c | 4 +- vs/sdl2/src/video/vita/SDL_vitagles_c.h | 2 +- vs/sdl2/src/video/vita/SDL_vitagles_pvr.c | 8 +- vs/sdl2/src/video/vita/SDL_vitagles_pvr_c.h | 2 +- vs/sdl2/src/video/vita/SDL_vitakeyboard.c | 6 +- vs/sdl2/src/video/vita/SDL_vitakeyboard.h | 2 +- vs/sdl2/src/video/vita/SDL_vitamessagebox.c | 4 +- vs/sdl2/src/video/vita/SDL_vitamessagebox.h | 4 +- vs/sdl2/src/video/vita/SDL_vitamouse.c | 6 +- vs/sdl2/src/video/vita/SDL_vitamouse_c.h | 2 +- vs/sdl2/src/video/vita/SDL_vitatouch.c | 6 +- vs/sdl2/src/video/vita/SDL_vitatouch.h | 2 +- vs/sdl2/src/video/vita/SDL_vitavideo.c | 22 +- vs/sdl2/src/video/vita/SDL_vitavideo.h | 4 +- .../src/video/vivante/SDL_vivanteopengles.c | 4 +- .../src/video/vivante/SDL_vivanteopengles.h | 4 +- .../src/video/vivante/SDL_vivanteplatform.c | 4 +- .../src/video/vivante/SDL_vivanteplatform.h | 4 +- vs/sdl2/src/video/vivante/SDL_vivantevideo.c | 43 +- vs/sdl2/src/video/vivante/SDL_vivantevideo.h | 6 +- vs/sdl2/src/video/vivante/SDL_vivantevulkan.c | 10 +- vs/sdl2/src/video/vivante/SDL_vivantevulkan.h | 4 +- .../src/video/wayland/SDL_waylandclipboard.c | 32 +- .../src/video/wayland/SDL_waylandclipboard.h | 2 +- .../video/wayland/SDL_waylanddatamanager.c | 92 +- .../video/wayland/SDL_waylanddatamanager.h | 3 +- vs/sdl2/src/video/wayland/SDL_waylanddyn.c | 51 +- vs/sdl2/src/video/wayland/SDL_waylanddyn.h | 2 +- vs/sdl2/src/video/wayland/SDL_waylandevents.c | 332 +- .../src/video/wayland/SDL_waylandevents_c.h | 2 +- .../src/video/wayland/SDL_waylandkeyboard.c | 16 +- .../src/video/wayland/SDL_waylandkeyboard.h | 2 +- .../src/video/wayland/SDL_waylandmessagebox.c | 18 +- .../src/video/wayland/SDL_waylandmessagebox.h | 4 +- vs/sdl2/src/video/wayland/SDL_waylandmouse.c | 203 +- vs/sdl2/src/video/wayland/SDL_waylandmouse.h | 4 +- .../src/video/wayland/SDL_waylandopengles.c | 8 +- .../src/video/wayland/SDL_waylandopengles.h | 2 +- vs/sdl2/src/video/wayland/SDL_waylandsym.h | 6 +- vs/sdl2/src/video/wayland/SDL_waylandtouch.c | 4 +- vs/sdl2/src/video/wayland/SDL_waylandtouch.h | 4 +- vs/sdl2/src/video/wayland/SDL_waylandvideo.c | 102 +- vs/sdl2/src/video/wayland/SDL_waylandvideo.h | 2 +- vs/sdl2/src/video/wayland/SDL_waylandvulkan.c | 10 +- vs/sdl2/src/video/wayland/SDL_waylandvulkan.h | 4 +- vs/sdl2/src/video/wayland/SDL_waylandwindow.c | 101 +- vs/sdl2/src/video/wayland/SDL_waylandwindow.h | 4 +- vs/sdl2/src/video/windows/SDL_msctf.h | 2 +- vs/sdl2/src/video/windows/SDL_vkeys.h | 2 +- .../src/video/windows/SDL_windowsclipboard.c | 6 +- .../src/video/windows/SDL_windowsclipboard.h | 2 +- vs/sdl2/src/video/windows/SDL_windowsevents.c | 160 +- vs/sdl2/src/video/windows/SDL_windowsevents.h | 2 +- .../video/windows/SDL_windowsframebuffer.c | 6 +- .../video/windows/SDL_windowsframebuffer.h | 2 +- .../src/video/windows/SDL_windowskeyboard.c | 78 +- .../src/video/windows/SDL_windowskeyboard.h | 2 +- .../src/video/windows/SDL_windowsmessagebox.c | 36 +- .../src/video/windows/SDL_windowsmessagebox.h | 4 +- vs/sdl2/src/video/windows/SDL_windowsmodes.c | 22 +- vs/sdl2/src/video/windows/SDL_windowsmodes.h | 2 +- vs/sdl2/src/video/windows/SDL_windowsmouse.c | 12 +- vs/sdl2/src/video/windows/SDL_windowsmouse.h | 2 +- vs/sdl2/src/video/windows/SDL_windowsopengl.c | 31 +- vs/sdl2/src/video/windows/SDL_windowsopengl.h | 8 +- .../src/video/windows/SDL_windowsopengles.c | 12 +- .../src/video/windows/SDL_windowsopengles.h | 4 +- vs/sdl2/src/video/windows/SDL_windowsshape.c | 18 +- vs/sdl2/src/video/windows/SDL_windowsshape.h | 2 +- vs/sdl2/src/video/windows/SDL_windowsvideo.c | 28 +- vs/sdl2/src/video/windows/SDL_windowsvideo.h | 2 +- vs/sdl2/src/video/windows/SDL_windowsvulkan.c | 10 +- vs/sdl2/src/video/windows/SDL_windowsvulkan.h | 4 +- vs/sdl2/src/video/windows/SDL_windowswindow.c | 41 +- vs/sdl2/src/video/windows/SDL_windowswindow.h | 6 +- vs/sdl2/src/video/windows/wmmsg.h | 2 +- vs/sdl2/src/video/winrt/SDL_winrtevents.cpp | 4 +- vs/sdl2/src/video/winrt/SDL_winrtevents_c.h | 2 +- vs/sdl2/src/video/winrt/SDL_winrtgamebar.cpp | 10 +- .../src/video/winrt/SDL_winrtgamebar_cpp.h | 2 +- vs/sdl2/src/video/winrt/SDL_winrtkeyboard.cpp | 4 +- .../src/video/winrt/SDL_winrtmessagebox.cpp | 12 +- vs/sdl2/src/video/winrt/SDL_winrtmessagebox.h | 4 +- vs/sdl2/src/video/winrt/SDL_winrtmouse.cpp | 6 +- vs/sdl2/src/video/winrt/SDL_winrtmouse_c.h | 2 +- vs/sdl2/src/video/winrt/SDL_winrtopengles.cpp | 6 +- vs/sdl2/src/video/winrt/SDL_winrtopengles.h | 4 +- .../src/video/winrt/SDL_winrtpointerinput.cpp | 10 +- vs/sdl2/src/video/winrt/SDL_winrtvideo.cpp | 43 +- vs/sdl2/src/video/winrt/SDL_winrtvideo_cpp.h | 4 +- vs/sdl2/src/video/x11/SDL_x11clipboard.c | 11 +- vs/sdl2/src/video/x11/SDL_x11clipboard.h | 2 +- vs/sdl2/src/video/x11/SDL_x11dyn.c | 16 +- vs/sdl2/src/video/x11/SDL_x11dyn.h | 18 +- vs/sdl2/src/video/x11/SDL_x11events.c | 59 +- vs/sdl2/src/video/x11/SDL_x11events.h | 2 +- vs/sdl2/src/video/x11/SDL_x11framebuffer.c | 8 +- vs/sdl2/src/video/x11/SDL_x11framebuffer.h | 2 +- vs/sdl2/src/video/x11/SDL_x11keyboard.c | 14 +- vs/sdl2/src/video/x11/SDL_x11keyboard.h | 2 +- vs/sdl2/src/video/x11/SDL_x11messagebox.c | 34 +- vs/sdl2/src/video/x11/SDL_x11messagebox.h | 4 +- vs/sdl2/src/video/x11/SDL_x11modes.c | 46 +- vs/sdl2/src/video/x11/SDL_x11modes.h | 8 +- vs/sdl2/src/video/x11/SDL_x11mouse.c | 159 +- vs/sdl2/src/video/x11/SDL_x11mouse.h | 2 +- vs/sdl2/src/video/x11/SDL_x11opengl.c | 73 +- vs/sdl2/src/video/x11/SDL_x11opengl.h | 14 +- vs/sdl2/src/video/x11/SDL_x11opengles.c | 6 +- vs/sdl2/src/video/x11/SDL_x11opengles.h | 4 +- vs/sdl2/src/video/x11/SDL_x11shape.c | 22 +- vs/sdl2/src/video/x11/SDL_x11shape.h | 2 +- vs/sdl2/src/video/x11/SDL_x11sym.h | 30 +- vs/sdl2/src/video/x11/SDL_x11touch.c | 4 +- vs/sdl2/src/video/x11/SDL_x11touch.h | 2 +- vs/sdl2/src/video/x11/SDL_x11video.c | 44 +- vs/sdl2/src/video/x11/SDL_x11video.h | 22 +- vs/sdl2/src/video/x11/SDL_x11vulkan.c | 12 +- vs/sdl2/src/video/x11/SDL_x11vulkan.h | 4 +- vs/sdl2/src/video/x11/SDL_x11window.c | 50 +- vs/sdl2/src/video/x11/SDL_x11window.h | 8 +- vs/sdl2/src/video/x11/SDL_x11xfixes.c | 19 +- vs/sdl2/src/video/x11/SDL_x11xfixes.h | 6 +- vs/sdl2/src/video/x11/SDL_x11xinput2.c | 52 +- vs/sdl2/src/video/x11/SDL_x11xinput2.h | 2 +- vs/sdl2/src/video/yuv2rgb/yuv_rgb.h | 401 +- vs/sdl2/src/video/yuv2rgb/yuv_rgb_common.h | 13 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_internal.h | 74 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.c | 44 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.h | 407 ++ vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.c | 464 ++ vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.h | 266 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse_func.h | 12 +- vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.c | 179 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.h | 131 + vs/sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h | 63 +- vs/sdl2/test/CMakeLists.txt | 125 +- vs/sdl2/test/Makefile.in | 23 +- vs/sdl2/test/acinclude.m4 | 4 +- vs/sdl2/test/checkkeys.c | 8 +- vs/sdl2/test/checkkeysthreads.c | 6 +- vs/sdl2/test/configure | 2 +- vs/sdl2/test/controllermap.c | 13 +- vs/sdl2/test/loopwave.c | 4 +- vs/sdl2/test/loopwavequeue.c | 8 +- vs/sdl2/test/testatomic.c | 5 +- vs/sdl2/test/testaudiocapture.c | 2 +- vs/sdl2/test/testaudiohotplug.c | 10 +- vs/sdl2/test/testaudioinfo.c | 8 +- vs/sdl2/test/testautomation.c | 4 +- vs/sdl2/test/testautomation_audio.c | 190 +- vs/sdl2/test/testautomation_clipboard.c | 12 +- vs/sdl2/test/testautomation_events.c | 4 + vs/sdl2/test/testautomation_guid.c | 2 +- vs/sdl2/test/testautomation_keyboard.c | 22 +- vs/sdl2/test/testautomation_log.c | 209 + vs/sdl2/test/testautomation_main.c | 41 +- vs/sdl2/test/testautomation_math.c | 362 +- vs/sdl2/test/testautomation_mouse.c | 56 +- vs/sdl2/test/testautomation_pixels.c | 42 +- vs/sdl2/test/testautomation_platform.c | 2 +- vs/sdl2/test/testautomation_render.c | 21 +- vs/sdl2/test/testautomation_stdlib.c | 139 +- vs/sdl2/test/testautomation_subsystems.c | 239 + vs/sdl2/test/testautomation_suites.h | 4 + vs/sdl2/test/testautomation_surface.c | 41 +- vs/sdl2/test/testautomation_timer.c | 3 + vs/sdl2/test/testautomation_video.c | 234 +- vs/sdl2/test/testbounds.c | 2 +- vs/sdl2/test/testcustomcursor.c | 4 +- vs/sdl2/test/testdisplayinfo.c | 4 +- vs/sdl2/test/testdraw2.c | 4 +- vs/sdl2/test/testdrawchessboard.c | 7 +- vs/sdl2/test/testdropfile.c | 4 +- vs/sdl2/test/testerror.c | 4 +- vs/sdl2/test/testevdev.c | 4 +- vs/sdl2/test/testfile.c | 20 +- vs/sdl2/test/testfilesystem.c | 8 +- vs/sdl2/test/testfilesystem_pre.c | 32 + vs/sdl2/test/testgamecontroller.c | 20 +- vs/sdl2/test/testgeometry.c | 6 +- vs/sdl2/test/testgesture.c | 8 +- vs/sdl2/test/testgl2.c | 20 +- vs/sdl2/test/testgles.c | 8 +- vs/sdl2/test/testgles2.c | 18 +- vs/sdl2/test/testgles2_sdf.c | 20 +- vs/sdl2/test/testhaptic.c | 8 +- vs/sdl2/test/testhittesting.c | 2 +- vs/sdl2/test/testhotplug.c | 4 +- vs/sdl2/test/testiconv.c | 4 +- vs/sdl2/test/testime.c | 28 +- vs/sdl2/test/testintersections.c | 4 +- vs/sdl2/test/testjoystick.c | 8 +- vs/sdl2/test/testkeys.c | 2 +- vs/sdl2/test/testloadso.c | 6 +- vs/sdl2/test/testlocale.c | 4 +- vs/sdl2/test/testlock.c | 4 +- vs/sdl2/test/testmessage.c | 2 +- vs/sdl2/test/testmouse.c | 16 +- vs/sdl2/test/testmultiaudio.c | 2 +- vs/sdl2/test/testnative.c | 16 +- vs/sdl2/test/testnative.h | 2 +- vs/sdl2/test/testnativeos2.c | 2 +- vs/sdl2/test/testnativew32.c | 4 +- vs/sdl2/test/testnativex11.c | 2 +- vs/sdl2/test/testoffscreen.c | 6 +- vs/sdl2/test/testoverlay2.c | 14 +- vs/sdl2/test/testplatform.c | 4 +- vs/sdl2/test/testpower.c | 2 +- vs/sdl2/test/testqsort.c | 2 +- vs/sdl2/test/testrelative.c | 4 +- vs/sdl2/test/testrendercopyex.c | 4 +- vs/sdl2/test/testrendertarget.c | 6 +- vs/sdl2/test/testresample.c | 6 +- vs/sdl2/test/testrumble.c | 8 +- vs/sdl2/test/testscale.c | 4 +- vs/sdl2/test/testsem.c | 2 +- vs/sdl2/test/testsensor.c | 6 +- vs/sdl2/test/testshader.c | 130 +- vs/sdl2/test/testshape.c | 8 +- vs/sdl2/test/testsprite2.c | 41 +- vs/sdl2/test/testspriteminimal.c | 4 +- vs/sdl2/test/teststreaming.c | 12 +- vs/sdl2/test/testsurround.c | 2 +- vs/sdl2/test/testthread.c | 6 +- vs/sdl2/test/testtimer.c | 78 +- vs/sdl2/test/testurl.c | 2 +- vs/sdl2/test/testutils.c | 22 +- vs/sdl2/test/testutils.h | 2 +- vs/sdl2/test/testver.c | 2 +- vs/sdl2/test/testviewport.c | 6 +- vs/sdl2/test/testvulkan.c | 14 +- vs/sdl2/test/testwm2.c | 8 +- vs/sdl2/test/testyuv.c | 14 +- vs/sdl2/test/testyuv_cvt.c | 2 +- vs/sdl2/test/testyuv_cvt.h | 2 +- vs/sdl2/test/torturethread.c | 2 +- vs/sdl2/test/watcom.mif | 22 +- 1215 files changed, 30228 insertions(+), 15829 deletions(-) create mode 100644 vs/sdl2/src/filesystem/gdk/SDL_sysfilesystem.cpp create mode 100644 vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.c create mode 100644 vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.h create mode 100644 vs/sdl2/src/joystick/hidapi/SDL_hidapi_steamdeck.c create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h create mode 100644 vs/sdl2/src/video/khronos/vk_video/vulkan_video_codecs_common.h create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_common.h create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_internal.h create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.c create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.h create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.c create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.h create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.c create mode 100644 vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.h create mode 100644 vs/sdl2/test/testautomation_log.c create mode 100644 vs/sdl2/test/testautomation_subsystems.c create mode 100644 vs/sdl2/test/testfilesystem_pre.c diff --git a/vs/sdl2/CMakeLists.txt b/vs/sdl2/CMakeLists.txt index 00cf9b43fb..8b5bd70565 100644 --- a/vs/sdl2/CMakeLists.txt +++ b/vs/sdl2/CMakeLists.txt @@ -2,6 +2,9 @@ if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR}) message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there") endif() +# MSVC runtime library flags are selected by an abstraction. +set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) + cmake_minimum_required(VERSION 3.0.0...3.5) project(SDL2 C CXX) @@ -83,8 +86,8 @@ endif() # See docs/release_checklist.md set(SDL_MAJOR_VERSION 2) -set(SDL_MINOR_VERSION 28) -set(SDL_MICRO_VERSION 2) +set(SDL_MINOR_VERSION 30) +set(SDL_MICRO_VERSION 4) set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}") # Set defaults preventing destination file conflicts @@ -224,11 +227,13 @@ elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+ elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$") set(OPT_DEF_ASM TRUE) set(USE_INTELCC TRUE) +elseif(CMAKE_C_COMPILER_ID MATCHES "QCC") + set(USE_QCC TRUE) else() set(OPT_DEF_ASM FALSE) endif() -if(USE_GCC OR USE_CLANG OR USE_INTELCC) +if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) set(OPT_DEF_GCC_ATOMICS ON) endif() @@ -236,6 +241,11 @@ endif() if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS) set(OPT_DEF_LIBC ON) endif() +if(WINDOWS OR DARWIN OR MACOSX OR IOS OR TVOS) + set(SDL_SYSTEM_ICONV_DEFAULT OFF) +else() + set(SDL_SYSTEM_ICONV_DEFAULT ON) +endif() if(NOT ("$ENV{CFLAGS}" STREQUAL "")) if(CMAKE_VERSION VERSION_LESS 3.11.0) @@ -253,6 +263,9 @@ endif() if(MSVC) option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) if(SDL_FORCE_STATIC_VCRT) + if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() foreach(flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) @@ -412,7 +425,8 @@ set_option(SDL_DIRECTFB "Use DirectFB video driver" OFF) dep_option(SDL_DIRECTFB_SHARED "Dynamically load directfb support" ON "SDL_DIRECTFB" OFF) set_option(SDL_DUMMYVIDEO "Use dummy video driver" ON) dep_option(SDL_IBUS "Enable IBus support" ON ${UNIX_SYS} OFF) -set_option(SDL_SYSTEM_ICONV "Use iconv() from system-installed libraries" ON) +set_option(SDL_SYSTEM_ICONV "Use iconv() from system-installed libraries" ${SDL_SYSTEM_ICONV_DEFAULT}) +set_option(SDL_LIBICONV "Prefer iconv() from libiconv, if available, over libc version" OFF) set_option(SDL_OPENGL "Include OpenGL support" ON) set_option(SDL_OPENGLES "Include OpenGL ES support" ON) set_option(SDL_PTHREADS "Use POSIX threads for multi-threading" ${SDL_PTHREADS_ENABLED_BY_DEFAULT}) @@ -563,7 +577,7 @@ if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF") endif() # Compiler option evaluation -if(USE_GCC OR USE_CLANG OR USE_INTELCC) +if(USE_GCC OR USE_CLANG OR USE_INTELCC OR USE_QCC) # Check for -Wall first, so later things can override pieces of it. # Note: clang-cl treats -Wall as -Weverything (which is very loud), # /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough. @@ -577,11 +591,50 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC) endif() endif() + check_c_compiler_flag(-Wundef HAVE_GCC_WUNDEF) + if(HAVE_GCC_WUNDEF) + list(APPEND EXTRA_CFLAGS "-Wundef") + endif() + check_c_compiler_flag(-fno-strict-aliasing HAVE_GCC_NO_STRICT_ALIASING) if(HAVE_GCC_NO_STRICT_ALIASING) list(APPEND EXTRA_CFLAGS "-fno-strict-aliasing") endif() + check_c_compiler_flag(-Wdocumentation HAVE_GCC_WDOCUMENTATION) + if(HAVE_GCC_WDOCUMENTATION) + if(SDL_WERROR) + check_c_compiler_flag(-Werror=documentation HAVE_GCC_WERROR_DOCUMENTATION) + if(HAVE_GCC_WERROR_DOCUMENTATION) + list(APPEND EXTRA_CFLAGS "-Werror=documentation") + endif() + endif() + list(APPEND EXTRA_CFLAGS "-Wdocumentation") + endif() + + check_c_compiler_flag(-Wdocumentation-unknown-command HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) + if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) + if(SDL_WERROR) + check_c_compiler_flag(-Werror=documentation-unknown-command HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) + if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) + list(APPEND EXTRA_CFLAGS "-Werror=documentation-unknown-command") + endif() + endif() + list(APPEND EXTRA_CFLAGS "-Wdocumentation-unknown-command") + endif() + + check_c_compiler_flag(-fcomment-block-commands=threadsafety HAVE_GCC_COMMENT_BLOCK_COMMANDS) + if(HAVE_GCC_COMMENT_BLOCK_COMMANDS) + list(APPEND EXTRA_CFLAGS "-fcomment-block-commands=threadsafety") + list(APPEND EXTRA_CFLAGS "-fcomment-block-commands=deprecated") + else() + check_c_compiler_flag(/clang:-fcomment-block-commands=threadsafety HAVE_CLANG_COMMENT_BLOCK_COMMANDS) + if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS) + list(APPEND EXTRA_CFLAGS "/clang:-fcomment-block-commands=threadsafety") + list(APPEND EXTRA_CFLAGS "/clang:-fcomment-block-commands=deprecated") + endif() + endif() + check_c_compiler_flag(-Wdeclaration-after-statement HAVE_GCC_WDECLARATION_AFTER_STATEMENT) if(HAVE_GCC_WDECLARATION_AFTER_STATEMENT) if(SDL_WERROR) @@ -858,7 +911,7 @@ if(SDL_ASSEMBLY) if(SDL_LSX) cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_FLAGS "-mlsx") + set(CMAKE_REQUIRED_FLAGS "-mlsx") check_c_source_compiles(" #ifndef __loongarch_sx #error Assembler CPP flag not enabled @@ -873,22 +926,6 @@ if(SDL_ASSEMBLY) endif() endif() - if(SDL_LASX) - cmake_push_check_state() - list(APPEND CMAKE_REQUIRED_FLAGS "-mlasx") - check_c_source_compiles(" - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LASX) - check_include_file("lasxintrin.h" HAVE_LASXINTRIN_H) - cmake_pop_check_state() - if(CPU_SUPPORTS_LASX AND HAVE_LASXINTRIN_H) - list(APPEND EXTRA_CFLAGS "-mlasx") - set(HAVE_LASX TRUE) - endif() - endif() - if(SDL_ARMSIMD) set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp") @@ -1018,15 +1055,11 @@ if(SDL_LIBC) sys/types.h wchar.h ) - if(NOT EMSCRIPTEN) - list(APPEND headers_to_check libunwind.h) - endif() foreach(_HEADER ${headers_to_check}) string(TOUPPER "HAVE_${_HEADER}" _UPPER) string(REGEX REPLACE "[./]" "_" _HAVE_H ${_UPPER}) check_include_file("${_HEADER}" ${_HAVE_H}) endforeach() - check_include_file(linux/input.h HAVE_LINUX_INPUT_H) set(STDC_HEADER_NAMES "stddef.h;stdarg.h;stdlib.h;string.h;stdio.h;wchar.h;float.h") check_include_files("${STDC_HEADER_NAMES}" STDC_HEADERS) @@ -1058,6 +1091,8 @@ if(SDL_LIBC) check_symbol_exists(getauxval "sys/auxv.h" HAVE_GETAUXVAL) check_symbol_exists(elf_aux_info "sys/auxv.h" HAVE_ELF_AUX_INFO) check_symbol_exists(poll "poll.h" HAVE_POLL) + check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE) + check_symbol_exists(posix_fallocate "fcntl.h" HAVE_POSIX_FALLOCATE) check_library_exists(m pow "" HAVE_LIBM) if(HAVE_LIBM) @@ -1080,16 +1115,31 @@ if(SDL_LIBC) endif() if(SDL_SYSTEM_ICONV) - check_library_exists(iconv iconv_open "" HAVE_LIBICONV) - if(HAVE_LIBICONV) - list(APPEND EXTRA_LIBS iconv) + check_c_source_compiles(" + #define LIBICONV_PLUG 1 /* in case libiconv header is in include path */ + #include + #include + int main(int argc, char **argv) { + return !iconv_open(NULL,NULL); + }" ICONV_IN_LIBC) + + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_LIBRARIES iconv) + check_c_source_compiles(" + #include + #include + int main(int argc, char **argv) { + return !iconv_open(NULL,NULL); + }" ICONV_IN_LIBICONV) + cmake_pop_check_state() + + if(ICONV_IN_LIBC OR ICONV_IN_LIBICONV) set(HAVE_ICONV 1) set(HAVE_SYSTEM_ICONV TRUE) - else() - check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV) - if(HAVE_BUILTIN_ICONV) - set(HAVE_ICONV 1) - set(HAVE_SYSTEM_ICONV TRUE) + if(ICONV_IN_LIBICONV AND (SDL_LIBICONV OR (NOT ICONV_IN_LIBC))) + set(SDL_USE_LIBICONV 1) + set(HAVE_LIBICONV TRUE) + list(APPEND EXTRA_LIBS iconv) endif() endif() endif() @@ -1400,10 +1450,7 @@ elseif(EMSCRIPTEN) endif() CheckPTHREAD() - - if(HAVE_LIBUNWIND_H) - list(APPEND EXTRA_TEST_LIBS unwind) - endif() + CheckLibUnwind() elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) if(SDL_AUDIO) @@ -1422,6 +1469,12 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) file(GLOB AIX_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/paudio/*.c) list(APPEND SOURCE_FILES ${AIX_AUDIO_SOURCES}) set(HAVE_SDL_AUDIO TRUE) + elseif(QNX) + set(SDL_AUDIO_DRIVER_QSA 1) + file(GLOB QSA_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/qsa/*.c) + list(APPEND SOURCE_FILES ${QSA_AUDIO_SOURCES}) + list(APPEND EXTRA_LIBS asound) + set(HAVE_SDL_AUDIO TRUE) endif() CheckOSS() CheckALSA() @@ -1453,6 +1506,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(SDL_VIDEO_VULKAN 1) set(HAVE_VULKAN TRUE) endif() + CheckQNXScreen() endif() if(UNIX) @@ -1464,7 +1518,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) #ifndef EVIOCGNAME #error EVIOCGNAME() ioctl not available #endif - int main(int argc, char** argv) { return 0; }" HAVE_INPUT_EVENTS) + int main(int argc, char** argv) { return 0; }" HAVE_LINUX_INPUT_H) if(LINUX) check_c_source_compiles(" @@ -1500,11 +1554,11 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) }" HAVE_INPUT_WSCONS) endif() - if(HAVE_INPUT_EVENTS) + if(HAVE_LINUX_INPUT_H) set(SDL_INPUT_LINUXEV 1) endif() - if(SDL_HAPTIC AND HAVE_INPUT_EVENTS) + if(SDL_HAPTIC AND HAVE_LINUX_INPUT_H) set(SDL_HAPTIC_LINUX 1) file(GLOB HAPTIC_SOURCES ${SDL2_SOURCE_DIR}/src/haptic/linux/*.c) list(APPEND SOURCE_FILES ${HAPTIC_SOURCES}) @@ -1567,15 +1621,8 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) endif() endif() - if(HAVE_LIBUNWIND_H) - # We've already found the header, so link the lib if present. - # NB: This .pc file is not present on FreeBSD where the implicitly - # linked base system libgcc_s includes all libunwind ABI. - pkg_search_module(UNWIND libunwind) - pkg_search_module(UNWIND_GENERIC libunwind-generic) - list(APPEND EXTRA_TEST_LIBS ${UNWIND_LIBRARIES} ${UNWIND_GENERIC_LIBRARIES}) - endif() endif() + CheckLibUnwind() if(HAVE_DBUS_DBUS_H) list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_dbus.c") @@ -1597,7 +1644,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_udev.c") endif() - if(HAVE_INPUT_EVENTS) + if(HAVE_LINUX_INPUT_H) list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev.c") list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev_kbd.c") endif() @@ -1606,6 +1653,11 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/freebsd/SDL_evdev_kbd_freebsd.c") endif() + if(HAVE_INPUT_WSCONS) + list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/openbsd/SDL_wscons_kbd.c") + list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/openbsd/SDL_wscons_mouse.c") + endif() + # Always compiled for Linux, unconditionally: list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_evdev_capabilities.c") list(APPEND SOURCE_FILES "${SDL2_SOURCE_DIR}/src/core/linux/SDL_threadprio.c") @@ -1703,6 +1755,13 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU) set(HAVE_RPATH TRUE) endif() + if(QNX) + # QNX's *printf() family generates a SIGSEGV if NULL is passed for a string + # specifier (on purpose), but SDL expects "(null)". Use the built-in + # implementation. + set(HAVE_VSNPRINTF 0) + set(USE_POSIX_SPAWN 1) + endif() elseif(WINDOWS) find_program(WINDRES windres) @@ -1751,13 +1810,11 @@ elseif(WINDOWS) check_include_file(d3d9.h HAVE_D3D_H) check_include_file(d3d11_1.h HAVE_D3D11_H) check_c_source_compiles(" - #include - #include #include + #include ID3D12Device1 *device; - #if WDK_NTDDI_VERSION > 0x0A000008 - int main(int argc, char **argv) { return 0; } - #endif" HAVE_D3D12_H) + int main(int argc, char **argv) {return 0; } + " HAVE_D3D12_H) check_include_file(ddraw.h HAVE_DDRAW_H) check_include_file(dsound.h HAVE_DSOUND_H) check_include_file(dinput.h HAVE_DINPUT_H) @@ -1782,16 +1839,6 @@ elseif(WINDOWS) #include #include int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_H) - check_c_source_compiles(" - #include - #include - XINPUT_GAMEPAD_EX x1; - int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_GAMEPAD_EX) - check_c_source_compiles(" - #include - #include - XINPUT_STATE_EX s1; - int main(int argc, char **argv) { return 0; }" HAVE_XINPUT_STATE_EX) check_c_source_compiles(" #define COBJMACROS #include @@ -2467,7 +2514,7 @@ elseif(VITA) ${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_syscond.c ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c) set(HAVE_SDL_THREADS TRUE) endif() @@ -2619,7 +2666,10 @@ elseif(PSP) endif() if(SDL_THREADS) set(SDL_THREAD_PSP 1) - file(GLOB PSP_THREAD_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c ${SDL2_SOURCE_DIR}/src/thread/psp/*.c) + file(GLOB PSP_THREAD_SOURCES + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c + ${SDL2_SOURCE_DIR}/src/thread/psp/*.c) list(APPEND SOURCE_FILES ${PSP_THREAD_SOURCES}) set(HAVE_SDL_THREADS TRUE) endif() @@ -2680,7 +2730,11 @@ elseif(PS2) endif() if(SDL_THREADS) set(SDL_THREAD_PS2 1) - file(GLOB PS2_THREAD_SOURCES ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_sysmutex.c ${SDL2_SOURCE_DIR}/src/thread/ps2/*.c) + file(GLOB PS2_THREAD_SOURCES + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_sysmutex.c + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c + ${SDL2_SOURCE_DIR}/src/thread/ps2/*.c) list(APPEND SOURCE_FILES ${PS2_THREAD_SOURCES}) set(HAVE_SDL_THREADS TRUE) endif() @@ -2811,7 +2865,9 @@ elseif(N3DS) if(SDL_THREADS) set(SDL_THREAD_N3DS 1) file(GLOB N3DS_THREAD_SOURCES ${SDL2_SOURCE_DIR}/src/thread/n3ds/*.c) - list(APPEND SOURCE_FILES ${N3DS_THREAD_SOURCES} ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c) + list(APPEND SOURCE_FILES ${N3DS_THREAD_SOURCES} + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_systls.c + ${SDL2_SOURCE_DIR}/src/thread/generic/SDL_syscond.c) set(HAVE_SDL_THREADS TRUE) endif() @@ -2999,6 +3055,10 @@ endif() listtostr(EXTRA_CFLAGS _EXTRA_CFLAGS) set(EXTRA_CFLAGS ${_EXTRA_CFLAGS}) +if(USE_GCC OR USE_CLANG) + string(REGEX REPLACE "(^| )-I" "\\1 -isystem" EXTRA_CFLAGS "${EXTRA_CFLAGS}") +endif() + # Compat helpers for the configuration files if(EXISTS "${PROJECT_SOURCE_DIR}/VERSION.txt") @@ -3061,9 +3121,17 @@ else() set(sdl_static_libname "SDL2") endif() -set(prefix ${CMAKE_INSTALL_PREFIX}) +# CMAKE_PREFIX_PATH and CMAKE_INSTALL_FULL_BINDIR can be a non-absolute path +# when a master-project does e.g. `set(CMAKE_INSTALL_PREFIX "libs/SDL2" CACHE PATH "prefix" FORCE)`. +if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}") + set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}") +endif() +if(NOT IS_ABSOLUTE "${CMAKE_INSTALL_FULL_BINDIR}") + set(CMAKE_INSTALL_FULL_BINDIR "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_FULL_BINDIR}") +endif() file(RELATIVE_PATH bin_prefix_relpath "${CMAKE_INSTALL_FULL_BINDIR}" "${CMAKE_INSTALL_PREFIX}") +set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(bindir "\${exec_prefix}/${CMAKE_INSTALL_BINDIR}") @@ -3182,7 +3250,7 @@ if (SDL_ASAN) endif() if(SDL_CCACHE AND NOT CMAKE_VERSION VERSION_LESS 3.4) - cmake_minimum_required(VERSION 3.4) + cmake_minimum_required(VERSION 3.4...3.5) find_program(CCACHE_BINARY ccache) if(CCACHE_BINARY) set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_BINARY}) @@ -3307,6 +3375,12 @@ if(ANDROID) endif() if(APPLE) + cmake_push_check_state(RESET) + check_c_compiler_flag(-fobjc-arc COMPILER_SUPPORTS_FOBJC_ARC) + cmake_pop_check_state() + if(NOT COMPILER_SUPPORTS_FOBJC_ARC) + message(FATAL_ERROR "Compiler does not support -fobjc-arc: this is required on Apple platforms") + endif() target_compile_options(sdl-build-options INTERFACE "-fobjc-arc") endif() @@ -3448,6 +3522,7 @@ if(SDL_TEST) "$" "$") target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS}) + target_include_directories(SDL2_test PRIVATE ${EXTRA_TEST_INCLUDES}) set_property(TARGET SDL2_test APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION") set_property(TARGET SDL2_test PROPERTY INTERFACE_SDL_VERSION "SDL2") endif() @@ -3459,6 +3534,9 @@ if(NOT SDL2_DISABLE_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + if(MSVC) + SDL_install_pdb(SDL2 "${CMAKE_INSTALL_BINDIR}") + endif() endif() if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN) @@ -3466,6 +3544,9 @@ if(NOT SDL2_DISABLE_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + if(MSVC) + SDL_install_pdb(SDL2main "${CMAKE_INSTALL_LIBDIR}") + endif() endif() if(SDL_STATIC) @@ -3473,6 +3554,9 @@ if(NOT SDL2_DISABLE_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + if(MSVC) + SDL_install_pdb(SDL2-static "${CMAKE_INSTALL_LIBDIR}") + endif() endif() if(SDL_TEST) @@ -3480,6 +3564,9 @@ if(NOT SDL2_DISABLE_INSTALL) LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") + if(MSVC) + SDL_install_pdb(SDL2_test "${CMAKE_INSTALL_LIBDIR}") + endif() endif() ##### Export files ##### diff --git a/vs/sdl2/LICENSE.txt b/vs/sdl2/LICENSE.txt index 83d8937efe..74bb56cdd5 100644 --- a/vs/sdl2/LICENSE.txt +++ b/vs/sdl2/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (C) 1997-2023 Sam Lantinga +Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/Makefile.in b/vs/sdl2/Makefile.in index eb4c4bc1ab..27e0bbbf3b 100644 --- a/vs/sdl2/Makefile.in +++ b/vs/sdl2/Makefile.in @@ -52,7 +52,7 @@ WAYLAND_SCANNER_CODE_MODE = @WAYLAND_SCANNER_CODE_MODE@ INSTALL_SDL2_CONFIG = @INSTALL_SDL2_CONFIG@ -SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-WinRT Xcode Xcode-iOS wayland-protocols +SRC_DIST = *.md *.txt acinclude Android.mk autogen.sh android-project build-scripts cmake cmake_uninstall.cmake.in configure configure.ac docs include Makefile.* mingw sdl2-config.cmake.in sdl2-config-version.cmake.in sdl2-config.in sdl2.m4 sdl2.pc.in SDL2.spec.in SDL2Config.cmake.in src test VisualC VisualC-GDK VisualC-WinRT Xcode Xcode-iOS wayland-protocols GEN_DIST = SDL2.spec ifneq ($V,1) diff --git a/vs/sdl2/Makefile.os2 b/vs/sdl2/Makefile.os2 index 88dbd07cbb..ca8b876d18 100644 --- a/vs/sdl2/Makefile.os2 +++ b/vs/sdl2/Makefile.os2 @@ -1,4 +1,4 @@ -# Open Watcom makefile to build SDL2.dll for OS/2 +# Open Watcom makefile to build SDL2.dll for OS/2: # wmake -f Makefile.os2 # # If you have GNU libiconv installed (iconv2.dll), you @@ -14,8 +14,8 @@ LIBNAME = SDL2 MAJOR_VERSION = 2 -MINOR_VERSION = 28 -MICRO_VERSION = 2 +MINOR_VERSION = 30 +MICRO_VERSION = 4 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) DESCRIPTION = Simple DirectMedia Layer 2 @@ -56,7 +56,7 @@ CFLAGS_DLL+= -bd # iconv: LIBICONV_LIB=iconv2.lib !ifeq LIBICONV 1 -CFLAGS_DLL+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 +CFLAGS_DLL+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DSDL_USE_LIBICONV LIBS+= $(ICONVLIB) !else LIBS+= libuls.lib libconv.lib @@ -81,7 +81,7 @@ SRCS+= SDL_events.c SDL_quit.c SDL_keyboard.c SDL_mouse.c SDL_windowevents.c & SDL_clipboardevents.c SDL_dropevents.c SDL_displayevents.c SDL_gesture.c & SDL_sensor.c SDL_touch.c SRCS+= SDL_haptic.c SDL_hidapi.c SDL_gamecontroller.c SDL_joystick.c controller_type.c -SRCS+= SDL_render.c yuv_rgb.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c & +SRCS+= SDL_render.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c & SDL_blendline.c SDL_blendpoint.c SDL_drawline.c SDL_drawpoint.c & SDL_render_sw.c SDL_rotate.c SDL_triangle.c SRCS+= SDL_blit.c SDL_blit_0.c SDL_blit_1.c SDL_blit_A.c SDL_blit_auto.c & @@ -94,7 +94,7 @@ SRCS+= SDL_systimer.c SRCS+= SDL_sysloadso.c SRCS+= SDL_sysfilesystem.c SRCS+= SDL_os2joystick.c SDL_syshaptic.c SDL_sysjoystick.c SDL_virtualjoystick.c -SRCS+= SDL_hidapijoystick.c SDL_hidapi_rumble.c SDL_hidapi_combined.c SDL_hidapi_gamecube.c SDL_hidapi_luna.c SDL_hidapi_ps3.c SDL_hidapi_ps4.c SDL_hidapi_ps5.c SDL_hidapi_shield.c SDL_hidapi_stadia.c SDL_hidapi_switch.c SDL_hidapi_wii.c SDL_hidapi_xbox360.c SDL_hidapi_xbox360w.c SDL_hidapi_xboxone.c SDL_hidapi_steam.c +SRCS+= SDL_hidapijoystick.c SDL_hidapi_rumble.c SDL_hidapi_combined.c SDL_hidapi_gamecube.c SDL_hidapi_luna.c SDL_hidapi_ps3.c SDL_hidapi_ps4.c SDL_hidapi_ps5.c SDL_hidapi_shield.c SDL_hidapi_stadia.c SDL_hidapi_switch.c SDL_hidapi_wii.c SDL_hidapi_xbox360.c SDL_hidapi_xbox360w.c SDL_hidapi_xboxone.c SDL_hidapi_steam.c SDL_hidapi_steamdeck.c SDL_steam_virtual_gamepad.c SRCS+= SDL_dummyaudio.c SDL_diskaudio.c SRCS+= SDL_nullvideo.c SDL_nullframebuffer.c SDL_nullevents.c SRCS+= SDL_dummysensor.c @@ -152,6 +152,8 @@ SDL_blendpoint.obj: SDL_blendpoint.c wcc386 $(CFLAGS_DLL) -wcd=200 -fo=$^@ $< SDL_RLEaccel.obj: SDL_RLEaccel.c wcc386 $(CFLAGS_DLL) -wcd=201 -fo=$^@ $< +yuv_rgb_sse.obj: yuv_rgb_sse.c + wcc386 $(CFLAGS_DLL) -wcd=202 -fo=$^@ $< !ifeq HIDAPI 1 # c99 mode needed because of structs with flexible array members in libusb.h SDL_hidapi.obj: SDL_hidapi.c diff --git a/vs/sdl2/Makefile.w32 b/vs/sdl2/Makefile.w32 index 1a8ec5ab5a..aacdd83d63 100644 --- a/vs/sdl2/Makefile.w32 +++ b/vs/sdl2/Makefile.w32 @@ -1,12 +1,12 @@ -# Open Watcom makefile to build SDL2.dll for Win32 +# Open Watcom makefile to build SDL2.dll for Win32: # wmake -f Makefile.w32 # # To error out upon warnings: wmake -f Makefile.w32 ENABLE_WERROR=1 LIBNAME = SDL2 MAJOR_VERSION = 2 -MINOR_VERSION = 28 -MICRO_VERSION = 2 +MINOR_VERSION = 30 +MICRO_VERSION = 4 VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION) LIBHOME = . @@ -60,7 +60,7 @@ SRCS+= SDL_events.c SDL_quit.c SDL_keyboard.c SDL_mouse.c SDL_windowevents.c & SDL_clipboardevents.c SDL_dropevents.c SDL_displayevents.c SDL_gesture.c & SDL_sensor.c SDL_touch.c SRCS+= SDL_haptic.c SDL_hidapi.c SDL_gamecontroller.c SDL_joystick.c controller_type.c -SRCS+= SDL_render.c yuv_rgb.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c & +SRCS+= SDL_render.c yuv_rgb_sse.c yuv_rgb_std.c SDL_yuv.c SDL_yuv_sw.c SDL_blendfillrect.c & SDL_blendline.c SDL_blendpoint.c SDL_drawline.c SDL_drawpoint.c & SDL_render_sw.c SDL_rotate.c SDL_triangle.c SRCS+= SDL_blit.c SDL_blit_0.c SDL_blit_1.c SDL_blit_A.c SDL_blit_auto.c & @@ -73,7 +73,7 @@ SRCS+= SDL_systimer.c SRCS+= SDL_sysloadso.c SRCS+= SDL_sysfilesystem.c SRCS+= SDL_syshaptic.c SDL_sysjoystick.c SDL_virtualjoystick.c -SRCS+= SDL_hidapijoystick.c SDL_hidapi_rumble.c SDL_hidapi_combined.c SDL_hidapi_gamecube.c SDL_hidapi_luna.c SDL_hidapi_ps3.c SDL_hidapi_ps4.c SDL_hidapi_ps5.c SDL_hidapi_shield.c SDL_hidapi_stadia.c SDL_hidapi_switch.c SDL_hidapi_wii.c SDL_hidapi_xbox360.c SDL_hidapi_xbox360w.c SDL_hidapi_xboxone.c SDL_hidapi_steam.c +SRCS+= SDL_hidapijoystick.c SDL_hidapi_rumble.c SDL_hidapi_combined.c SDL_hidapi_gamecube.c SDL_hidapi_luna.c SDL_hidapi_ps3.c SDL_hidapi_ps4.c SDL_hidapi_ps5.c SDL_hidapi_shield.c SDL_hidapi_stadia.c SDL_hidapi_switch.c SDL_hidapi_wii.c SDL_hidapi_xbox360.c SDL_hidapi_xbox360w.c SDL_hidapi_xboxone.c SDL_hidapi_steam.c SDL_hidapi_steamdeck.c SRCS+= SDL_dummyaudio.c SDL_diskaudio.c SRCS+= SDL_nullvideo.c SDL_nullframebuffer.c SDL_nullevents.c SRCS+= SDL_dummysensor.c @@ -93,7 +93,7 @@ SRCS+= SDL_render_gl.c SDL_shaders_gl.c SRCS+= SDL_render_gles2.c SDL_shaders_gles2.c SRCS+= SDL_windowssensor.c SRCS+= SDL_syscond_cv.c -SRCS+= SDL_windowsclipboard.c SDL_windowsevents.c SDL_windowsframebuffer.c SDL_windowskeyboard.c SDL_windowsmessagebox.c SDL_windowsmodes.c SDL_windowsmouse.c SDL_windowsopengl.c SDL_windowsopengles.c SDL_windowsshape.c SDL_windowsvideo.c SDL_windowsvulkan.c SDL_windowswindow.c +SRCS+= SDL_windowsclipboard.c SDL_windowsevents.c SDL_windowsframebuffer.c SDL_windowskeyboard.c SDL_windowsmessagebox.c SDL_windowsmodes.c SDL_windowsmouse.c SDL_windowsopengl.c SDL_windowsopengles.c SDL_windowsshape.c SDL_windowsvideo.c SDL_windowsvulkan.c SDL_windowswindow.c SDL_steam_virtual_gamepad.c SRCS+= SDL_dynapi.c @@ -147,6 +147,9 @@ SDL_RLEaccel.obj: SDL_RLEaccel.c SDL_malloc.obj: SDL_malloc.c wcc386 $(CFLAGS_DLL) -wcd=201 -fo=$^@ $< +yuv_rgb_sse.obj: yuv_rgb_sse.c + wcc386 $(CFLAGS_DLL) -wcd=202 -fo=$^@ $< + # SDL2libm MSRCS= e_atan2.c e_exp.c e_fmod.c e_log10.c e_log.c e_pow.c e_rem_pio2.c e_sqrt.c & k_cos.c k_rem_pio2.c k_sin.c k_tan.c & diff --git a/vs/sdl2/README.md b/vs/sdl2/README.md index d1719bb6fe..fa7f7ba0b5 100644 --- a/vs/sdl2/README.md +++ b/vs/sdl2/README.md @@ -1,17 +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) + +# 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/vs/sdl2/VisualC-WinRT/SDL-UWP.sln b/vs/sdl2/VisualC-WinRT/SDL-UWP.sln index 21be875455..472c4f01b7 100644 --- a/vs/sdl2/VisualC-WinRT/SDL-UWP.sln +++ b/vs/sdl2/VisualC-WinRT/SDL-UWP.sln @@ -1,40 +1,40 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.ActiveCfg = Debug|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.Build.0 = Debug|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.ActiveCfg = Debug|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.Build.0 = Debug|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.ActiveCfg = Debug|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.Build.0 = Debug|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.ActiveCfg = Debug|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.Build.0 = Debug|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.ActiveCfg = Release|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.Build.0 = Release|ARM - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.ActiveCfg = Release|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.Build.0 = Release|ARM64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.ActiveCfg = Release|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32 - {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL2-UWP", "SDL-UWP.vcxproj", "{89E9B32E-A86A-47C3-A948-D2B1622925CE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|ARM = Debug|ARM + Debug|ARM64 = Debug|ARM64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|ARM = Release|ARM + Release|ARM64 = Release|ARM64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.ActiveCfg = Debug|ARM + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM.Build.0 = Debug|ARM + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|ARM64.Build.0 = Debug|ARM64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.ActiveCfg = Debug|x64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x64.Build.0 = Debug|x64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.ActiveCfg = Debug|Win32 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Debug|x86.Build.0 = Debug|Win32 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.ActiveCfg = Release|ARM + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM.Build.0 = Release|ARM + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.ActiveCfg = Release|ARM64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|ARM64.Build.0 = Release|ARM64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.ActiveCfg = Release|x64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x64.Build.0 = Release|x64 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.ActiveCfg = Release|Win32 + {89E9B32E-A86A-47C3-A948-D2B1622925CE}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj b/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj index 73c7d5c084..696505f351 100644 --- a/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj +++ b/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj @@ -1,594 +1,606 @@ - - - - - Debug - ARM64 - - - Debug - ARM - - - Debug - Win32 - - - Debug - x64 - - - Release - ARM - - - Release - ARM64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - - - true - - - true - - - true - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - true - - - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - true - - - - - {89e9b32e-a86a-47c3-a948-d2b1622925ce} - DynamicLibrary - SDL2-UWP - SDL2 - en-US - 14.0 - true - Windows Store - 8.2 - 10.0.16299.0 - 10.0.16299.0 - 10.0 - - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - DynamicLibrary - false - true - v142 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - false - false - SDL2 - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) - - - - - NotUsing - false - ..\include;%(AdditionalIncludeDirectories) - DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) - - - Console - false - false - /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) - - - - - - + + + + + Debug + ARM64 + + + Debug + ARM + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + true + + + true + + + true + + + + + + + + + + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + + + + + {89e9b32e-a86a-47c3-a948-d2b1622925ce} + DynamicLibrary + SDL2-UWP + SDL2 + en-US + 14.0 + true + Windows Store + 8.2 + 10.0.16299.0 + 10.0.16299.0 + 10.0 + + + + DynamicLibrary + true + v142 + + + DynamicLibrary + true + v142 + + + DynamicLibrary + true + v142 + + + DynamicLibrary + true + v142 + + + DynamicLibrary + false + true + v142 + + + DynamicLibrary + false + true + v142 + + + DynamicLibrary + false + true + v142 + + + DynamicLibrary + false + true + v142 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + false + false + SDL2 + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib %(AdditionalOptions) + + + + + NotUsing + false + ..\include;%(AdditionalIncludeDirectories) + DLL_EXPORT;_CRT_SECURE_NO_WARNINGS;SDL_BUILDING_WINRT=1;%(PreprocessorDefinitions) + + + Console + false + false + /nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib %(AdditionalOptions) + + + + + + diff --git a/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj.filters b/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj.filters index e1dc73de96..0045d54760 100644 --- a/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj.filters +++ b/vs/sdl2/VisualC-WinRT/SDL-UWP.vcxproj.filters @@ -1,849 +1,855 @@ - - - - - {fa0ff2df-c3d6-498a-96f1-1f88e7ce0da3} - - - {68e1b30b-19ed-4612-93e4-6260c5a979e5} - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Header Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Source Files - - - Source Files - - - Source Files - - - \ No newline at end of file + + + + + {fa0ff2df-c3d6-498a-96f1-1f88e7ce0da3} + + + {68e1b30b-19ed-4612-93e4-6260c5a979e5} + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Header Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Header Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/vs/sdl2/VisualC/SDL/SDL.vcxproj.filters b/vs/sdl2/VisualC/SDL/SDL.vcxproj.filters index da002cd3c8..60899f55c4 100644 --- a/vs/sdl2/VisualC/SDL/SDL.vcxproj.filters +++ b/vs/sdl2/VisualC/SDL/SDL.vcxproj.filters @@ -169,6 +169,9 @@ {4755f3a6-49ac-46d6-86be-21f5c21f2197} + + {f48c2b17-1bee-4fec-a7c8-24cf619abe08} + @@ -231,6 +234,9 @@ API Headers + + API Headers + API Headers @@ -401,6 +407,7 @@ + API Headers @@ -425,6 +432,9 @@ core\windows + + core\windows + core\windows @@ -464,9 +474,6 @@ events - - events - events @@ -488,15 +495,15 @@ haptic - - hidapi - joystick joystick + + joystick + joystick @@ -668,9 +675,6 @@ video\windows - - video\windows - timer @@ -776,9 +780,6 @@ video\khronos\vulkan - - video\khronos\vulkan - video\khronos\vulkan @@ -824,6 +825,11 @@ + + + render\direct3d12 + + @@ -831,7 +837,10 @@ + + + audio @@ -859,6 +868,9 @@ core\windows + + core\windows + core\windows @@ -913,12 +925,18 @@ hidapi + + joystick + joystick joystick + + joystick + libm @@ -1027,7 +1045,7 @@ joystick\dummy - + joystick\hidapi @@ -1036,6 +1054,9 @@ joystick\hidapi + + joystick\hidapi + joystick\hidapi @@ -1045,18 +1066,33 @@ joystick\hidapi + + joystick\hidapi + joystick\hidapi + + joystick\hidapi + + + joystick\hidapi + joystick\hidapi + + joystick\hidapi + joystick\hidapi joystick\hidapi + + joystick\hidapi + joystick\hidapi @@ -1201,7 +1237,7 @@ thread - + thread\windows @@ -1219,6 +1255,9 @@ thread\generic + + stdlib + stdlib @@ -1316,6 +1355,13 @@ power\windows + + render\direct3d12 + + + render\direct3d12 + + diff --git a/vs/sdl2/VisualC/pkg-support/cmake/sdl2-config.cmake b/vs/sdl2/VisualC/pkg-support/cmake/sdl2-config.cmake index 0f03a6305c..e54f470008 100644 --- a/vs/sdl2/VisualC/pkg-support/cmake/sdl2-config.cmake +++ b/vs/sdl2/VisualC/pkg-support/cmake/sdl2-config.cmake @@ -1,7 +1,7 @@ # SDL2 CMake configuration file: # This file is meant to be placed in a cmake subfolder of SDL2-devel-2.x.y-VC -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.0...3.5) include(FeatureSummary) set_package_properties(SDL2 PROPERTIES diff --git a/vs/sdl2/VisualC/tests/testautomation/testautomation.vcxproj b/vs/sdl2/VisualC/tests/testautomation/testautomation.vcxproj index d58dc0b326..b781dcac91 100644 --- a/vs/sdl2/VisualC/tests/testautomation/testautomation.vcxproj +++ b/vs/sdl2/VisualC/tests/testautomation/testautomation.vcxproj @@ -210,6 +210,7 @@ + @@ -224,6 +225,7 @@ + @@ -231,4 +233,4 @@ - + \ No newline at end of file diff --git a/vs/sdl2/VisualC/tests/testsensor/testsensor.vcxproj b/vs/sdl2/VisualC/tests/testsensor/testsensor.vcxproj index 71360e9932..5afff777b7 100644 --- a/vs/sdl2/VisualC/tests/testsensor/testsensor.vcxproj +++ b/vs/sdl2/VisualC/tests/testsensor/testsensor.vcxproj @@ -1,204 +1,204 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A4} - testsensor - 10.0 - - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Debug/testsensor.tlb - - - Disabled - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Windows - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\Debug/testsensor.tlb - - - Disabled - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Windows - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Release/testsensor.tlb - - - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - Windows - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\Release/testsensor.tlb - - - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - Windows - - - - - {81ce8daf-ebb2-4761-8e45-b71abcca8c68} - false - false - true - - - {da956fd3-e142-46f2-9dd5-c78bebb56b7a} - false - false - true - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A4} + testsensor + 10.0 + + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/testsensor.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Debug/testsensor.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/testsensor.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Release/testsensor.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + false + false + true + + + {da956fd3-e142-46f2-9dd5-c78bebb56b7a} + false + false + true + + + + + + + + + diff --git a/vs/sdl2/VisualC/tests/testwm2/testwm2.vcxproj b/vs/sdl2/VisualC/tests/testwm2/testwm2.vcxproj index aa63b05811..81d090241a 100644 --- a/vs/sdl2/VisualC/tests/testwm2/testwm2.vcxproj +++ b/vs/sdl2/VisualC/tests/testwm2/testwm2.vcxproj @@ -1,210 +1,210 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A5} - testwm2 - 10.0 - - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - Application - $(DefaultPlatformToolset) - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.40219.1 - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - $(SolutionDir)$(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - AllRules.ruleset - - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Debug/testwm2.tlb - - - Disabled - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Windows - - - - - _DEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\Debug/testwm2.tlb - - - Disabled - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDebugDLL - Level3 - OldStyle - - - _DEBUG;%(PreprocessorDefinitions) - 0x0409 - - - true - Windows - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - Win32 - .\Release/testwm2.tlb - - - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - Windows - - - - - NDEBUG;%(PreprocessorDefinitions) - true - true - X64 - .\Release/testwm2.tlb - - - $(SolutionDir)/../include;%(AdditionalIncludeDirectories) - %(AdditionalUsingDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) - MultiThreadedDLL - Level3 - - - NDEBUG;%(PreprocessorDefinitions) - 0x0409 - - - Windows - - - - - {81ce8daf-ebb2-4761-8e45-b71abcca8c68} - false - false - true - - - {da956fd3-e142-46f2-9dd5-c78bebb56b7a} - false - false - true - - - {da956fd3-e143-46f2-9fe5-c77bebc56b1a} - false - false - true - - - - - - - - - + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {C4E04D18-EF76-4B42-B4C2-16A1BACDC0A5} + testwm2 + 10.0 + + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + Application + $(DefaultPlatformToolset) + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + $(SolutionDir)$(Platform)\$(Configuration)\ + $(Platform)\$(Configuration)\ + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + AllRules.ruleset + + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Debug/testwm2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + + + + _DEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Debug/testwm2.tlb + + + Disabled + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDebugDLL + Level3 + OldStyle + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + + + true + Windows + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + Win32 + .\Release/testwm2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + + + + + NDEBUG;%(PreprocessorDefinitions) + true + true + X64 + .\Release/testwm2.tlb + + + $(SolutionDir)/../include;%(AdditionalIncludeDirectories) + %(AdditionalUsingDirectories) + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + + + Windows + + + + + {81ce8daf-ebb2-4761-8e45-b71abcca8c68} + false + false + true + + + {da956fd3-e142-46f2-9dd5-c78bebb56b7a} + false + false + true + + + {da956fd3-e143-46f2-9fe5-c77bebc56b1a} + false + false + true + + + + + + + + + diff --git a/vs/sdl2/WhatsNew.txt b/vs/sdl2/WhatsNew.txt index 1d7c27e20a..90d94243db 100644 --- a/vs/sdl2/WhatsNew.txt +++ b/vs/sdl2/WhatsNew.txt @@ -1,9 +1,28 @@ This is a list of major changes in SDL's version history. +--------------------------------------------------------------------------- +2.30.0: +--------------------------------------------------------------------------- + +General: +* Added support for 2 bits-per-pixel indexed surface formats +* Added the function SDL_GameControllerGetSteamHandle() to get the Steam API handle for a controller, if available +* Added the event SDL_CONTROLLERSTEAMHANDLEUPDATED which is sent when the Steam API handle for a controller changes. This could also change the name, VID, and PID of the controller. +* Added the environment variable SDL_LOGGING to control default log output + +macOS: +* Added the hint SDL_HINT_JOYSTICK_IOKIT to control whether the IOKit controller driver should be used +* Added the hint SDL_HINT_JOYSTICK_MFI to control whether the GCController controller driver should be used +* Added the hint SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE to choose whether high or low power GPU should be used for rendering, in the case where there are multiple GPUs available + +Xbox: +* Added the function SDL_GDKGetDefaultUser() + --------------------------------------------------------------------------- 2.28.2: --------------------------------------------------------------------------- + General: * Added the hint SDL_HINT_JOYSTICK_WGI to control whether to use Windows.Gaming.Input for controllers diff --git a/vs/sdl2/Xcode-iOS/Demos/src/accelerometer.c b/vs/sdl2/Xcode-iOS/Demos/src/accelerometer.c index 3ce8125134..4c166a621c 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/accelerometer.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/accelerometer.c @@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer) /* load the ship */ bmp_surface = SDL_LoadBMP("ship.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not ship.bmp"); } /* set blue to transparent on the ship */ @@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer) /* create ship texture from surface */ ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (ship == NULL) { + if (!ship) { fatalError("could not create ship texture"); } SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); @@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer) /* load the space background */ bmp_surface = SDL_LoadBMP("space.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load space.bmp"); } /* create space texture from surface */ space = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (space == NULL) { + if (!space) { fatalError("could not create space texture"); } SDL_FreeSurface(bmp_surface); @@ -179,7 +179,7 @@ main(int argc, char *argv[]) printf("There are %d joysticks available\n", SDL_NumJoysticks()); printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0)); accelerometer = SDL_JoystickOpen(0); - if (accelerometer == NULL) { + if (!accelerometer) { fatalError("Could not open joystick (accelerometer)"); } printf("joystick number of axis = %d\n", diff --git a/vs/sdl2/Xcode-iOS/Demos/src/fireworks.c b/vs/sdl2/Xcode-iOS/Demos/src/fireworks.c index eb3bb4cdee..a9af3fb583 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/fireworks.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/fireworks.c @@ -334,7 +334,7 @@ initializeTexture() to format passed into OpenGL */ bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } diff --git a/vs/sdl2/Xcode-iOS/Demos/src/happy.c b/vs/sdl2/Xcode-iOS/Demos/src/happy.c index 42562007e1..163d3463f5 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/happy.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/happy.c @@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer) SDL_Surface *bmp_surface; /* load the bmp */ bmp_surface = SDL_LoadBMP("icon.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load bmp"); } /* set white to transparent on the happyface */ @@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer) /* convert RGBA surface to texture */ texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (texture == NULL) { + if (!texture) { fatalError("could not create texture"); } SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); diff --git a/vs/sdl2/Xcode-iOS/Demos/src/keyboard.c b/vs/sdl2/Xcode-iOS/Demos/src/keyboard.c index 6ab1db213a..4d630bae5f 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/keyboard.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/keyboard.c @@ -165,7 +165,7 @@ loadFont(void) { SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp"); - if (surface == NULL) { + if (!surface) { printf("Error loading bitmap: %s\n", SDL_GetError()); return 0; } else { @@ -183,7 +183,7 @@ loadFont(void) SDL_BlitSurface(surface, NULL, converted, NULL); /* create our texture */ texture = SDL_CreateTextureFromSurface(renderer, converted); - if (texture == NULL) { + if (!texture) { printf("texture creation failed: %s\n", SDL_GetError()); } else { /* set blend mode for our texture */ diff --git a/vs/sdl2/Xcode-iOS/Demos/src/rectangles.c b/vs/sdl2/Xcode-iOS/Demos/src/rectangles.c index 9102cf2795..a08f997906 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/rectangles.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/rectangles.c @@ -58,11 +58,11 @@ main(int argc, char *argv[]) /* create window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI); - if (window == NULL) { + if (!window) { fatalError("Could not initialize Window"); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { fatalError("Could not create renderer"); } diff --git a/vs/sdl2/Xcode-iOS/Demos/src/touch.c b/vs/sdl2/Xcode-iOS/Demos/src/touch.c index 22a251be14..4b7ff95484 100644 --- a/vs/sdl2/Xcode-iOS/Demos/src/touch.c +++ b/vs/sdl2/Xcode-iOS/Demos/src/touch.c @@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer) { SDL_Surface *bmp_surface; bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } brush = SDL_CreateTextureFromSurface(renderer, bmp_surface); SDL_FreeSurface(bmp_surface); - if (brush == NULL) { + if (!brush) { fatalError("could not create brush texture"); } /* additive blending -- laying strokes on top of eachother makes them brighter */ diff --git a/vs/sdl2/Xcode/SDL/Info-Framework.plist b/vs/sdl2/Xcode/SDL/Info-Framework.plist index b6ba3556b5..fc1167f1a3 100644 --- a/vs/sdl2/Xcode/SDL/Info-Framework.plist +++ b/vs/sdl2/Xcode/SDL/Info-Framework.plist @@ -19,10 +19,10 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 2.28.2 + 2.30.4 CFBundleSignature SDLX CFBundleVersion - 2.28.2 + 2.30.4 diff --git a/vs/sdl2/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/vs/sdl2/Xcode/SDL/SDL.xcodeproj/project.pbxproj index 44854e87d3..d260331509 100644 --- a/vs/sdl2/Xcode/SDL/SDL.xcodeproj/project.pbxproj +++ b/vs/sdl2/Xcode/SDL/SDL.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -160,7 +160,6 @@ A75FCD1023E25AB700529352 /* SDL_uikitview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A61923E2513D00DCD162 /* SDL_uikitview.h */; }; A75FCD1123E25AB700529352 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCD1223E25AB700529352 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; - A75FCD1323E25AB700529352 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A75FCD1423E25AB700529352 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCD1523E25AB700529352 /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A92E23E2514000DCD162 /* SDL_dropevents_c.h */; }; A75FCD1623E25AB700529352 /* SDL_haptic_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A5C623E2513D00DCD162 /* SDL_haptic_c.h */; }; @@ -207,7 +206,6 @@ A75FCD4823E25AB700529352 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCD4A23E25AB700529352 /* SDL_cocoakeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68023E2513E00DCD162 /* SDL_cocoakeyboard.h */; }; A75FCD4B23E25AB700529352 /* SDL_uikitvulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A63323E2513D00DCD162 /* SDL_uikitvulkan.h */; }; - A75FCD4E23E25AB700529352 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; A75FCD4F23E25AB700529352 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCD5023E25AB700529352 /* gl2ext.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72323E2513E00DCD162 /* gl2ext.h */; }; A75FCD5123E25AB700529352 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93923E2514000DCD162 /* SDL_clipboardevents_c.h */; }; @@ -283,7 +281,6 @@ A75FCDA123E25AB700529352 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; A75FCDA223E25AB700529352 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A75FCDA323E25AB700529352 /* vulkan_vi.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72F23E2513E00DCD162 /* vulkan_vi.h */; }; - A75FCDA423E25AB700529352 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; A75FCDA523E25AB700529352 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCDA623E25AB700529352 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93323E2514000DCD162 /* default_cursor.h */; }; A75FCDA723E25AB700529352 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8F523E2514000DCD162 /* SDL_render_sw_c.h */; }; @@ -371,7 +368,6 @@ 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 */; }; - A75FCE0523E25AB700529352 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; A75FCE0623E25AB700529352 /* SDL_render_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A90123E2514000DCD162 /* SDL_render_gles.c */; }; A75FCE0723E25AB700529352 /* SDL_systhread.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A78623E2513E00DCD162 /* SDL_systhread.c */; }; A75FCE0823E25AB700529352 /* SDL_windowevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92F23E2514000DCD162 /* SDL_windowevents.c */; }; @@ -536,7 +532,6 @@ A75FCEC923E25AC700529352 /* SDL_uikitview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A61923E2513D00DCD162 /* SDL_uikitview.h */; }; A75FCECA23E25AC700529352 /* SDL_bits.h in Headers */ = {isa = PBXBuildFile; fileRef = AADA5B8616CCAB3000107CF7 /* SDL_bits.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCECB23E25AC700529352 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; - A75FCECC23E25AC700529352 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A75FCECD23E25AC700529352 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557CC1595D4D800BBD41B /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCECE23E25AC700529352 /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A92E23E2514000DCD162 /* SDL_dropevents_c.h */; }; A75FCECF23E25AC700529352 /* SDL_haptic_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A5C623E2513D00DCD162 /* SDL_haptic_c.h */; }; @@ -583,7 +578,6 @@ A75FCF0123E25AC700529352 /* SDL_keycode.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DB1595D4D800BBD41B /* SDL_keycode.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCF0323E25AC700529352 /* SDL_cocoakeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68023E2513E00DCD162 /* SDL_cocoakeyboard.h */; }; A75FCF0423E25AC700529352 /* SDL_uikitvulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A63323E2513D00DCD162 /* SDL_uikitvulkan.h */; }; - A75FCF0723E25AC700529352 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; A75FCF0823E25AC700529352 /* SDL_loadso.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557DC1595D4D800BBD41B /* SDL_loadso.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCF0923E25AC700529352 /* gl2ext.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72323E2513E00DCD162 /* gl2ext.h */; }; A75FCF0A23E25AC700529352 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93923E2514000DCD162 /* SDL_clipboardevents_c.h */; }; @@ -659,7 +653,6 @@ A75FCF5A23E25AC700529352 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; A75FCF5B23E25AC700529352 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A75FCF5C23E25AC700529352 /* vulkan_vi.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72F23E2513E00DCD162 /* vulkan_vi.h */; }; - A75FCF5D23E25AC700529352 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; A75FCF5E23E25AC700529352 /* SDL_quit.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557E81595D4D800BBD41B /* SDL_quit.h */; settings = {ATTRIBUTES = (Public, ); }; }; A75FCF5F23E25AC700529352 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93323E2514000DCD162 /* default_cursor.h */; }; A75FCF6023E25AC700529352 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8F523E2514000DCD162 /* SDL_render_sw_c.h */; }; @@ -747,7 +740,6 @@ 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 */; }; - A75FCFBE23E25AC700529352 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; A75FCFBF23E25AC700529352 /* SDL_render_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A90123E2514000DCD162 /* SDL_render_gles.c */; }; A75FCFC023E25AC700529352 /* SDL_systhread.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A78623E2513E00DCD162 /* SDL_systhread.c */; }; A75FCFC123E25AC700529352 /* SDL_windowevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92F23E2514000DCD162 /* SDL_windowevents.c */; }; @@ -947,7 +939,6 @@ A769B09623E259AE00872273 /* SDL_coremotionsensor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A57B23E2513D00DCD162 /* SDL_coremotionsensor.h */; }; A769B09723E259AE00872273 /* SDL_uikitview.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A61923E2513D00DCD162 /* SDL_uikitview.h */; }; A769B09923E259AE00872273 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; - A769B09A23E259AE00872273 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A769B09C23E259AE00872273 /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A92E23E2514000DCD162 /* SDL_dropevents_c.h */; }; A769B09D23E259AE00872273 /* SDL_haptic_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A5C623E2513D00DCD162 /* SDL_haptic_c.h */; }; A769B09F23E259AE00872273 /* SDL_dataqueue.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A57023E2513D00DCD162 /* SDL_dataqueue.h */; }; @@ -979,7 +970,6 @@ A769B0CD23E259AE00872273 /* SDL_systhread_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A78423E2513E00DCD162 /* SDL_systhread_c.h */; }; A769B0D023E259AE00872273 /* SDL_cocoakeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A68023E2513E00DCD162 /* SDL_cocoakeyboard.h */; }; A769B0D123E259AE00872273 /* SDL_uikitvulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A63323E2513D00DCD162 /* SDL_uikitvulkan.h */; }; - A769B0D423E259AE00872273 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; A769B0D623E259AE00872273 /* gl2ext.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72323E2513E00DCD162 /* gl2ext.h */; }; A769B0D723E259AE00872273 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93923E2514000DCD162 /* SDL_clipboardevents_c.h */; }; A769B0D923E259AE00872273 /* SDL_syshaptic_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A5CF23E2513D00DCD162 /* SDL_syshaptic_c.h */; }; @@ -1041,7 +1031,6 @@ A769B12923E259AE00872273 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; A769B12A23E259AE00872273 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A769B12B23E259AE00872273 /* vulkan_vi.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A72F23E2513E00DCD162 /* vulkan_vi.h */; }; - A769B12C23E259AE00872273 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; A769B12E23E259AE00872273 /* default_cursor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A93323E2514000DCD162 /* default_cursor.h */; }; A769B12F23E259AE00872273 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A8F523E2514000DCD162 /* SDL_render_sw_c.h */; }; A769B13223E259AE00872273 /* SDL_nullvideo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A60A23E2513D00DCD162 /* SDL_nullvideo.h */; }; @@ -1107,7 +1096,6 @@ 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 */; }; - A769B18E23E259AE00872273 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; A769B18F23E259AE00872273 /* SDL_render_gles.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A90123E2514000DCD162 /* SDL_render_gles.c */; }; A769B19023E259AE00872273 /* SDL_systhread.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A78623E2513E00DCD162 /* SDL_systhread.c */; }; A769B19123E259AE00872273 /* SDL_windowevents.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A92F23E2514000DCD162 /* SDL_windowevents.c */; }; @@ -1760,10 +1748,6 @@ A7D8AC9B23E2514100DCD162 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A7D8AC9D23E2514100DCD162 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A7D8AC9E23E2514100DCD162 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; - A7D8ACA023E2514100DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; - A7D8ACA123E2514100DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; - A7D8ACA323E2514100DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; - A7D8ACA423E2514100DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A7D8ACA623E2514100DCD162 /* SDL_uikitview.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A62923E2513D00DCD162 /* SDL_uikitview.m */; }; A7D8ACA723E2514100DCD162 /* SDL_uikitview.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A62923E2513D00DCD162 /* SDL_uikitview.m */; }; A7D8ACA923E2514100DCD162 /* SDL_uikitview.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A62923E2513D00DCD162 /* SDL_uikitview.m */; }; @@ -2120,12 +2104,6 @@ A7D8B26923E2514200DCD162 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; A7D8B26A23E2514200DCD162 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; A7D8B26B23E2514200DCD162 /* vk_platform.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73123E2513E00DCD162 /* vk_platform.h */; }; - A7D8B26C23E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; - A7D8B26D23E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; - A7D8B26E23E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; - A7D8B26F23E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; - A7D8B27023E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; - A7D8B27123E2514200DCD162 /* vulkan.hpp in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73223E2513E00DCD162 /* vulkan.hpp */; }; A7D8B27223E2514200DCD162 /* vulkan_fuchsia.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73323E2513E00DCD162 /* vulkan_fuchsia.h */; }; A7D8B27323E2514200DCD162 /* vulkan_fuchsia.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73323E2513E00DCD162 /* vulkan_fuchsia.h */; }; A7D8B27423E2514200DCD162 /* vulkan_fuchsia.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73323E2513E00DCD162 /* vulkan_fuchsia.h */; }; @@ -2162,12 +2140,6 @@ A7D8B29323E2514200DCD162 /* vulkan_xcb.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73823E2513E00DCD162 /* vulkan_xcb.h */; }; A7D8B29423E2514200DCD162 /* vulkan_xcb.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73823E2513E00DCD162 /* vulkan_xcb.h */; }; A7D8B29523E2514200DCD162 /* vulkan_xcb.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73823E2513E00DCD162 /* vulkan_xcb.h */; }; - A7D8B29623E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; - A7D8B29723E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; - A7D8B29823E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; - A7D8B29923E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; - A7D8B29A23E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; - A7D8B29B23E2514200DCD162 /* vulkan_mir.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73923E2513E00DCD162 /* vulkan_mir.h */; }; A7D8B29C23E2514200DCD162 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; A7D8B29D23E2514200DCD162 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; A7D8B29E23E2514200DCD162 /* vulkan_xlib.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */; }; @@ -2246,12 +2218,6 @@ A7D8B3B923E2514200DCD162 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76B23E2513E00DCD162 /* SDL_blit.h */; }; A7D8B3BA23E2514200DCD162 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76B23E2513E00DCD162 /* SDL_blit.h */; }; A7D8B3BB23E2514200DCD162 /* SDL_blit.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A76B23E2513E00DCD162 /* SDL_blit.h */; }; - A7D8B3BF23E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; - A7D8B3C023E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; - A7D8B3C123E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; - A7D8B3C223E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; - A7D8B3C323E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; - A7D8B3C423E2514200DCD162 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */; }; A7D8B3C823E2514200DCD162 /* yuv_rgb_sse_func.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A77023E2513E00DCD162 /* yuv_rgb_sse_func.h */; }; A7D8B3C923E2514300DCD162 /* yuv_rgb_sse_func.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A77023E2513E00DCD162 /* yuv_rgb_sse_func.h */; }; A7D8B3CA23E2514300DCD162 /* yuv_rgb_sse_func.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A77023E2513E00DCD162 /* yuv_rgb_sse_func.h */; }; @@ -3188,7 +3154,6 @@ A7D8BBC723E2561500DCD162 /* SDL_steamcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */; }; A7D8BBCB23E2561600DCD162 /* SDL_steamcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */; }; A7D8BBCF23E2561600DCD162 /* SDL_steamcontroller.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A7A523E2513E00DCD162 /* SDL_steamcontroller.h */; }; - A7D8BBD123E2574800DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A7D8BBD223E2574800DCD162 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; A7D8BBD323E2574800DCD162 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61E23E2513D00DCD162 /* SDL_uikitappdelegate.m */; }; A7D8BBD423E2574800DCD162 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62123E2513D00DCD162 /* SDL_uikitclipboard.h */; }; @@ -3215,7 +3180,6 @@ A7D8BBE923E2574800DCD162 /* SDL_uikitvulkan.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A62523E2513D00DCD162 /* SDL_uikitvulkan.m */; }; A7D8BBEA23E2574800DCD162 /* SDL_uikitwindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */; }; A7D8BBEB23E2574800DCD162 /* SDL_uikitwindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61A23E2513D00DCD162 /* SDL_uikitwindow.m */; }; - A7D8BBEC23E2574800DCD162 /* keyinfotable.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62823E2513D00DCD162 /* keyinfotable.h */; }; A7D8BBED23E2574800DCD162 /* SDL_uikitappdelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */; }; A7D8BBEE23E2574800DCD162 /* SDL_uikitappdelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A7D8A61E23E2513D00DCD162 /* SDL_uikitappdelegate.m */; }; A7D8BBEF23E2574800DCD162 /* SDL_uikitclipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D8A62123E2513D00DCD162 /* SDL_uikitclipboard.h */; }; @@ -3364,6 +3328,87 @@ DB31407017554B71006C0E22 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0073179F0858DECD00B2BC32 /* IOKit.framework */; }; DB31407217554B71006C0E22 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 007317C10858E15000B2BC32 /* Carbon.framework */; }; DB31408D17554D3C006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; }; + F316AB852B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB862B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB872B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB882B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB892B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB8A2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB8B2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB8C2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB8D2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */; }; + F316AB8E2B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB8F2B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB902B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB912B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB922B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB932B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB942B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB952B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB962B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */; }; + F316AB972B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB982B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB992B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9A2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9B2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9C2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9D2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9E2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316AB9F2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */; }; + F316ABA02B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA12B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA22B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA32B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA42B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA52B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA62B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA72B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA82B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */; }; + F316ABA92B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAA2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAB2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAC2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAD2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAE2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABAF2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABB02B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABB12B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */; }; + F316ABB22B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB32B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB42B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB52B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB62B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB72B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB82B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABB92B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABBA2B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */ = {isa = PBXBuildFile; fileRef = F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */; }; + F316ABBB2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABBC2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABBD2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABBE2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABBF2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABC02B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABC12B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABC22B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABC32B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */; }; + F316ABC42B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABC52B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABC62B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABC72B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABC82B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABC92B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABCA2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABCB2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABCC2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */; }; + F316ABCD2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABCE2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABCF2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD02B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD12B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD22B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD32B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD42B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; + F316ABD52B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */ = {isa = PBXBuildFile; fileRef = F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */; }; F31A92C828D4CB39003BFD6A /* SDL_offscreenopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = F31A92C628D4CB39003BFD6A /* SDL_offscreenopengles.h */; }; F31A92C928D4CB39003BFD6A /* SDL_offscreenopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = F31A92C628D4CB39003BFD6A /* SDL_offscreenopengles.h */; }; F31A92CA28D4CB39003BFD6A /* SDL_offscreenopengles.h in Headers */ = {isa = PBXBuildFile; fileRef = F31A92C628D4CB39003BFD6A /* SDL_offscreenopengles.h */; }; @@ -3396,6 +3441,51 @@ F34B9895291DEFF500AAC96E /* SDL_hidapi_steam.c in Sources */ = {isa = PBXBuildFile; fileRef = A75FDAAC23E2795C00529352 /* SDL_hidapi_steam.c */; }; F34B9896291DEFF700AAC96E /* SDL_hidapi_steam.c in Sources */ = {isa = PBXBuildFile; fileRef = A75FDAAC23E2795C00529352 /* SDL_hidapi_steam.c */; }; F34B9897291DEFFA00AAC96E /* SDL_hidapi_steam.c in Sources */ = {isa = PBXBuildFile; fileRef = A75FDAAC23E2795C00529352 /* SDL_hidapi_steam.c */; }; + F362B9322B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9332B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9342B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9352B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9362B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9372B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9382B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B9392B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B93A2B33916600D30B94 /* controller_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B91F2B33916600D30B94 /* controller_list.h */; }; + F362B93D2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B93E2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B93F2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9402B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9412B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9422B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9432B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9442B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9452B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */; }; + F362B9462B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B9472B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B9482B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B9492B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B94A2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B94B2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B94C2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B94D2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B94E2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */; }; + F362B9522B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9532B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9542B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9552B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9562B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9572B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9582B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B9592B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B95A2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */; }; + F362B95B2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B95C2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B95D2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B95E2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B95F2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B9602B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B9612B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B9622B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; + F362B9632B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */ = {isa = PBXBuildFile; fileRef = F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */; }; 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 */; platformFilter = ios; }; @@ -3797,7 +3887,6 @@ A7D8A62523E2513D00DCD162 /* SDL_uikitvulkan.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitvulkan.m; sourceTree = ""; }; A7D8A62623E2513D00DCD162 /* SDL_uikitmessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmessagebox.h; sourceTree = ""; }; A7D8A62723E2513D00DCD162 /* SDL_uikitwindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitwindow.h; sourceTree = ""; }; - A7D8A62823E2513D00DCD162 /* keyinfotable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = keyinfotable.h; sourceTree = ""; }; A7D8A62923E2513D00DCD162 /* SDL_uikitview.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitview.m; sourceTree = ""; }; A7D8A62A23E2513D00DCD162 /* SDL_uikitclipboard.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitclipboard.m; sourceTree = ""; }; A7D8A62B23E2513D00DCD162 /* SDL_uikitopenglview.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitopenglview.h; sourceTree = ""; }; @@ -3861,14 +3950,12 @@ A7D8A72F23E2513E00DCD162 /* vulkan_vi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_vi.h; sourceTree = ""; }; A7D8A73023E2513E00DCD162 /* vulkan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan.h; sourceTree = ""; }; A7D8A73123E2513E00DCD162 /* vk_platform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vk_platform.h; sourceTree = ""; }; - A7D8A73223E2513E00DCD162 /* vulkan.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = vulkan.hpp; sourceTree = ""; }; A7D8A73323E2513E00DCD162 /* vulkan_fuchsia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_fuchsia.h; sourceTree = ""; }; A7D8A73423E2513E00DCD162 /* vulkan_wayland.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_wayland.h; sourceTree = ""; }; A7D8A73523E2513E00DCD162 /* vulkan_win32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_win32.h; sourceTree = ""; }; A7D8A73623E2513E00DCD162 /* vulkan_macos.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_macos.h; sourceTree = ""; }; A7D8A73723E2513E00DCD162 /* vulkan_xlib_xrandr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_xlib_xrandr.h; sourceTree = ""; }; A7D8A73823E2513E00DCD162 /* vulkan_xcb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_xcb.h; sourceTree = ""; }; - A7D8A73923E2513E00DCD162 /* vulkan_mir.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_mir.h; sourceTree = ""; }; A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_xlib.h; sourceTree = ""; }; A7D8A73B23E2513E00DCD162 /* vulkan_ios.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_ios.h; sourceTree = ""; }; A7D8A73C23E2513E00DCD162 /* vulkan_core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vulkan_core.h; sourceTree = ""; }; @@ -3882,7 +3969,6 @@ A7D8A76923E2513E00DCD162 /* SDL_shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shape.c; sourceTree = ""; }; A7D8A76A23E2513E00DCD162 /* SDL_yuv_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_c.h; sourceTree = ""; }; A7D8A76B23E2513E00DCD162 /* SDL_blit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_blit.h; sourceTree = ""; }; - A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb.c; sourceTree = ""; }; A7D8A77023E2513E00DCD162 /* yuv_rgb_sse_func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_sse_func.h; sourceTree = ""; }; A7D8A77123E2513E00DCD162 /* yuv_rgb_std_func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_std_func.h; sourceTree = ""; }; A7D8A77223E2513E00DCD162 /* yuv_rgb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb.h; sourceTree = ""; }; @@ -4104,9 +4190,23 @@ DB31407717554B71006C0E22 /* libSDL2.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libSDL2.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; E2D187CF28A5673500D2B4F1 /* SDL2.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDL2.framework; sourceTree = BUILT_PRODUCTS_DIR; }; E2D187D228A5673500D2B4F1 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_common.h; sourceTree = ""; }; + F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_internal.h; sourceTree = ""; }; + F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb_std.c; sourceTree = ""; }; + F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb_sse.c; sourceTree = ""; }; + F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_lsx.h; sourceTree = ""; }; + F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb_lsx.c; sourceTree = ""; }; + F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_sse.h; sourceTree = ""; }; + F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_std.h; sourceTree = ""; }; + F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_lsx_func.h; sourceTree = ""; }; F31A92C628D4CB39003BFD6A /* SDL_offscreenopengles.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_offscreenopengles.h; sourceTree = ""; }; F31A92C728D4CB39003BFD6A /* SDL_offscreenopengles.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_offscreenopengles.c; sourceTree = ""; }; F32305FE28939F6400E66D30 /* SDL_hidapi_combined.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_combined.c; sourceTree = ""; }; + F362B91F2B33916600D30B94 /* controller_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = controller_list.h; sourceTree = ""; }; + F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_hidapi_steamdeck.c; sourceTree = ""; }; + F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_hidapi_nintendo.h; sourceTree = ""; }; + F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_steam_virtual_gamepad.h; sourceTree = ""; }; + F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_steam_virtual_gamepad.c; sourceTree = ""; }; F376F6182559B29300CFC0BC /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.1.sdk/System/Library/Frameworks/OpenGLES.framework; sourceTree = DEVELOPER_DIR; }; F376F61A2559B2AF00CFC0BC /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; F376F6312559B31D00CFC0BC /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/iOSSupport/System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; @@ -4769,7 +4869,6 @@ A7D8A61823E2513D00DCD162 /* uikit */ = { isa = PBXGroup; children = ( - A7D8A62823E2513D00DCD162 /* keyinfotable.h */, A7D8A62F23E2513D00DCD162 /* SDL_uikitappdelegate.h */, A7D8A61E23E2513D00DCD162 /* SDL_uikitappdelegate.m */, A7D8A62123E2513D00DCD162 /* SDL_uikitclipboard.h */, @@ -4884,7 +4983,6 @@ A7D8A73323E2513E00DCD162 /* vulkan_fuchsia.h */, A7D8A73B23E2513E00DCD162 /* vulkan_ios.h */, A7D8A73623E2513E00DCD162 /* vulkan_macos.h */, - A7D8A73923E2513E00DCD162 /* vulkan_mir.h */, A7D8A72F23E2513E00DCD162 /* vulkan_vi.h */, A7D8A73423E2513E00DCD162 /* vulkan_wayland.h */, A7D8A73523E2513E00DCD162 /* vulkan_win32.h */, @@ -4892,7 +4990,6 @@ A7D8A73723E2513E00DCD162 /* vulkan_xlib_xrandr.h */, A7D8A73A23E2513E00DCD162 /* vulkan_xlib.h */, A7D8A73023E2513E00DCD162 /* vulkan.h */, - A7D8A73223E2513E00DCD162 /* vulkan.hpp */, ); path = vulkan; sourceTree = ""; @@ -4900,9 +4997,17 @@ A7D8A76C23E2513E00DCD162 /* yuv2rgb */ = { isa = PBXGroup; children = ( + F316AB7C2B5A02C2002EF551 /* yuv_rgb_common.h */, + F316AB7D2B5A02C2002EF551 /* yuv_rgb_internal.h */, + F316AB842B5A02C3002EF551 /* yuv_rgb_lsx_func.h */, + F316AB812B5A02C3002EF551 /* yuv_rgb_lsx.c */, + F316AB802B5A02C3002EF551 /* yuv_rgb_lsx.h */, A7D8A77023E2513E00DCD162 /* yuv_rgb_sse_func.h */, + F316AB7F2B5A02C3002EF551 /* yuv_rgb_sse.c */, + F316AB822B5A02C3002EF551 /* yuv_rgb_sse.h */, A7D8A77123E2513E00DCD162 /* yuv_rgb_std_func.h */, - A7D8A76E23E2513E00DCD162 /* yuv_rgb.c */, + F316AB7E2B5A02C3002EF551 /* yuv_rgb_std.c */, + F316AB832B5A02C3002EF551 /* yuv_rgb_std.h */, A7D8A77223E2513E00DCD162 /* yuv_rgb.h */, ); path = yuv2rgb; @@ -4950,12 +5055,15 @@ A7D8A7AA23E2513E00DCD162 /* iphoneos */, A7D8A7A123E2513E00DCD162 /* steam */, 75E09157241EA924004729E1 /* virtual */, - A7D8A7AD23E2513E00DCD162 /* SDL_gamecontroller.c */, - A7D8A7A923E2513E00DCD162 /* SDL_joystick.c */, + F362B91F2B33916600D30B94 /* controller_list.h */, F3820712284F3609004DD584 /* controller_type.c */, A7D8A7D923E2513E00DCD162 /* controller_type.h */, + A7D8A7AD23E2513E00DCD162 /* SDL_gamecontroller.c */, A7D8A79E23E2513E00DCD162 /* SDL_gamecontrollerdb.h */, A7D8A7D023E2513E00DCD162 /* SDL_joystick_c.h */, + A7D8A7A923E2513E00DCD162 /* SDL_joystick.c */, + F362B9512B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c */, + F362B9502B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h */, A7D8A7CF23E2513E00DCD162 /* SDL_sysjoystick.h */, A7D8A7CB23E2513E00DCD162 /* usb_ids.h */, ); @@ -4994,6 +5102,7 @@ F32305FE28939F6400E66D30 /* SDL_hidapi_combined.c */, A7D8A7C923E2513E00DCD162 /* SDL_hidapi_gamecube.c */, F3F07D59269640160074468B /* SDL_hidapi_luna.c */, + F362B93C2B33920400D30B94 /* SDL_hidapi_nintendo.h */, F388C95428B5F6F600661ECF /* SDL_hidapi_ps3.c */, A7D8A7C323E2513E00DCD162 /* SDL_hidapi_ps4.c */, F3A4909D2554D38500E92A8B /* SDL_hidapi_ps5.c */, @@ -5002,6 +5111,7 @@ 9846B07B287A9020000C35C8 /* SDL_hidapi_shield.c */, F3984CCF25BCC92800374F43 /* SDL_hidapi_stadia.c */, A75FDAAC23E2795C00529352 /* SDL_hidapi_steam.c */, + F362B93B2B33920400D30B94 /* SDL_hidapi_steamdeck.c */, A7D8A7C623E2513E00DCD162 /* SDL_hidapi_switch.c */, F3D60A8228C16A1800788A3A /* SDL_hidapi_wii.c */, A7D8A7C223E2513E00DCD162 /* SDL_hidapi_xbox360.c */, @@ -5393,6 +5503,7 @@ A75FCD0223E25AB700529352 /* close_code.h in Headers */, A75FCD0323E25AB700529352 /* SDL.h in Headers */, A75FCD0423E25AB700529352 /* SDL_uikitmetalview.h in Headers */, + F362B9592B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A75FCD0523E25AB700529352 /* SDL_assert.h in Headers */, A75FCD0623E25AB700529352 /* SDL_shape_internals.h in Headers */, A75FCD0723E25AB700529352 /* SDL_glfuncs.h in Headers */, @@ -5408,7 +5519,6 @@ A75FCD1023E25AB700529352 /* SDL_uikitview.h in Headers */, A75FCD1123E25AB700529352 /* SDL_bits.h in Headers */, A75FCD1223E25AB700529352 /* SDL_uikitappdelegate.h in Headers */, - A75FCD1323E25AB700529352 /* keyinfotable.h in Headers */, A75FCD1423E25AB700529352 /* SDL_blendmode.h in Headers */, A75FCD1523E25AB700529352 /* SDL_dropevents_c.h in Headers */, A75FCD1623E25AB700529352 /* SDL_haptic_c.h in Headers */, @@ -5456,6 +5566,7 @@ A75FCD4323E25AB700529352 /* SDL_keyboard.h in Headers */, A75FCD4423E25AB700529352 /* SDL_uikitevents.h in Headers */, A75FCD4523E25AB700529352 /* SDL_gesture_c.h in Headers */, + F362B9392B33916600D30B94 /* controller_list.h in Headers */, A75FCD4623E25AB700529352 /* SDL_shaders_gl.h in Headers */, A75FCD4723E25AB700529352 /* SDL_systhread_c.h in Headers */, A1BB8B7327F6CF330057CFA8 /* SDL_list.h in Headers */, @@ -5463,11 +5574,11 @@ 5616CA63252BB35F005D5928 /* SDL_sysurl.h in Headers */, A75FCD4A23E25AB700529352 /* SDL_cocoakeyboard.h in Headers */, A75FCD4B23E25AB700529352 /* SDL_uikitvulkan.h in Headers */, - A75FCD4E23E25AB700529352 /* vulkan.hpp in Headers */, A75FCD4F23E25AB700529352 /* SDL_loadso.h in Headers */, A75FCD5023E25AB700529352 /* gl2ext.h in Headers */, A75FCD5123E25AB700529352 /* SDL_clipboardevents_c.h in Headers */, A75FCD5323E25AB700529352 /* SDL_syshaptic_c.h in Headers */, + F316ABC22B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A75FCD5423E25AB700529352 /* SDL_hints_c.h in Headers */, A75FCD5523E25AB700529352 /* SDL_audiodev_c.h in Headers */, A75FCD5623E25AB700529352 /* SDL_audio_c.h in Headers */, @@ -5481,6 +5592,7 @@ A75FCD5E23E25AB700529352 /* yuv_rgb_std_func.h in Headers */, A75FCD5F23E25AB700529352 /* vulkan_core.h in Headers */, A75FCD6023E25AB700529352 /* SDL_syssensor.h in Headers */, + F316ABD42B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A75FCD6123E25AB700529352 /* SDL_dynapi.h in Headers */, A75FCD6223E25AB700529352 /* SDL_assert_c.h in Headers */, A75FCD6323E25AB700529352 /* SDL_diskaudio.h in Headers */, @@ -5490,6 +5602,7 @@ A75FCD6723E25AB700529352 /* SDL_wave.h in Headers */, A75FCD6823E25AB700529352 /* SDL_cocoaopengl.h in Headers */, A75FCD6923E25AB700529352 /* yuv_rgb_sse_func.h in Headers */, + F316ABCB2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A75FCD6B23E25AB700529352 /* SDL_offscreenevents_c.h in Headers */, F3973FA928A59BDD00B84553 /* SDL_vacopy.h in Headers */, A1626A592617008D003F1973 /* SDL_triangle.h in Headers */, @@ -5513,6 +5626,8 @@ A75FCD7F23E25AB700529352 /* SDL_opengles.h in Headers */, A75FCD8023E25AB700529352 /* SDL_shaders_gles2.h in Headers */, A75FCD8123E25AB700529352 /* SDL_opengles2.h in Headers */, + F316AB8C2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, + F316ABB02B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A75FCD8223E25AB700529352 /* SDL_glesfuncs.h in Headers */, A75FCD8323E25AB700529352 /* SDL_blendpoint.h in Headers */, A75FCD8423E25AB700529352 /* SDL_offscreenvideo.h in Headers */, @@ -5542,7 +5657,6 @@ A75FCDA123E25AB700529352 /* vulkan_xlib.h in Headers */, A75FCDA223E25AB700529352 /* SDL_uikitwindow.h in Headers */, A75FCDA323E25AB700529352 /* vulkan_vi.h in Headers */, - A75FCDA423E25AB700529352 /* vulkan_mir.h in Headers */, A75FCDA523E25AB700529352 /* SDL_quit.h in Headers */, A75FCDA623E25AB700529352 /* default_cursor.h in Headers */, A75FCDA723E25AB700529352 /* SDL_render_sw_c.h in Headers */, @@ -5602,11 +5716,13 @@ A75FCDDE23E25AB700529352 /* SDL_video.h in Headers */, A75FCDDF23E25AB700529352 /* SDL_opengles2_gl2.h in Headers */, A75FCDE023E25AB700529352 /* SDL_sensor.h in Headers */, + F362B94D2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A75FCDE123E25AB700529352 /* SDL_sysvideo.h in Headers */, F386F6EE2884663E001840AA /* SDL_log_c.h in Headers */, A75FCDE223E25AB700529352 /* SDL_opengles2_gl2platform.h in Headers */, A75FCDE323E25AB700529352 /* SDL_opengles2_gl2ext.h in Headers */, A75FCDE523E25AB700529352 /* SDL_dynapi_overrides.h in Headers */, + F316AB952B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A75FCDE623E25AB700529352 /* SDL_cocoawindow.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5622,6 +5738,7 @@ A75FCEBB23E25AC700529352 /* close_code.h in Headers */, A75FCEBC23E25AC700529352 /* SDL.h in Headers */, A75FCEBD23E25AC700529352 /* SDL_uikitmetalview.h in Headers */, + F362B95A2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A75FCEBE23E25AC700529352 /* SDL_assert.h in Headers */, A75FCEBF23E25AC700529352 /* SDL_shape_internals.h in Headers */, A75FCEC023E25AC700529352 /* SDL_glfuncs.h in Headers */, @@ -5637,7 +5754,6 @@ A75FCEC923E25AC700529352 /* SDL_uikitview.h in Headers */, A75FCECA23E25AC700529352 /* SDL_bits.h in Headers */, A75FCECB23E25AC700529352 /* SDL_uikitappdelegate.h in Headers */, - A75FCECC23E25AC700529352 /* keyinfotable.h in Headers */, A75FCECD23E25AC700529352 /* SDL_blendmode.h in Headers */, A75FCECE23E25AC700529352 /* SDL_dropevents_c.h in Headers */, A75FCECF23E25AC700529352 /* SDL_haptic_c.h in Headers */, @@ -5685,6 +5801,7 @@ A75FCEFC23E25AC700529352 /* SDL_keyboard.h in Headers */, A75FCEFD23E25AC700529352 /* SDL_uikitevents.h in Headers */, A75FCEFE23E25AC700529352 /* SDL_gesture_c.h in Headers */, + F362B93A2B33916600D30B94 /* controller_list.h in Headers */, A75FCEFF23E25AC700529352 /* SDL_shaders_gl.h in Headers */, A75FCF0023E25AC700529352 /* SDL_systhread_c.h in Headers */, A1BB8B7427F6CF330057CFA8 /* SDL_list.h in Headers */, @@ -5692,11 +5809,11 @@ 5616CA66252BB361005D5928 /* SDL_sysurl.h in Headers */, A75FCF0323E25AC700529352 /* SDL_cocoakeyboard.h in Headers */, A75FCF0423E25AC700529352 /* SDL_uikitvulkan.h in Headers */, - A75FCF0723E25AC700529352 /* vulkan.hpp in Headers */, A75FCF0823E25AC700529352 /* SDL_loadso.h in Headers */, A75FCF0923E25AC700529352 /* gl2ext.h in Headers */, A75FCF0A23E25AC700529352 /* SDL_clipboardevents_c.h in Headers */, A75FCF0C23E25AC700529352 /* SDL_syshaptic_c.h in Headers */, + F316ABC32B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A75FCF0D23E25AC700529352 /* SDL_hints_c.h in Headers */, A75FCF0E23E25AC700529352 /* SDL_audiodev_c.h in Headers */, A75FCF0F23E25AC700529352 /* SDL_audio_c.h in Headers */, @@ -5710,6 +5827,7 @@ A75FCF1723E25AC700529352 /* yuv_rgb_std_func.h in Headers */, A75FCF1823E25AC700529352 /* vulkan_core.h in Headers */, A75FCF1923E25AC700529352 /* SDL_syssensor.h in Headers */, + F316ABD52B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A75FCF1A23E25AC700529352 /* SDL_dynapi.h in Headers */, A75FCF1B23E25AC700529352 /* SDL_assert_c.h in Headers */, A75FCF1C23E25AC700529352 /* SDL_diskaudio.h in Headers */, @@ -5719,6 +5837,7 @@ A75FCF2023E25AC700529352 /* SDL_wave.h in Headers */, A75FCF2123E25AC700529352 /* SDL_cocoaopengl.h in Headers */, A75FCF2223E25AC700529352 /* yuv_rgb_sse_func.h in Headers */, + F316ABCC2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A75FCF2423E25AC700529352 /* SDL_offscreenevents_c.h in Headers */, F3973FAA28A59BDD00B84553 /* SDL_vacopy.h in Headers */, A1626A5A2617008D003F1973 /* SDL_triangle.h in Headers */, @@ -5742,6 +5861,8 @@ A75FCF3823E25AC700529352 /* SDL_opengles.h in Headers */, A75FCF3923E25AC700529352 /* SDL_shaders_gles2.h in Headers */, A75FCF3A23E25AC700529352 /* SDL_opengles2.h in Headers */, + F316AB8D2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, + F316ABB12B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A75FCF3B23E25AC700529352 /* SDL_glesfuncs.h in Headers */, A75FCF3C23E25AC700529352 /* SDL_blendpoint.h in Headers */, A75FCF3D23E25AC700529352 /* SDL_offscreenvideo.h in Headers */, @@ -5771,7 +5892,6 @@ A75FCF5A23E25AC700529352 /* vulkan_xlib.h in Headers */, A75FCF5B23E25AC700529352 /* SDL_uikitwindow.h in Headers */, A75FCF5C23E25AC700529352 /* vulkan_vi.h in Headers */, - A75FCF5D23E25AC700529352 /* vulkan_mir.h in Headers */, A75FCF5E23E25AC700529352 /* SDL_quit.h in Headers */, A75FCF5F23E25AC700529352 /* default_cursor.h in Headers */, A75FCF6023E25AC700529352 /* SDL_render_sw_c.h in Headers */, @@ -5831,11 +5951,13 @@ A75FCF9723E25AC700529352 /* SDL_video.h in Headers */, A75FCF9823E25AC700529352 /* SDL_opengles2_gl2.h in Headers */, A75FCF9923E25AC700529352 /* SDL_sensor.h in Headers */, + F362B94E2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A75FCF9A23E25AC700529352 /* SDL_sysvideo.h in Headers */, F386F6EF2884663E001840AA /* SDL_log_c.h in Headers */, A75FCF9B23E25AC700529352 /* SDL_opengles2_gl2platform.h in Headers */, A75FCF9C23E25AC700529352 /* SDL_opengles2_gl2ext.h in Headers */, A75FCF9E23E25AC700529352 /* SDL_dynapi_overrides.h in Headers */, + F316AB962B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A75FCF9F23E25AC700529352 /* SDL_cocoawindow.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -5856,7 +5978,6 @@ A769B09623E259AE00872273 /* SDL_coremotionsensor.h in Headers */, A769B09723E259AE00872273 /* SDL_uikitview.h in Headers */, A769B09923E259AE00872273 /* SDL_uikitappdelegate.h in Headers */, - A769B09A23E259AE00872273 /* keyinfotable.h in Headers */, A769B09C23E259AE00872273 /* SDL_dropevents_c.h in Headers */, A769B09D23E259AE00872273 /* SDL_haptic_c.h in Headers */, A769B09F23E259AE00872273 /* SDL_dataqueue.h in Headers */, @@ -5880,6 +6001,7 @@ A769B0BC23E259AE00872273 /* SDL_sysaudio.h in Headers */, A769B0BF23E259AE00872273 /* math_libm.h in Headers */, A769B0C023E259AE00872273 /* SDL_uikitvideo.h in Headers */, + F316ABC02B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A769B0C123E259AE00872273 /* SDL_cocoamouse.h in Headers */, A769B0C323E259AE00872273 /* SDL_blit_slow.h in Headers */, F3973FA728A59BDD00B84553 /* SDL_vacopy.h in Headers */, @@ -5895,7 +6017,6 @@ A769B0D023E259AE00872273 /* SDL_cocoakeyboard.h in Headers */, 5616CA5D252BB35E005D5928 /* SDL_sysurl.h in Headers */, A769B0D123E259AE00872273 /* SDL_uikitvulkan.h in Headers */, - A769B0D423E259AE00872273 /* vulkan.hpp in Headers */, A769B0D623E259AE00872273 /* gl2ext.h in Headers */, A769B0D723E259AE00872273 /* SDL_clipboardevents_c.h in Headers */, A769B0D923E259AE00872273 /* SDL_syshaptic_c.h in Headers */, @@ -5911,13 +6032,16 @@ A769B0E523E259AE00872273 /* vulkan_android.h in Headers */, A769B0E623E259AE00872273 /* yuv_rgb_std_func.h in Headers */, A769B0E723E259AE00872273 /* vulkan_core.h in Headers */, + F362B9572B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A769B0E823E259AE00872273 /* SDL_syssensor.h in Headers */, + F316AB8A2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, A769B0E923E259AE00872273 /* SDL_dynapi.h in Headers */, A769B0EA23E259AE00872273 /* SDL_assert_c.h in Headers */, A769B0EB23E259AE00872273 /* SDL_diskaudio.h in Headers */, A769B0ED23E259AE00872273 /* SDL_drawpoint.h in Headers */, A769B0EF23E259AE00872273 /* SDL_wave.h in Headers */, A769B0F023E259AE00872273 /* SDL_cocoaopengl.h in Headers */, + F316ABC92B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A1626A572617008D003F1973 /* SDL_triangle.h in Headers */, A769B0F123E259AE00872273 /* yuv_rgb_sse_func.h in Headers */, A769B0F323E259AE00872273 /* SDL_offscreenevents_c.h in Headers */, @@ -5938,9 +6062,11 @@ A769B10A23E259AE00872273 /* SDL_blendpoint.h in Headers */, A769B10B23E259AE00872273 /* SDL_offscreenvideo.h in Headers */, A769B10C23E259AE00872273 /* SDL_nullevents_c.h in Headers */, + F316ABD22B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A769B10D23E259AE00872273 /* SDL_sysjoystick.h in Headers */, A769B10E23E259AE00872273 /* scancodes_linux.h in Headers */, A769B11023E259AE00872273 /* SDL_touch_c.h in Headers */, + F362B94B2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A769B11123E259AE00872273 /* SDL_gamecontrollerdb.h in Headers */, A769B11223E259AE00872273 /* SDL_cocoavulkan.h in Headers */, A769B11323E259AE00872273 /* gl2platform.h in Headers */, @@ -5952,6 +6078,7 @@ A769B11D23E259AE00872273 /* vulkan_xlib_xrandr.h in Headers */, A769B11E23E259AE00872273 /* SDL_sensor_c.h in Headers */, A769B11F23E259AE00872273 /* SDL_sysrender.h in Headers */, + F316AB932B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A769B12023E259AE00872273 /* SDL_rotate.h in Headers */, A769B12523E259AE00872273 /* scancodes_darwin.h in Headers */, A769B12623E259AE00872273 /* controller_type.h in Headers */, @@ -5960,7 +6087,6 @@ F386F6F52884663E001840AA /* SDL_utils_c.h in Headers */, A769B12A23E259AE00872273 /* SDL_uikitwindow.h in Headers */, A769B12B23E259AE00872273 /* vulkan_vi.h in Headers */, - A769B12C23E259AE00872273 /* vulkan_mir.h in Headers */, A769B12E23E259AE00872273 /* default_cursor.h in Headers */, A769B12F23E259AE00872273 /* SDL_render_sw_c.h in Headers */, A769B13223E259AE00872273 /* SDL_nullvideo.h in Headers */, @@ -5997,11 +6123,13 @@ A769B15623E259AE00872273 /* SDL_syshaptic.h in Headers */, A769B15723E259AE00872273 /* SDL_vulkan_internal.h in Headers */, A769B15923E259AE00872273 /* SDL_cocoaevents.h in Headers */, + F362B9372B33916600D30B94 /* controller_list.h in Headers */, A769B15A23E259AE00872273 /* vk_icd.h in Headers */, A769B15B23E259AE00872273 /* SDL_nullframebuffer_c.h in Headers */, A769B15D23E259AE00872273 /* SDL_dynapi_procs.h in Headers */, A769B15E23E259AE00872273 /* vulkan_fuchsia.h in Headers */, A769B16123E259AE00872273 /* usb_ids.h in Headers */, + F316ABAE2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A769B16323E259AE00872273 /* SDL_gles2funcs.h in Headers */, A769B16923E259AE00872273 /* SDL_sysvideo.h in Headers */, A769B16D23E259AE00872273 /* SDL_dynapi_overrides.h in Headers */, @@ -6024,6 +6152,7 @@ A7D88A1E23E2437C00DCD162 /* SDL_bits.h in Headers */, A7D8BA0223E2514400DCD162 /* SDL_blendfillrect.h in Headers */, A7D8B9EA23E2514400DCD162 /* SDL_blendline.h in Headers */, + F316ABC52B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A7D88A1F23E2437C00DCD162 /* SDL_blendmode.h in Headers */, A7D8BA0E23E2514400DCD162 /* SDL_blendpoint.h in Headers */, A7D8B3B723E2514200DCD162 /* SDL_blit.h in Headers */, @@ -6059,6 +6188,7 @@ A7D8BB4023E2514500DCD162 /* SDL_displayevents_c.h in Headers */, A7D8BA1A23E2514400DCD162 /* SDL_draw.h in Headers */, A7D8BA0823E2514400DCD162 /* SDL_drawline.h in Headers */, + F316ABBC2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8B9F023E2514400DCD162 /* SDL_drawpoint.h in Headers */, A7D8BB2E23E2514500DCD162 /* SDL_dropevents_c.h in Headers */, A7D8B79523E2514400DCD162 /* SDL_dummyaudio.h in Headers */, @@ -6083,14 +6213,17 @@ A7D8BA7A23E2514400DCD162 /* SDL_glfuncs.h in Headers */, A7D88A2D23E2437C00DCD162 /* SDL_haptic.h in Headers */, A7D8AABD23E2514100DCD162 /* SDL_haptic_c.h in Headers */, + F316AB8F2B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A75FDBC623EA380300529352 /* SDL_hidapi_rumble.h in Headers */, A7D8B55823E2514300DCD162 /* SDL_hidapijoystick_c.h in Headers */, A7D88A2E23E2437C00DCD162 /* SDL_hints.h in Headers */, A7D8B94B23E2514400DCD162 /* SDL_hints_c.h in Headers */, + F316ABCE2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8A99A23E2514000DCD162 /* SDL_internal.h in Headers */, F395C1942569C68F00942BFF /* SDL_iokitjoystick_c.h in Headers */, A7D88A2F23E2437C00DCD162 /* SDL_joystick.h in Headers */, A7D8B58823E2514300DCD162 /* SDL_joystick_c.h in Headers */, + F316AB862B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, A7D88A3023E2437C00DCD162 /* SDL_keyboard.h in Headers */, A7D8BB8823E2514500DCD162 /* SDL_keyboard_c.h in Headers */, A7D88A3323E2437C00DCD162 /* SDL_keycode.h in Headers */, @@ -6161,6 +6294,8 @@ A7D8B5D623E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B61223E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B9D823E2514400DCD162 /* SDL_sysrender.h in Headers */, + F362B9472B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, + F316ABAA2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8A97C23E2514000DCD162 /* SDL_syssensor.h in Headers */, A7D88A5323E2437C00DCD162 /* SDL_system.h in Headers */, A7D8B3E723E2514300DCD162 /* SDL_systhread.h in Headers */, @@ -6199,6 +6334,7 @@ A7D8B9CC23E2514400DCD162 /* SDL_yuv_sw_c.h in Headers */, A7D88A1623E2437C00DCD162 /* begin_code.h in Headers */, A7D8BB4623E2514500DCD162 /* blank_cursor.h in Headers */, + F362B9532B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A7D88A1823E2437C00DCD162 /* close_code.h in Headers */, A7D8B5B823E2514300DCD162 /* controller_type.h in Headers */, A7D8BB4C23E2514500DCD162 /* default_cursor.h in Headers */, @@ -6209,7 +6345,6 @@ A7D8B22523E2514200DCD162 /* gl2ext.h in Headers */, A7D8B23123E2514200DCD162 /* gl2platform.h in Headers */, A75FDB5923E39E6100529352 /* hidapi.h in Headers */, - A7D8ACA023E2514100DCD162 /* keyinfotable.h in Headers */, A7D8B23723E2514200DCD162 /* khrplatform.h in Headers */, A7D8BB0423E2514500DCD162 /* math_libm.h in Headers */, A7D8BAC223E2514500DCD162 /* math_private.h in Headers */, @@ -6224,16 +6359,15 @@ A7D8B26723E2514200DCD162 /* vk_platform.h in Headers */, A7D8B2AF23E2514200DCD162 /* vk_sdk_platform.h in Headers */, A7D8B26123E2514200DCD162 /* vulkan.h in Headers */, - A7D8B26D23E2514200DCD162 /* vulkan.hpp in Headers */, A7D8B2B523E2514200DCD162 /* vulkan_android.h in Headers */, A7D8B2A923E2514200DCD162 /* vulkan_core.h in Headers */, A7D8B27323E2514200DCD162 /* vulkan_fuchsia.h in Headers */, A7D8B2A323E2514200DCD162 /* vulkan_ios.h in Headers */, A7D8B28523E2514200DCD162 /* vulkan_macos.h in Headers */, - A7D8B29723E2514200DCD162 /* vulkan_mir.h in Headers */, A7D8B25B23E2514200DCD162 /* vulkan_vi.h in Headers */, A7D8B27923E2514200DCD162 /* vulkan_wayland.h in Headers */, A7D8B27F23E2514200DCD162 /* vulkan_win32.h in Headers */, + F362B9332B33916600D30B94 /* controller_list.h in Headers */, A7D8B29123E2514200DCD162 /* vulkan_xcb.h in Headers */, A7D8B29D23E2514200DCD162 /* vulkan_xlib.h in Headers */, A7D8B28B23E2514200DCD162 /* vulkan_xlib_xrandr.h in Headers */, @@ -6258,6 +6392,7 @@ A7D88BD523E24BED00DCD162 /* SDL_bits.h in Headers */, A7D8BA0323E2514400DCD162 /* SDL_blendfillrect.h in Headers */, A7D8B9EB23E2514400DCD162 /* SDL_blendline.h in Headers */, + F316ABC62B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A7D88BD623E24BED00DCD162 /* SDL_blendmode.h in Headers */, A7D8BA0F23E2514400DCD162 /* SDL_blendpoint.h in Headers */, A7D8B3B823E2514200DCD162 /* SDL_blit.h in Headers */, @@ -6293,6 +6428,7 @@ A7D8BB4123E2514500DCD162 /* SDL_displayevents_c.h in Headers */, A7D8BA1B23E2514400DCD162 /* SDL_draw.h in Headers */, A7D8BA0923E2514400DCD162 /* SDL_drawline.h in Headers */, + F316ABBD2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8B9F123E2514400DCD162 /* SDL_drawpoint.h in Headers */, A7D8BB2F23E2514500DCD162 /* SDL_dropevents_c.h in Headers */, A7D8B79623E2514400DCD162 /* SDL_dummyaudio.h in Headers */, @@ -6317,14 +6453,17 @@ A7D8BA7B23E2514400DCD162 /* SDL_glfuncs.h in Headers */, A7D88BE423E24BED00DCD162 /* SDL_haptic.h in Headers */, A7D8AABE23E2514100DCD162 /* SDL_haptic_c.h in Headers */, + F316AB902B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A75FDBC723EA380300529352 /* SDL_hidapi_rumble.h in Headers */, A7D8B55923E2514300DCD162 /* SDL_hidapijoystick_c.h in Headers */, A7D88BE523E24BED00DCD162 /* SDL_hints.h in Headers */, A7D8B94C23E2514400DCD162 /* SDL_hints_c.h in Headers */, + F316ABCF2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8A99B23E2514000DCD162 /* SDL_internal.h in Headers */, F395C1952569C68F00942BFF /* SDL_iokitjoystick_c.h in Headers */, A7D88BE623E24BED00DCD162 /* SDL_joystick.h in Headers */, A7D8B58923E2514300DCD162 /* SDL_joystick_c.h in Headers */, + F316AB872B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, A7D88BE723E24BED00DCD162 /* SDL_keyboard.h in Headers */, A7D8BB8923E2514500DCD162 /* SDL_keyboard_c.h in Headers */, A7D88BEB23E24BED00DCD162 /* SDL_keycode.h in Headers */, @@ -6395,6 +6534,8 @@ A7D8B5D723E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B61323E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B9D923E2514400DCD162 /* SDL_sysrender.h in Headers */, + F362B9482B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, + F316ABAB2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8A97D23E2514000DCD162 /* SDL_syssensor.h in Headers */, A7D88C0E23E24BED00DCD162 /* SDL_system.h in Headers */, A7D8B3E823E2514300DCD162 /* SDL_systhread.h in Headers */, @@ -6433,6 +6574,7 @@ A7D8B9CD23E2514400DCD162 /* SDL_yuv_sw_c.h in Headers */, A7D88BCC23E24BED00DCD162 /* begin_code.h in Headers */, A7D8BB4723E2514500DCD162 /* blank_cursor.h in Headers */, + F362B9542B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A7D88BCE23E24BED00DCD162 /* close_code.h in Headers */, A7D8B5B923E2514300DCD162 /* controller_type.h in Headers */, A7D8BB4D23E2514500DCD162 /* default_cursor.h in Headers */, @@ -6443,7 +6585,6 @@ A7D8B22623E2514200DCD162 /* gl2ext.h in Headers */, A7D8B23223E2514200DCD162 /* gl2platform.h in Headers */, A75FDB5A23E39E6100529352 /* hidapi.h in Headers */, - A7D8ACA123E2514100DCD162 /* keyinfotable.h in Headers */, A7D8B23823E2514200DCD162 /* khrplatform.h in Headers */, A7D8BB0523E2514500DCD162 /* math_libm.h in Headers */, A7D8BAC323E2514500DCD162 /* math_private.h in Headers */, @@ -6458,16 +6599,15 @@ A7D8B26823E2514200DCD162 /* vk_platform.h in Headers */, A7D8B2B023E2514200DCD162 /* vk_sdk_platform.h in Headers */, A7D8B26223E2514200DCD162 /* vulkan.h in Headers */, - A7D8B26E23E2514200DCD162 /* vulkan.hpp in Headers */, A7D8B2B623E2514200DCD162 /* vulkan_android.h in Headers */, A7D8B2AA23E2514200DCD162 /* vulkan_core.h in Headers */, A7D8B27423E2514200DCD162 /* vulkan_fuchsia.h in Headers */, A7D8B2A423E2514200DCD162 /* vulkan_ios.h in Headers */, A7D8B28623E2514200DCD162 /* vulkan_macos.h in Headers */, - A7D8B29823E2514200DCD162 /* vulkan_mir.h in Headers */, A7D8B25C23E2514200DCD162 /* vulkan_vi.h in Headers */, A7D8B27A23E2514200DCD162 /* vulkan_wayland.h in Headers */, A7D8B28023E2514200DCD162 /* vulkan_win32.h in Headers */, + F362B9342B33916600D30B94 /* controller_list.h in Headers */, A7D8B29223E2514200DCD162 /* vulkan_xcb.h in Headers */, A7D8B29E23E2514200DCD162 /* vulkan_xlib.h in Headers */, A7D8B28C23E2514200DCD162 /* vulkan_xlib_xrandr.h in Headers */, @@ -6493,7 +6633,6 @@ A7D8A97323E2514000DCD162 /* SDL_coremotionsensor.h in Headers */, A7D8AC4923E2514100DCD162 /* SDL_uikitview.h in Headers */, A7D8ACCD23E2514100DCD162 /* SDL_uikitappdelegate.h in Headers */, - A7D8ACA323E2514100DCD162 /* keyinfotable.h in Headers */, A7D8BB3123E2514500DCD162 /* SDL_dropevents_c.h in Headers */, A7D8AAC023E2514100DCD162 /* SDL_haptic_c.h in Headers */, A7D8A94923E2514000DCD162 /* SDL_dataqueue.h in Headers */, @@ -6517,6 +6656,7 @@ A7D8B85E23E2514400DCD162 /* SDL_sysaudio.h in Headers */, A7D8BB0723E2514500DCD162 /* math_libm.h in Headers */, A7D8AC7F23E2514100DCD162 /* SDL_uikitvideo.h in Headers */, + F316ABBF2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8AF2223E2514100DCD162 /* SDL_cocoamouse.h in Headers */, A7D8ADF023E2514100DCD162 /* SDL_blit_slow.h in Headers */, F3973FA628A59BDD00B84553 /* SDL_vacopy.h in Headers */, @@ -6532,7 +6672,6 @@ A7D8AE9223E2514100DCD162 /* SDL_cocoakeyboard.h in Headers */, 5616CA5A252BB35D005D5928 /* SDL_sysurl.h in Headers */, A7D8ACE523E2514100DCD162 /* SDL_uikitvulkan.h in Headers */, - A7D8B27023E2514200DCD162 /* vulkan.hpp in Headers */, A7D8B22823E2514200DCD162 /* gl2ext.h in Headers */, A7D8BB7323E2514500DCD162 /* SDL_clipboardevents_c.h in Headers */, A7D8AAE423E2514100DCD162 /* SDL_syshaptic_c.h in Headers */, @@ -6548,13 +6687,16 @@ A7D8B2B823E2514200DCD162 /* vulkan_android.h in Headers */, A7D8B3D223E2514300DCD162 /* yuv_rgb_std_func.h in Headers */, A7D8B2AC23E2514200DCD162 /* vulkan_core.h in Headers */, + F362B9562B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A7D8A97F23E2514000DCD162 /* SDL_syssensor.h in Headers */, + F316AB892B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, A7D8AB0E23E2514100DCD162 /* SDL_dynapi.h in Headers */, A7D8B61B23E2514300DCD162 /* SDL_assert_c.h in Headers */, A7D8B8A623E2514400DCD162 /* SDL_diskaudio.h in Headers */, A7D8B9F323E2514400DCD162 /* SDL_drawpoint.h in Headers */, A7D8B87023E2514400DCD162 /* SDL_wave.h in Headers */, A7D8AEE023E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, + F316ABC82B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A1626A562617008D003F1973 /* SDL_triangle.h in Headers */, A7D8B3CC23E2514300DCD162 /* yuv_rgb_sse_func.h in Headers */, A7D8AB5F23E2514100DCD162 /* SDL_offscreenevents_c.h in Headers */, @@ -6575,9 +6717,11 @@ A7D8BA1123E2514400DCD162 /* SDL_blendpoint.h in Headers */, A7D8AB7123E2514100DCD162 /* SDL_offscreenvideo.h in Headers */, A7D8AC0123E2514100DCD162 /* SDL_nullevents_c.h in Headers */, + F316ABD12B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8B58523E2514300DCD162 /* SDL_sysjoystick.h in Headers */, A7D8BB6123E2514500DCD162 /* scancodes_linux.h in Headers */, A7D8BB6723E2514500DCD162 /* SDL_touch_c.h in Headers */, + F362B94A2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A7D8B4B023E2514300DCD162 /* SDL_gamecontrollerdb.h in Headers */, A7D8AEEC23E2514100DCD162 /* SDL_cocoavulkan.h in Headers */, A7D8B23423E2514200DCD162 /* gl2platform.h in Headers */, @@ -6589,6 +6733,7 @@ A7D8B28E23E2514200DCD162 /* vulkan_xlib_xrandr.h in Headers */, A7D8A99123E2514000DCD162 /* SDL_sensor_c.h in Headers */, A7D8B9DB23E2514400DCD162 /* SDL_sysrender.h in Headers */, + F316AB922B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A7D8BA3523E2514400DCD162 /* SDL_rotate.h in Headers */, A7D8BB5523E2514500DCD162 /* scancodes_darwin.h in Headers */, A7D8B5BB23E2514300DCD162 /* controller_type.h in Headers */, @@ -6597,7 +6742,6 @@ F386F6F42884663E001840AA /* SDL_utils_c.h in Headers */, A7D8AC9D23E2514100DCD162 /* SDL_uikitwindow.h in Headers */, A7D8B25E23E2514200DCD162 /* vulkan_vi.h in Headers */, - A7D8B29A23E2514200DCD162 /* vulkan_mir.h in Headers */, A7D8BB4F23E2514500DCD162 /* default_cursor.h in Headers */, A7D8B9FF23E2514400DCD162 /* SDL_render_sw_c.h in Headers */, A7D8ABFB23E2514100DCD162 /* SDL_nullvideo.h in Headers */, @@ -6634,11 +6778,13 @@ A7D8AAD823E2514100DCD162 /* SDL_syshaptic.h in Headers */, A7D8AD2123E2514100DCD162 /* SDL_vulkan_internal.h in Headers */, A7D8AF1623E2514100DCD162 /* SDL_cocoaevents.h in Headers */, + F362B9362B33916600D30B94 /* controller_list.h in Headers */, A7D8B25823E2514200DCD162 /* vk_icd.h in Headers */, A7D8ABE923E2514100DCD162 /* SDL_nullframebuffer_c.h in Headers */, A7D8AB2023E2514100DCD162 /* SDL_dynapi_procs.h in Headers */, A7D8B27623E2514200DCD162 /* vulkan_fuchsia.h in Headers */, A7D8B57323E2514300DCD162 /* usb_ids.h in Headers */, + F316ABAD2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8BA5923E2514400DCD162 /* SDL_gles2funcs.h in Headers */, A7D8AC4323E2514100DCD162 /* SDL_sysvideo.h in Headers */, A7D8AB1423E2514100DCD162 /* SDL_dynapi_overrides.h in Headers */, @@ -6661,6 +6807,7 @@ AADA5B8716CCAB3000107CF7 /* SDL_bits.h in Headers */, A7D8BA0123E2514400DCD162 /* SDL_blendfillrect.h in Headers */, A7D8B9E923E2514400DCD162 /* SDL_blendline.h in Headers */, + F316ABC42B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, AA7558041595D4D800BBD41B /* SDL_blendmode.h in Headers */, A7D8BA0D23E2514400DCD162 /* SDL_blendpoint.h in Headers */, A7D8B3B623E2514200DCD162 /* SDL_blit.h in Headers */, @@ -6696,6 +6843,7 @@ A7D8BB3F23E2514500DCD162 /* SDL_displayevents_c.h in Headers */, A7D8BA1923E2514400DCD162 /* SDL_draw.h in Headers */, A7D8BA0723E2514400DCD162 /* SDL_drawline.h in Headers */, + F316ABBB2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8B9EF23E2514400DCD162 /* SDL_drawpoint.h in Headers */, A7D8BB2D23E2514500DCD162 /* SDL_dropevents_c.h in Headers */, A7D8B79423E2514400DCD162 /* SDL_dummyaudio.h in Headers */, @@ -6720,14 +6868,17 @@ A7D8BA7923E2514400DCD162 /* SDL_glfuncs.h in Headers */, AA7558181595D4D800BBD41B /* SDL_haptic.h in Headers */, A7D8AABC23E2514100DCD162 /* SDL_haptic_c.h in Headers */, + F316AB8E2B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A75FDBC523EA380300529352 /* SDL_hidapi_rumble.h in Headers */, A7D8B55723E2514300DCD162 /* SDL_hidapijoystick_c.h in Headers */, AA75581A1595D4D800BBD41B /* SDL_hints.h in Headers */, A7D8B94A23E2514400DCD162 /* SDL_hints_c.h in Headers */, + F316ABCD2B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8A99923E2514000DCD162 /* SDL_internal.h in Headers */, F395C1932569C68F00942BFF /* SDL_iokitjoystick_c.h in Headers */, AA75581E1595D4D800BBD41B /* SDL_joystick.h in Headers */, A7D8B58723E2514300DCD162 /* SDL_joystick_c.h in Headers */, + F316AB852B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, AA7558201595D4D800BBD41B /* SDL_keyboard.h in Headers */, A7D8BB8723E2514500DCD162 /* SDL_keyboard_c.h in Headers */, AA7558221595D4D800BBD41B /* SDL_keycode.h in Headers */, @@ -6798,6 +6949,8 @@ A7D8B5D523E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B61123E2514300DCD162 /* SDL_syspower.h in Headers */, A7D8B9D723E2514400DCD162 /* SDL_sysrender.h in Headers */, + F362B9462B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, + F316ABA92B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8A97B23E2514000DCD162 /* SDL_syssensor.h in Headers */, AA75584E1595D4D800BBD41B /* SDL_system.h in Headers */, A7D8B3E623E2514300DCD162 /* SDL_systhread.h in Headers */, @@ -6836,6 +6989,7 @@ A7D8B9CB23E2514400DCD162 /* SDL_yuv_sw_c.h in Headers */, AA7557FA1595D4D800BBD41B /* begin_code.h in Headers */, A7D8BB4523E2514500DCD162 /* blank_cursor.h in Headers */, + F362B9522B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, AA7557FC1595D4D800BBD41B /* close_code.h in Headers */, A7D8B5B723E2514300DCD162 /* controller_type.h in Headers */, A7D8BB4B23E2514500DCD162 /* default_cursor.h in Headers */, @@ -6846,7 +7000,6 @@ A7D8B22423E2514200DCD162 /* gl2ext.h in Headers */, A7D8B23023E2514200DCD162 /* gl2platform.h in Headers */, A75FDB5823E39E6100529352 /* hidapi.h in Headers */, - A7D8BBD123E2574800DCD162 /* keyinfotable.h in Headers */, A7D8B23623E2514200DCD162 /* khrplatform.h in Headers */, A7D8BB0323E2514500DCD162 /* math_libm.h in Headers */, A7D8BAC123E2514500DCD162 /* math_private.h in Headers */, @@ -6861,16 +7014,15 @@ A7D8B26623E2514200DCD162 /* vk_platform.h in Headers */, A7D8B2AE23E2514200DCD162 /* vk_sdk_platform.h in Headers */, A7D8B26023E2514200DCD162 /* vulkan.h in Headers */, - A7D8B26C23E2514200DCD162 /* vulkan.hpp in Headers */, A7D8B2B423E2514200DCD162 /* vulkan_android.h in Headers */, A7D8B2A823E2514200DCD162 /* vulkan_core.h in Headers */, A7D8B27223E2514200DCD162 /* vulkan_fuchsia.h in Headers */, A7D8B2A223E2514200DCD162 /* vulkan_ios.h in Headers */, A7D8B28423E2514200DCD162 /* vulkan_macos.h in Headers */, - A7D8B29623E2514200DCD162 /* vulkan_mir.h in Headers */, A7D8B25A23E2514200DCD162 /* vulkan_vi.h in Headers */, A7D8B27823E2514200DCD162 /* vulkan_wayland.h in Headers */, A7D8B27E23E2514200DCD162 /* vulkan_win32.h in Headers */, + F362B9322B33916600D30B94 /* controller_list.h in Headers */, A7D8B29023E2514200DCD162 /* vulkan_xcb.h in Headers */, A7D8B29C23E2514200DCD162 /* vulkan_xlib.h in Headers */, A7D8B28A23E2514200DCD162 /* vulkan_xlib_xrandr.h in Headers */, @@ -6885,9 +7037,11 @@ buildActionMask = 2147483647; files = ( A7D8B9A423E2514400DCD162 /* SDL_shaders_metal_tvos.h in Headers */, + F316ABBE2B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8AC0C23E2514100DCD162 /* SDL_shape_internals.h in Headers */, A7D8BA7C23E2514400DCD162 /* SDL_glfuncs.h in Headers */, A7D8AC0623E2514100DCD162 /* SDL_rect_c.h in Headers */, + F362B9352B33916600D30B94 /* controller_list.h in Headers */, 75E09166241EA924004729E1 /* SDL_virtualjoystick_c.h in Headers */, A7D8B99E23E2514400DCD162 /* SDL_shaders_metal_osx.h in Headers */, A7D8B98F23E2514400DCD162 /* SDL_shaders_metal_ios.h in Headers */, @@ -6904,7 +7058,9 @@ A7D8B3EF23E2514300DCD162 /* SDL_thread_c.h in Headers */, A7D8AF0923E2514100DCD162 /* SDL_cocoamessagebox.h in Headers */, A7D8BA0423E2514400DCD162 /* SDL_blendfillrect.h in Headers */, + F362B9552B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, A7D8B55A23E2514300DCD162 /* SDL_hidapijoystick_c.h in Headers */, + F316ABAC2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8B2C323E2514200DCD162 /* SDL_pixels_c.h in Headers */, A7D8B58A23E2514300DCD162 /* SDL_joystick_c.h in Headers */, A75FDB5B23E39E6100529352 /* hidapi.h in Headers */, @@ -6919,13 +7075,13 @@ A7D8B9CE23E2514400DCD162 /* SDL_yuv_sw_c.h in Headers */, A7D8BBFD23E2574800DCD162 /* SDL_uikitvideo.h in Headers */, A7D8BBAE23E2514500DCD162 /* SDL_windowevents_c.h in Headers */, + F316AB912B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A7D8AF0323E2514100DCD162 /* SDL_cocoavideo.h in Headers */, A7D8BB3C23E2514500DCD162 /* SDL_gesture_c.h in Headers */, A7D8BBEF23E2574800DCD162 /* SDL_uikitclipboard.h in Headers */, A7D8BA7623E2514400DCD162 /* SDL_shaders_gl.h in Headers */, A7D8B42B23E2514300DCD162 /* SDL_systhread_c.h in Headers */, A7D8AE9123E2514100DCD162 /* SDL_cocoakeyboard.h in Headers */, - A7D8B26F23E2514200DCD162 /* vulkan.hpp in Headers */, A7D8B22723E2514200DCD162 /* gl2ext.h in Headers */, A7D8BB7223E2514500DCD162 /* SDL_clipboardevents_c.h in Headers */, A7D8AAE323E2514100DCD162 /* SDL_syshaptic_c.h in Headers */, @@ -6962,6 +7118,7 @@ A7D8BBF123E2574800DCD162 /* SDL_uikitevents.h in Headers */, A7D8BBFF23E2574800DCD162 /* SDL_uikitview.h in Headers */, A7D8BBA823E2514500DCD162 /* SDL_events_c.h in Headers */, + F316ABC72B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A7D8BAC423E2514500DCD162 /* math_private.h in Headers */, A7D8B27B23E2514200DCD162 /* vulkan_wayland.h in Headers */, A7D8BBF523E2574800DCD162 /* SDL_uikitmetalview.h in Headers */, @@ -6969,7 +7126,6 @@ A7D8BA5223E2514400DCD162 /* SDL_shaders_gles2.h in Headers */, A7D8BA4623E2514400DCD162 /* SDL_glesfuncs.h in Headers */, A7D8BA1023E2514400DCD162 /* SDL_blendpoint.h in Headers */, - A7D8BBEC23E2574800DCD162 /* keyinfotable.h in Headers */, A7D8AB7023E2514100DCD162 /* SDL_offscreenvideo.h in Headers */, A7D8AC0023E2514100DCD162 /* SDL_nullevents_c.h in Headers */, A7D8B58423E2514300DCD162 /* SDL_sysjoystick.h in Headers */, @@ -6995,11 +7151,12 @@ A7D8B5BA23E2514300DCD162 /* controller_type.h in Headers */, A7D8B29F23E2514200DCD162 /* vulkan_xlib.h in Headers */, A7D8B25D23E2514200DCD162 /* vulkan_vi.h in Headers */, - A7D8B29923E2514200DCD162 /* vulkan_mir.h in Headers */, + F316AB882B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, A1BB8B6F27F6CF330057CFA8 /* SDL_list.h in Headers */, A7D8BB4E23E2514500DCD162 /* default_cursor.h in Headers */, A7D8B9FE23E2514400DCD162 /* SDL_render_sw_c.h in Headers */, A7D8BBED23E2574800DCD162 /* SDL_uikitappdelegate.h in Headers */, + F362B9492B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A7D8BBF923E2574800DCD162 /* SDL_uikitopengles.h in Headers */, F31A92CC28D4CB39003BFD6A /* SDL_offscreenopengles.h in Headers */, A7D8ABFA23E2514100DCD162 /* SDL_nullvideo.h in Headers */, @@ -7020,6 +7177,7 @@ A7D8BB2423E2514500DCD162 /* scancodes_windows.h in Headers */, A7D8B5C623E2514300DCD162 /* SDL_rwopsbundlesupport.h in Headers */, A7D8B61423E2514300DCD162 /* SDL_syspower.h in Headers */, + F316ABD02B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8B28723E2514200DCD162 /* vulkan_macos.h in Headers */, A7D8B29323E2514200DCD162 /* vulkan_xcb.h in Headers */, A7D8B2A523E2514200DCD162 /* vulkan_ios.h in Headers */, @@ -7059,6 +7217,7 @@ DB313FC917554B71006C0E22 /* close_code.h in Headers */, DB313FF917554B71006C0E22 /* SDL.h in Headers */, A7D8AC6223E2514100DCD162 /* SDL_uikitmetalview.h in Headers */, + F362B9582B33EB7300D30B94 /* SDL_steam_virtual_gamepad.h in Headers */, DB313FCA17554B71006C0E22 /* SDL_assert.h in Headers */, A7D8AC0E23E2514100DCD162 /* SDL_shape_internals.h in Headers */, A7D8BA7E23E2514400DCD162 /* SDL_glfuncs.h in Headers */, @@ -7075,7 +7234,6 @@ A7D8AC4A23E2514100DCD162 /* SDL_uikitview.h in Headers */, DB313FFC17554B71006C0E22 /* SDL_bits.h in Headers */, A7D8ACCE23E2514100DCD162 /* SDL_uikitappdelegate.h in Headers */, - A7D8ACA423E2514100DCD162 /* keyinfotable.h in Headers */, DB313FCD17554B71006C0E22 /* SDL_blendmode.h in Headers */, A7D8BB3223E2514500DCD162 /* SDL_dropevents_c.h in Headers */, A7D8AAC123E2514100DCD162 /* SDL_haptic_c.h in Headers */, @@ -7122,18 +7280,19 @@ DB313FDA17554B71006C0E22 /* SDL_keyboard.h in Headers */, A7D8ACC223E2514100DCD162 /* SDL_uikitevents.h in Headers */, A7D8BB3E23E2514500DCD162 /* SDL_gesture_c.h in Headers */, + F362B9382B33916600D30B94 /* controller_list.h in Headers */, A7D8BA7823E2514400DCD162 /* SDL_shaders_gl.h in Headers */, A7D8B42D23E2514300DCD162 /* SDL_systhread_c.h in Headers */, A1BB8B7227F6CF330057CFA8 /* SDL_list.h in Headers */, DB313FDB17554B71006C0E22 /* SDL_keycode.h in Headers */, A7D8AE9323E2514100DCD162 /* SDL_cocoakeyboard.h in Headers */, A7D8ACE623E2514100DCD162 /* SDL_uikitvulkan.h in Headers */, - A7D8B27123E2514200DCD162 /* vulkan.hpp in Headers */, DB313FDC17554B71006C0E22 /* SDL_loadso.h in Headers */, A7D8B22923E2514200DCD162 /* gl2ext.h in Headers */, A7D8BB7423E2514500DCD162 /* SDL_clipboardevents_c.h in Headers */, A7D8AAE523E2514100DCD162 /* SDL_syshaptic_c.h in Headers */, A7D8B94F23E2514400DCD162 /* SDL_hints_c.h in Headers */, + F316ABC12B5A02C3002EF551 /* yuv_rgb_sse.h in Headers */, A7D8B7B723E2514400DCD162 /* SDL_audiodev_c.h in Headers */, A7D8B7A523E2514400DCD162 /* SDL_audio_c.h in Headers */, A7D8AC6E23E2514100DCD162 /* SDL_uikitmodes.h in Headers */, @@ -7147,6 +7306,7 @@ A7D8B2AD23E2514200DCD162 /* vulkan_core.h in Headers */, A7D8A98023E2514000DCD162 /* SDL_syssensor.h in Headers */, A7D8AB0F23E2514100DCD162 /* SDL_dynapi.h in Headers */, + F316ABD32B5A02C3002EF551 /* yuv_rgb_lsx_func.h in Headers */, A7D8B61C23E2514300DCD162 /* SDL_assert_c.h in Headers */, A7D8B8A723E2514400DCD162 /* SDL_diskaudio.h in Headers */, DB313FDE17554B71006C0E22 /* SDL_main.h in Headers */, @@ -7156,6 +7316,7 @@ A7D8AEE123E2514100DCD162 /* SDL_cocoaopengl.h in Headers */, A7D8B3CD23E2514300DCD162 /* yuv_rgb_sse_func.h in Headers */, 5605721B2473688D00B46B66 /* SDL_syslocale.h in Headers */, + F316ABCA2B5A02C3002EF551 /* yuv_rgb_std.h in Headers */, A7D8AB6023E2514100DCD162 /* SDL_offscreenevents_c.h in Headers */, F3973FA828A59BDD00B84553 /* SDL_vacopy.h in Headers */, A1626A582617008D003F1973 /* SDL_triangle.h in Headers */, @@ -7179,6 +7340,8 @@ A7D8BA5423E2514400DCD162 /* SDL_shaders_gles2.h in Headers */, DB313FE417554B71006C0E22 /* SDL_opengles2.h in Headers */, A7D8BA4823E2514400DCD162 /* SDL_glesfuncs.h in Headers */, + F316AB8B2B5A02C3002EF551 /* yuv_rgb_common.h in Headers */, + F316ABAF2B5A02C3002EF551 /* yuv_rgb_lsx.h in Headers */, A7D8BA1223E2514400DCD162 /* SDL_blendpoint.h in Headers */, A7D8AB7223E2514100DCD162 /* SDL_offscreenvideo.h in Headers */, A7D8AC0223E2514100DCD162 /* SDL_nullevents_c.h in Headers */, @@ -7207,7 +7370,6 @@ A7D8B2A123E2514200DCD162 /* vulkan_xlib.h in Headers */, A7D8AC9E23E2514100DCD162 /* SDL_uikitwindow.h in Headers */, A7D8B25F23E2514200DCD162 /* vulkan_vi.h in Headers */, - A7D8B29B23E2514200DCD162 /* vulkan_mir.h in Headers */, DB313FE817554B71006C0E22 /* SDL_quit.h in Headers */, A7D8BB5023E2514500DCD162 /* default_cursor.h in Headers */, A7D8BA0023E2514400DCD162 /* SDL_render_sw_c.h in Headers */, @@ -7268,11 +7430,13 @@ AAC070FE195606770073DCDF /* SDL_opengles2_gl2.h in Headers */, F3950CDA212BC88D00F51292 /* SDL_sensor.h in Headers */, A75FDBCB23EA380300529352 /* SDL_hidapi_rumble.h in Headers */, + F362B94C2B33920500D30B94 /* SDL_hidapi_nintendo.h in Headers */, A7D8AC4423E2514100DCD162 /* SDL_sysvideo.h in Headers */, F386F6ED2884663E001840AA /* SDL_log_c.h in Headers */, AAC07104195606770073DCDF /* SDL_opengles2_gl2platform.h in Headers */, AAC07101195606770073DCDF /* SDL_opengles2_gl2ext.h in Headers */, A7D8AB1523E2514100DCD162 /* SDL_dynapi_overrides.h in Headers */, + F316AB942B5A02C3002EF551 /* yuv_rgb_internal.h in Headers */, A7D8AEFF23E2514100DCD162 /* SDL_cocoawindow.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; @@ -7756,7 +7920,6 @@ A75FCE0223E25AB700529352 /* SDL_log.c in Sources */, A75FCE0323E25AB700529352 /* SDL_cocoaopengl.m in Sources */, A75FCE0423E25AB700529352 /* SDL_offscreenframebuffer.c in Sources */, - A75FCE0523E25AB700529352 /* yuv_rgb.c in Sources */, F323060628939F6400E66D30 /* SDL_hidapi_combined.c in Sources */, A75FCE0623E25AB700529352 /* SDL_render_gles.c in Sources */, A75FCE0723E25AB700529352 /* SDL_systhread.c in Sources */, @@ -7779,6 +7942,7 @@ A75FCE1923E25AB700529352 /* SDL_offscreenevents.c in Sources */, A75FCE1A23E25AB700529352 /* SDL_uikitview.m in Sources */, A75FCE1B23E25AB700529352 /* SDL_nullevents.c in Sources */, + F362B9442B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A75FCE1C23E25AB700529352 /* SDL_audiodev.c in Sources */, A75FCE1D23E25AB700529352 /* SDL_cocoaclipboard.m in Sources */, A75FCE1E23E25AB700529352 /* SDL_blit_slow.c in Sources */, @@ -7842,6 +8006,7 @@ A75FCE5323E25AB700529352 /* SDL_mixer.c in Sources */, 5616CA64252BB35F005D5928 /* SDL_url.c in Sources */, A75FCE5423E25AB700529352 /* SDL_events.c in Sources */, + F316AB9E2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F386F7002884663E001840AA /* SDL_utils.c in Sources */, A75FCE5523E25AB700529352 /* SDL_blit_0.c in Sources */, A75FCE5623E25AB700529352 /* k_tan.c in Sources */, @@ -7858,6 +8023,7 @@ F3ADAB922576F0B400A6B1D9 /* SDL_sysurl.m in Sources */, A75FCE6323E25AB700529352 /* SDL_string.c in Sources */, A75FCE6423E25AB700529352 /* SDL_render_gl.c in Sources */, + F316ABA72B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A75FCE6523E25AB700529352 /* SDL_uikitopengles.m in Sources */, A75FCE6723E25AB700529352 /* SDL_cocoamodes.m in Sources */, A75FCE6823E25AB700529352 /* k_rem_pio2.c in Sources */, @@ -7910,10 +8076,12 @@ A75FCE9B23E25AB700529352 /* SDL_drawpoint.c in Sources */, A75FCE9C23E25AB700529352 /* e_sqrt.c in Sources */, A75FCE9D23E25AB700529352 /* SDL_cocoavideo.m in Sources */, + F362B9622B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A75FCE9F23E25AB700529352 /* SDL.c in Sources */, A75FCEA123E25AB700529352 /* SDL_cocoavulkan.m in Sources */, A75FCEA223E25AB700529352 /* SDL_uikitappdelegate.m in Sources */, A75FCEA323E25AB700529352 /* SDL_offscreenwindow.c in Sources */, + F316ABB92B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -7952,7 +8120,6 @@ A75FCFBB23E25AC700529352 /* SDL_log.c in Sources */, A75FCFBC23E25AC700529352 /* SDL_cocoaopengl.m in Sources */, A75FCFBD23E25AC700529352 /* SDL_offscreenframebuffer.c in Sources */, - A75FCFBE23E25AC700529352 /* yuv_rgb.c in Sources */, F323060728939F6400E66D30 /* SDL_hidapi_combined.c in Sources */, A75FCFBF23E25AC700529352 /* SDL_render_gles.c in Sources */, A75FCFC023E25AC700529352 /* SDL_systhread.c in Sources */, @@ -7975,6 +8142,7 @@ A75FCFD223E25AC700529352 /* SDL_offscreenevents.c in Sources */, A75FCFD323E25AC700529352 /* SDL_uikitview.m in Sources */, A75FCFD423E25AC700529352 /* SDL_nullevents.c in Sources */, + F362B9452B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A75FCFD523E25AC700529352 /* SDL_audiodev.c in Sources */, A75FCFD623E25AC700529352 /* SDL_cocoaclipboard.m in Sources */, A75FCFD723E25AC700529352 /* SDL_blit_slow.c in Sources */, @@ -8038,6 +8206,7 @@ A75FD00C23E25AC700529352 /* SDL_mixer.c in Sources */, 5616CA67252BB361005D5928 /* SDL_url.c in Sources */, A75FD00D23E25AC700529352 /* SDL_events.c in Sources */, + F316AB9F2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F386F7012884663E001840AA /* SDL_utils.c in Sources */, A75FD00E23E25AC700529352 /* SDL_blit_0.c in Sources */, A75FD00F23E25AC700529352 /* k_tan.c in Sources */, @@ -8054,6 +8223,7 @@ F3ADAB932576F0B400A6B1D9 /* SDL_sysurl.m in Sources */, A75FD01C23E25AC700529352 /* SDL_string.c in Sources */, A75FD01D23E25AC700529352 /* SDL_render_gl.c in Sources */, + F316ABA82B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A75FD01E23E25AC700529352 /* SDL_uikitopengles.m in Sources */, A75FD02023E25AC700529352 /* SDL_cocoamodes.m in Sources */, A75FD02123E25AC700529352 /* k_rem_pio2.c in Sources */, @@ -8106,10 +8276,12 @@ A75FD05423E25AC700529352 /* SDL_drawpoint.c in Sources */, A75FD05523E25AC700529352 /* e_sqrt.c in Sources */, A75FD05623E25AC700529352 /* SDL_cocoavideo.m in Sources */, + F362B9632B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A75FD05823E25AC700529352 /* SDL.c in Sources */, A75FD05A23E25AC700529352 /* SDL_cocoavulkan.m in Sources */, A75FD05B23E25AC700529352 /* SDL_uikitappdelegate.m in Sources */, A75FD05C23E25AC700529352 /* SDL_offscreenwindow.c in Sources */, + F316ABBA2B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8140,11 +8312,12 @@ A769B18723E259AE00872273 /* SDL_hidapi_xbox360w.c in Sources */, A769B18823E259AE00872273 /* SDL_atomic.c in Sources */, A769B18923E259AE00872273 /* SDL_displayevents.c in Sources */, + F316ABA52B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A769B18B23E259AE00872273 /* SDL_log.c in Sources */, A769B18C23E259AE00872273 /* SDL_cocoaopengl.m in Sources */, A769B18D23E259AE00872273 /* SDL_offscreenframebuffer.c in Sources */, - A769B18E23E259AE00872273 /* yuv_rgb.c in Sources */, A769B18F23E259AE00872273 /* SDL_render_gles.c in Sources */, + F362B9602B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A769B19023E259AE00872273 /* SDL_systhread.c in Sources */, A769B19123E259AE00872273 /* SDL_windowevents.c in Sources */, A769B19223E259AE00872273 /* s_scalbn.c in Sources */, @@ -8157,6 +8330,7 @@ A769B19A23E259AE00872273 /* SDL_syssem.c in Sources */, A769B19B23E259AE00872273 /* SDL_hidapi_xbox360.c in Sources */, A769B19C23E259AE00872273 /* SDL_coreaudio.m in Sources */, + F362B9422B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A769B19D23E259AE00872273 /* SDL_blendline.c in Sources */, A769B19E23E259AE00872273 /* SDL_blit_A.c in Sources */, A769B19F23E259AE00872273 /* SDL_d3dmath.c in Sources */, @@ -8235,6 +8409,7 @@ A769B1E923E259AE00872273 /* SDL_uikit_main.c in Sources */, F3F07D5F269640160074468B /* SDL_hidapi_luna.c in Sources */, A769B1EA23E259AE00872273 /* SDL_stdlib.c in Sources */, + F316ABB72B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, A769B1EB23E259AE00872273 /* SDL_dummyaudio.c in Sources */, A769B1EC23E259AE00872273 /* SDL_fillrect.c in Sources */, A769B1ED23E259AE00872273 /* SDL_nullframebuffer.c in Sources */, @@ -8250,6 +8425,7 @@ A769B1F923E259AE00872273 /* SDL_joystick.c in Sources */, A769B1FA23E259AE00872273 /* SDL_render_gles2.c in Sources */, A769B1FB23E259AE00872273 /* SDL_surface.c in Sources */, + F316AB9C2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F395BF6A25633B2400942BFF /* SDL_crc32.c in Sources */, A769B1FC23E259AE00872273 /* SDL_hidapi_xboxone.c in Sources */, A769B1FD23E259AE00872273 /* SDL_blit_auto.c in Sources */, @@ -8343,7 +8519,6 @@ A7D8AB2623E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8923E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7423E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, - A7D8B3C023E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA3E23E2514400DCD162 /* SDL_render_gles.c in Sources */, A7D8B43523E2514300DCD162 /* SDL_systhread.c in Sources */, F323060028939F6400E66D30 /* SDL_hidapi_combined.c in Sources */, @@ -8368,6 +8543,7 @@ A7D8ABF223E2514100DCD162 /* SDL_nullevents.c in Sources */, A7D8B81923E2514400DCD162 /* SDL_audiodev.c in Sources */, A7D8AF0D23E2514100DCD162 /* SDL_cocoaclipboard.m in Sources */, + F362B93E2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A7D8ABCE23E2514100DCD162 /* SDL_blit_slow.c in Sources */, A7D8BA9823E2514400DCD162 /* s_copysign.c in Sources */, A7D8AAB723E2514100DCD162 /* SDL_haptic.c in Sources */, @@ -8431,6 +8607,7 @@ A7D8ADE723E2514100DCD162 /* SDL_blit_0.c in Sources */, A7D8BB0A23E2514500DCD162 /* k_tan.c in Sources */, A75FDBCF23EA380300529352 /* SDL_hidapi_rumble.c in Sources */, + F316AB982B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F386F6FA2884663E001840AA /* SDL_utils.c in Sources */, A7D8B8A923E2514400DCD162 /* SDL_diskaudio.c in Sources */, A7D8AFC123E2514200DCD162 /* SDL_egl.c in Sources */, @@ -8447,6 +8624,7 @@ F3ADAB8E2576F0B400A6B1D9 /* SDL_sysurl.m in Sources */, A7D8AC8223E2514100DCD162 /* SDL_uikitopengles.m in Sources */, A7D8AE9523E2514100DCD162 /* SDL_cocoamodes.m in Sources */, + F316ABA12B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8BAA423E2514400DCD162 /* k_rem_pio2.c in Sources */, A7D8BB9A23E2514500DCD162 /* SDL_gesture.c in Sources */, A7D8B95723E2514400DCD162 /* SDL_getenv.c in Sources */, @@ -8499,10 +8677,12 @@ A7D8BA2623E2514400DCD162 /* SDL_drawpoint.c in Sources */, A7D8BAF823E2514500DCD162 /* e_sqrt.c in Sources */, A7D8AEAD23E2514100DCD162 /* SDL_cocoavideo.m in Sources */, + F362B95C2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A7D8A94C23E2514000DCD162 /* SDL.c in Sources */, A7D8AEA123E2514100DCD162 /* SDL_cocoavulkan.m in Sources */, A7D8AC6423E2514100DCD162 /* SDL_uikitappdelegate.m in Sources */, A7D8AB6223E2514100DCD162 /* SDL_offscreenwindow.c in Sources */, + F316ABB32B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8539,7 +8719,6 @@ A7D8AB2723E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8A23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7523E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, - A7D8B3C123E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA3F23E2514400DCD162 /* SDL_render_gles.c in Sources */, A7D8B43623E2514300DCD162 /* SDL_systhread.c in Sources */, F323060128939F6400E66D30 /* SDL_hidapi_combined.c in Sources */, @@ -8564,6 +8743,7 @@ A7D8ABF323E2514100DCD162 /* SDL_nullevents.c in Sources */, A7D8B81A23E2514400DCD162 /* SDL_audiodev.c in Sources */, A7D8AF0E23E2514100DCD162 /* SDL_cocoaclipboard.m in Sources */, + F362B93F2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A7D8ABCF23E2514100DCD162 /* SDL_blit_slow.c in Sources */, A7D8BA9923E2514400DCD162 /* s_copysign.c in Sources */, A7D8AAB823E2514100DCD162 /* SDL_haptic.c in Sources */, @@ -8627,6 +8807,7 @@ A7D8ADE823E2514100DCD162 /* SDL_blit_0.c in Sources */, A7D8BB0B23E2514500DCD162 /* k_tan.c in Sources */, A75FDBD023EA380300529352 /* SDL_hidapi_rumble.c in Sources */, + F316AB992B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F386F6FB2884663E001840AA /* SDL_utils.c in Sources */, A7D8B8AA23E2514400DCD162 /* SDL_diskaudio.c in Sources */, A7D8AFC223E2514200DCD162 /* SDL_egl.c in Sources */, @@ -8643,6 +8824,7 @@ F3ADAB8F2576F0B400A6B1D9 /* SDL_sysurl.m in Sources */, A7D8AC8323E2514100DCD162 /* SDL_uikitopengles.m in Sources */, A7D8AE9623E2514100DCD162 /* SDL_cocoamodes.m in Sources */, + F316ABA22B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8BAA523E2514400DCD162 /* k_rem_pio2.c in Sources */, A7D8BB9B23E2514500DCD162 /* SDL_gesture.c in Sources */, A7D8B95823E2514400DCD162 /* SDL_getenv.c in Sources */, @@ -8695,10 +8877,12 @@ A7D8BA2723E2514400DCD162 /* SDL_drawpoint.c in Sources */, A7D8BAF923E2514500DCD162 /* e_sqrt.c in Sources */, A7D8AEAE23E2514100DCD162 /* SDL_cocoavideo.m in Sources */, + F362B95D2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A7D8A94D23E2514000DCD162 /* SDL.c in Sources */, A7D8AEA223E2514100DCD162 /* SDL_cocoavulkan.m in Sources */, A7D8AC6523E2514100DCD162 /* SDL_uikitappdelegate.m in Sources */, A7D8AB6323E2514100DCD162 /* SDL_offscreenwindow.c in Sources */, + F316ABB42B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8729,11 +8913,12 @@ A7D8B56123E2514300DCD162 /* SDL_hidapi_xbox360w.c in Sources */, A7D8A95B23E2514000DCD162 /* SDL_atomic.c in Sources */, A7D8BB2B23E2514500DCD162 /* SDL_displayevents.c in Sources */, + F316ABA42B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8AB2923E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8C23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7723E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, - A7D8B3C323E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA4123E2514400DCD162 /* SDL_render_gles.c in Sources */, + F362B95F2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, A7D8B43823E2514300DCD162 /* SDL_systhread.c in Sources */, A7D8BB3723E2514500DCD162 /* SDL_windowevents.c in Sources */, A7D8BABF23E2514400DCD162 /* s_scalbn.c in Sources */, @@ -8746,6 +8931,7 @@ A7D8B42623E2514300DCD162 /* SDL_syssem.c in Sources */, A7D8B53D23E2514300DCD162 /* SDL_hidapi_xbox360.c in Sources */, A7D8B8D623E2514400DCD162 /* SDL_coreaudio.m in Sources */, + F362B9412B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A7D8BA2323E2514400DCD162 /* SDL_blendline.c in Sources */, A7D8ADF623E2514100DCD162 /* SDL_blit_A.c in Sources */, A7D8BA3B23E2514400DCD162 /* SDL_d3dmath.c in Sources */, @@ -8824,6 +9010,7 @@ A7D8BC0723E2590800DCD162 /* SDL_uikit_main.c in Sources */, F3F07D5E269640160074468B /* SDL_hidapi_luna.c in Sources */, A7D8B97223E2514400DCD162 /* SDL_stdlib.c in Sources */, + F316ABB62B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, A7D8B79E23E2514400DCD162 /* SDL_dummyaudio.c in Sources */, A7D8B3A823E2514200DCD162 /* SDL_fillrect.c in Sources */, A7D8ABE323E2514100DCD162 /* SDL_nullframebuffer.c in Sources */, @@ -8839,6 +9026,7 @@ A7D8B4E023E2514300DCD162 /* SDL_joystick.c in Sources */, A7D8BA4D23E2514400DCD162 /* SDL_render_gles2.c in Sources */, A7D8AC3123E2514100DCD162 /* SDL_surface.c in Sources */, + F316AB9B2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, F395BF6925633B2400942BFF /* SDL_crc32.c in Sources */, A7D8B54F23E2514300DCD162 /* SDL_hidapi_xboxone.c in Sources */, A7D8AD2723E2514100DCD162 /* SDL_blit_auto.c in Sources */, @@ -8937,7 +9125,6 @@ A7D8AB2523E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8823E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7323E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, - A7D8B3BF23E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA3D23E2514400DCD162 /* SDL_render_gles.c in Sources */, A7D8B43423E2514300DCD162 /* SDL_systhread.c in Sources */, A7D8BB3323E2514500DCD162 /* SDL_windowevents.c in Sources */, @@ -8966,6 +9153,7 @@ A7D8BBE523E2574800DCD162 /* SDL_uikitview.m in Sources */, A7D8BBE923E2574800DCD162 /* SDL_uikitvulkan.m in Sources */, A7D8ABCD23E2514100DCD162 /* SDL_blit_slow.c in Sources */, + F362B93D2B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, A7D8BA9723E2514400DCD162 /* s_copysign.c in Sources */, F3984CD025BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AAB623E2514100DCD162 /* SDL_haptic.c in Sources */, @@ -8974,6 +9162,8 @@ A7D8BBC523E2561500DCD162 /* SDL_steamcontroller.c in Sources */, A7D8AD3223E2514100DCD162 /* SDL_blit_N.c in Sources */, A7D8BB7B23E2514500DCD162 /* SDL_dropevents.c in Sources */, + F362B95B2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, + F316AB972B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, A7D8BACD23E2514500DCD162 /* e_atan2.c in Sources */, A7D8BA8B23E2514400DCD162 /* s_sin.c in Sources */, A7D8BBEB23E2574800DCD162 /* SDL_uikitwindow.m in Sources */, @@ -9047,9 +9237,11 @@ A7D8BB6923E2514500DCD162 /* SDL_keyboard.c in Sources */, A7D8ACE723E2514100DCD162 /* SDL_rect.c in Sources */, A7D8AE9A23E2514100DCD162 /* SDL_cocoaopengles.m in Sources */, + F316ABB22B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, A7D8B96823E2514400DCD162 /* SDL_qsort.c in Sources */, A7D8B55123E2514300DCD162 /* SDL_hidapi_switch.c in Sources */, A7D8B96223E2514400DCD162 /* SDL_strtokr.c in Sources */, + F316ABA02B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8BB7523E2514500DCD162 /* SDL_clipboardevents.c in Sources */, A1BB8B6327F6CF330057CFA8 /* SDL_list.c in Sources */, A7D8BAB523E2514400DCD162 /* k_cos.c in Sources */, @@ -9134,7 +9326,6 @@ A7D8AE8B23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7623E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, 5616CA58252BB35C005D5928 /* SDL_url.c in Sources */, - A7D8B3C223E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA4023E2514400DCD162 /* SDL_render_gles.c in Sources */, A7D8B43723E2514300DCD162 /* SDL_systhread.c in Sources */, F3973FAE28A59BDD00B84553 /* SDL_crc16.c in Sources */, @@ -9161,6 +9352,7 @@ A7D8ABD023E2514100DCD162 /* SDL_blit_slow.c in Sources */, A7D8BA9A23E2514400DCD162 /* s_copysign.c in Sources */, A7D8AAB923E2514100DCD162 /* SDL_haptic.c in Sources */, + F362B9402B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, F3984CD325BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AF2723E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86323E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, @@ -9169,6 +9361,8 @@ A7D8BBFA23E2574800DCD162 /* SDL_uikitopengles.m in Sources */, A7D8BAD023E2514500DCD162 /* e_atan2.c in Sources */, A7D8BA8E23E2514400DCD162 /* s_sin.c in Sources */, + F362B95E2B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, + F316AB9A2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, A7D8B5EA23E2514300DCD162 /* SDL_power.c in Sources */, A7D8AED923E2514100DCD162 /* SDL_cocoakeyboard.m in Sources */, A7D8AB1923E2514100DCD162 /* SDL_dynapi.c in Sources */, @@ -9242,9 +9436,11 @@ A7D8BC0023E2574800DCD162 /* SDL_uikitview.m in Sources */, A7D8AE9D23E2514100DCD162 /* SDL_cocoaopengles.m in Sources */, A7D8B96B23E2514400DCD162 /* SDL_qsort.c in Sources */, + F316ABB52B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, A7D8B55423E2514300DCD162 /* SDL_hidapi_switch.c in Sources */, A7D8B96523E2514400DCD162 /* SDL_strtokr.c in Sources */, A7D8BB7823E2514500DCD162 /* SDL_clipboardevents.c in Sources */, + F316ABA32B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8BAB823E2514400DCD162 /* k_cos.c in Sources */, A1BB8B6627F6CF330057CFA8 /* SDL_list.c in Sources */, A7D8B54823E2514300DCD162 /* SDL_hidapijoystick.c in Sources */, @@ -9326,7 +9522,6 @@ A7D8AB2A23E2514100DCD162 /* SDL_log.c in Sources */, A7D8AE8D23E2514100DCD162 /* SDL_cocoaopengl.m in Sources */, A7D8AB7823E2514100DCD162 /* SDL_offscreenframebuffer.c in Sources */, - A7D8B3C423E2514200DCD162 /* yuv_rgb.c in Sources */, A7D8BA4223E2514400DCD162 /* SDL_render_gles.c in Sources */, 5616CA61252BB35E005D5928 /* SDL_url.c in Sources */, A7D8B43923E2514300DCD162 /* SDL_systhread.c in Sources */, @@ -9356,6 +9551,7 @@ A7D8BA9C23E2514400DCD162 /* s_copysign.c in Sources */, A7D8AABB23E2514100DCD162 /* SDL_haptic.c in Sources */, A7D8AC9223E2514100DCD162 /* SDL_uikitvulkan.m in Sources */, + F362B9432B33920500D30B94 /* SDL_hidapi_steamdeck.c in Sources */, F3984CD625BCC92900374F43 /* SDL_hidapi_stadia.c in Sources */, A7D8AF2923E2514100DCD162 /* SDL_cocoametalview.m in Sources */, A7D8B86523E2514400DCD162 /* SDL_audiotypecvt.c in Sources */, @@ -9364,6 +9560,8 @@ A7D8AD3723E2514100DCD162 /* SDL_blit_N.c in Sources */, A7D8BB8023E2514500DCD162 /* SDL_dropevents.c in Sources */, A7D8BAD223E2514500DCD162 /* e_atan2.c in Sources */, + F362B9612B33EB7300D30B94 /* SDL_steam_virtual_gamepad.c in Sources */, + F316AB9D2B5A02C3002EF551 /* yuv_rgb_std.c in Sources */, A7D8BA9023E2514400DCD162 /* s_sin.c in Sources */, A7D8B5EC23E2514300DCD162 /* SDL_power.c in Sources */, A7D8AEDB23E2514100DCD162 /* SDL_cocoakeyboard.m in Sources */, @@ -9437,9 +9635,11 @@ A7D8ACEC23E2514100DCD162 /* SDL_rect.c in Sources */, A7D8AE9F23E2514100DCD162 /* SDL_cocoaopengles.m in Sources */, A7D8B96D23E2514400DCD162 /* SDL_qsort.c in Sources */, + F316ABB82B5A02C3002EF551 /* yuv_rgb_lsx.c in Sources */, A7D8B55623E2514300DCD162 /* SDL_hidapi_switch.c in Sources */, A7D8B96723E2514400DCD162 /* SDL_strtokr.c in Sources */, A7D8BB7A23E2514500DCD162 /* SDL_clipboardevents.c in Sources */, + F316ABA62B5A02C3002EF551 /* yuv_rgb_sse.c in Sources */, A7D8BABA23E2514400DCD162 /* k_cos.c in Sources */, A1BB8B6927F6CF330057CFA8 /* SDL_list.c in Sources */, A7D8B54A23E2514300DCD162 /* SDL_hidapijoystick.c in Sources */, @@ -9528,8 +9728,8 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEPLOYMENT_POSTPROCESSING = YES; - DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.2.0; + DYLIB_COMPATIBILITY_VERSION = 3001.0.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_ALTIVEC_EXTENSIONS = YES; @@ -9570,7 +9770,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.28.2; + MARKETING_VERSION = 2.30.4; OTHER_LDFLAGS = "-liconv"; }; name = Release; @@ -9613,8 +9813,8 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; DEBUG_INFORMATION_FORMAT = dwarf; - DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.2.0; + DYLIB_COMPATIBILITY_VERSION = 3001.0.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -9656,7 +9856,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_LINK_OBJC_RUNTIME = NO; - MARKETING_VERSION = 2.28.2; + MARKETING_VERSION = 2.30.4; OTHER_LDFLAGS = "-liconv"; }; name = Debug; @@ -9862,8 +10062,8 @@ CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.2.0; + DYLIB_COMPATIBILITY_VERSION = 3001.0.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; @@ -9914,8 +10114,8 @@ CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; - DYLIB_COMPATIBILITY_VERSION = 2801.0.0; - DYLIB_CURRENT_VERSION = 2801.2.0; + DYLIB_COMPATIBILITY_VERSION = 3001.0.0; + DYLIB_CURRENT_VERSION = 3001.4.0; DYLIB_INSTALL_NAME_BASE = "@rpath"; ENABLE_NS_ASSERTIONS = NO; GCC_C_LANGUAGE_STANDARD = gnu11; diff --git a/vs/sdl2/Xcode/SDL/pkg-support/SDL.info b/vs/sdl2/Xcode/SDL/pkg-support/SDL.info index f436dfd372..87eff0c52b 100644 --- a/vs/sdl2/Xcode/SDL/pkg-support/SDL.info +++ b/vs/sdl2/Xcode/SDL/pkg-support/SDL.info @@ -1,4 +1,4 @@ -Title SDL 2.28.2 +Title SDL 2.30.4 Version 1 Description SDL Library for Mac OS X (http://www.libsdl.org) DefaultLocation /Library/Frameworks diff --git a/vs/sdl2/Xcode/SDL/pkg-support/resources/CMake/sdl2-config.cmake b/vs/sdl2/Xcode/SDL/pkg-support/resources/CMake/sdl2-config.cmake index e1b77133b5..9205d1f2b8 100644 --- a/vs/sdl2/Xcode/SDL/pkg-support/resources/CMake/sdl2-config.cmake +++ b/vs/sdl2/Xcode/SDL/pkg-support/resources/CMake/sdl2-config.cmake @@ -31,8 +31,15 @@ endmacro() set(SDL2_FOUND TRUE) -string(REGEX REPLACE "SDL2\\.framework.*" "SDL2.framework" SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") -string(REGEX REPLACE "SDL2\\.framework.*" "" SDL2_FRAMEWORK_PARENT_PATH "${CMAKE_CURRENT_LIST_DIR}") +# Compute the installation prefix relative to this file. +set(SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}") # > /SDL2.framework/Resources/CMake/ +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/Current/Resources/CMake +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" REALPATH) # > /SDL2.framework/Versions/A/Resources/CMake/ +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/Resources/ +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/A/ +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/Versions/ +get_filename_component(SDL2_FRAMEWORK_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > /SDL2.framework/ +get_filename_component(SDL2_FRAMEWORK_PARENT_PATH "${SDL2_FRAMEWORK_PATH}" PATH) # > / # For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables. @@ -49,12 +56,12 @@ set(SDL2_LIBRARIES "SDL2::SDL2") # This is done for compatibility with CMake generated SDL2-target.cmake files. if(NOT TARGET SDL2::SDL2) - add_library(SDL2::SDL2 INTERFACE IMPORTED) + add_library(SDL2::SDL2 SHARED IMPORTED) set_target_properties(SDL2::SDL2 PROPERTIES - INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\"" + FRAMEWORK "TRUE" + IMPORTED_LOCATION "${SDL2_FRAMEWORK_PATH}/Versions/A/SDL2" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" - INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2" COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED" INTERFACE_SDL2_SHARED "ON" COMPATIBLE_INTERFACE_STRING "SDL_VERSION" diff --git a/vs/sdl2/Xcode/SDL/pkg-support/resources/License.txt b/vs/sdl2/Xcode/SDL/pkg-support/resources/License.txt index 523c51e496..42f37361d4 100644 --- a/vs/sdl2/Xcode/SDL/pkg-support/resources/License.txt +++ b/vs/sdl2/Xcode/SDL/pkg-support/resources/License.txt @@ -1,6 +1,6 @@ Simple DirectMedia Layer -Copyright (C) 1997-2023 Sam Lantinga +Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj b/vs/sdl2/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj index 1d5183a7da..543d100d79 100644 --- a/vs/sdl2/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj +++ b/vs/sdl2/Xcode/SDLTest/SDLTest.xcodeproj/project.pbxproj @@ -155,6 +155,100 @@ DBEC54ED1A1A828A005B1EAB /* axis.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBEC54D61A1A8145005B1EAB /* axis.bmp */; }; DBEC54EE1A1A828D005B1EAB /* button.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBEC54D71A1A8145005B1EAB /* button.bmp */; }; DBEC54EF1A1A828F005B1EAB /* controllermap.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBEC54D81A1A8145005B1EAB /* controllermap.bmp */; }; + F3A249DB2B389C7A00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249DC2B389C7A00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249DE2B389CCA00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249DF2B389CCA00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249E12B389CDB00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249E22B389CDB00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249E42B389CE700A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249E52B389CE700A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249E72B389CF000A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249E82B389CF000A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249EA2B389CFB00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249EB2B389CFB00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249ED2B389D0900A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249EE2B389D0900A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249F02B389D3100A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249F12B389D3100A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249F32B389D3B00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249F42B389D3B00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249F62B389D4400A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249F72B389D4400A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249F92B389D5200A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249FA2B389D5200A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249FC2B389D5B00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A249FD2B389D5B00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A249FF2B389D6600A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A002B389D6600A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A022B389D6F00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A032B389D6F00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A052B389D7C00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A062B389D7C00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A082B389D8A00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A092B389D8A00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A0B2B389D9B00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A0C2B389D9B00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A0E2B389DA800A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A0F2B389DA800A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A112B389DB400A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A122B389DB400A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A142B389DC000A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A152B389DC000A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A172B389DCA00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A182B389DCA00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A1A2B389DD600A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A1B2B389DD600A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A1D2B389DE100A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A1E2B389DE100A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A202B389DEB00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A212B389DEB00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A232B389DF500A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A242B389DF500A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A262B389DFF00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A272B389DFF00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A292B389E0900A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A2A2B389E0900A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A2C2B389E1400A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A2D2B389E1400A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A302B389E2800A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A312B389E2800A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A332B389E3200A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A342B389E3200A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A362B389E4F00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A372B389E4F00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A392B389E5D00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A3A2B389E5D00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A3C2B389E6600A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A3D2B389E6600A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A3F2B389E7200A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A402B389E7200A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A422B389E7C00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A432B389E7C00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A452B389E8700A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A462B389E8700A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A482B389E9100A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A492B389E9100A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A4B2B389E9C00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A4C2B389E9C00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A4E2B389EA500A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A4F2B389EA500A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A512B389EB600A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A522B389EB600A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A542B389EC200A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A552B389EC200A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A572B389ECD00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A582B389ECD00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A5A2B389ED800A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A5B2B389ED800A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A5D2B389EE200A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A5E2B389EE200A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A602B389EED00A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A612B389EED00A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A632B389EF900A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A642B389EF900A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + F3A24A662B389F0400A5162D /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; }; + F3A24A672B389F0400A5162D /* SDL2.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA643093FFD41000C53B3 /* SDL2.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; F3C17C6B28E4022A00E1A26D /* libSDL_test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DB166D7F16A1D12400A1396C /* libSDL_test.a */; }; F3C17C7428E40AF000E1A26D /* testutils.c in Sources */ = {isa = PBXBuildFile; fileRef = F3C17C7328E40ADE00E1A26D /* testutils.c */; }; F3C17C7628E40BA200E1A26D /* controllermap_back.bmp in CopyFiles */ = {isa = PBXBuildFile; fileRef = F3C17C7528E40B6B00E1A26D /* controllermap_back.bmp */; }; @@ -727,47 +821,564 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + F3A249DD2B389C7A00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249DC2B389C7A00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249E02B389CCA00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249DF2B389CCA00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249E32B389CDB00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249E22B389CDB00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249E62B389CE700A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249E52B389CE700A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249E92B389CF000A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249E82B389CF000A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249EC2B389CFB00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249EB2B389CFB00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249EF2B389D0900A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249EE2B389D0900A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249F22B389D3100A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249F12B389D3100A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249F52B389D3B00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249F42B389D3B00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249F82B389D4400A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249F72B389D4400A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249FB2B389D5200A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249FA2B389D5200A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A249FE2B389D5B00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A249FD2B389D5B00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A012B389D6600A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A002B389D6600A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A042B389D6F00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A032B389D6F00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A072B389D7C00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A062B389D7C00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A0A2B389D8A00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A092B389D8A00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A0D2B389D9B00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A0C2B389D9B00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A102B389DA800A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A0F2B389DA800A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A132B389DB400A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A122B389DB400A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A162B389DC000A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A152B389DC000A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A192B389DCA00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A182B389DCA00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A1C2B389DD600A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A1B2B389DD600A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A1F2B389DE100A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A1E2B389DE100A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A222B389DEB00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A212B389DEB00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A252B389DF500A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A242B389DF500A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A282B389E0000A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A272B389DFF00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A2B2B389E0900A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A2A2B389E0900A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A2E2B389E1500A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A2D2B389E1400A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A322B389E2800A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A312B389E2800A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A352B389E3200A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A342B389E3200A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A382B389E4F00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A372B389E4F00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A3B2B389E5D00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A3A2B389E5D00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A3E2B389E6600A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A3D2B389E6600A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A412B389E7200A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A402B389E7200A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A442B389E7C00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A432B389E7C00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A472B389E8700A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A462B389E8700A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A4A2B389E9100A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A492B389E9100A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A4D2B389E9C00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A4C2B389E9C00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A502B389EA600A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A4F2B389EA500A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A532B389EB600A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A522B389EB600A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A562B389EC200A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A552B389EC200A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A592B389ECD00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A582B389ECD00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A5C2B389ED800A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A5B2B389ED800A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A5F2B389EE200A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A5E2B389EE200A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A622B389EED00A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A612B389EED00A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A652B389EF900A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A642B389EF900A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; + F3A24A682B389F0400A5162D /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + F3A24A672B389F0400A5162D /* SDL2.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 0017958C10741F7900F5D044 /* testatomic */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testatomic; path = testatomic.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017958C10741F7900F5D044 /* testatomic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testatomic.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0017958F1074216E00F5D044 /* testatomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testatomic.c; sourceTree = ""; }; - 001795AD107421BF00F5D044 /* testaudioinfo */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testaudioinfo; path = testaudioinfo.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001795AD107421BF00F5D044 /* testaudioinfo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testaudioinfo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001795B01074222D00F5D044 /* testaudioinfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testaudioinfo.c; sourceTree = ""; }; 0017972110742F3200F5D044 /* testgl2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgl2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0017972710742FB900F5D044 /* testgl2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testgl2.c; sourceTree = ""; }; - 00179748107430D600F5D044 /* testhaptic */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testhaptic; path = testhaptic.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 00179748107430D600F5D044 /* testhaptic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testhaptic.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0017974E1074315700F5D044 /* testhaptic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testhaptic.c; sourceTree = ""; }; - 0017976E107431B300F5D044 /* testdraw2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testdraw2; path = testdraw2.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017976E107431B300F5D044 /* testdraw2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdraw2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001797711074320D00F5D044 /* testdraw2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testdraw2.c; sourceTree = ""; }; - 0017978E107432AE00F5D044 /* testime */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testime; path = testime.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017978E107432AE00F5D044 /* testime.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testime.app; sourceTree = BUILT_PRODUCTS_DIR; }; 00179791107432FA00F5D044 /* testime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testime.c; sourceTree = ""; }; - 001797AE1074334C00F5D044 /* testintersections */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testintersections; path = testintersections.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001797AE1074334C00F5D044 /* testintersections.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testintersections.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001797B31074339C00F5D044 /* testintersections.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testintersections.c; sourceTree = ""; }; - 001797D0107433C600F5D044 /* testloadso */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testloadso; path = testloadso.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001797D0107433C600F5D044 /* testloadso.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testloadso.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001797D31074343E00F5D044 /* testloadso.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testloadso.c; sourceTree = ""; }; - 001798121074355200F5D044 /* testmultiaudio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testmultiaudio; path = testmultiaudio.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798121074355200F5D044 /* testmultiaudio.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testmultiaudio.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001798151074359B00F5D044 /* testmultiaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testmultiaudio.c; sourceTree = ""; }; 0017985A107436ED00F5D044 /* testnative.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testnative.c; sourceTree = ""; }; 0017985B107436ED00F5D044 /* testnative.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = testnative.h; sourceTree = ""; }; 0017985C107436ED00F5D044 /* testnativecocoa.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = testnativecocoa.m; sourceTree = ""; }; 00179872107438D000F5D044 /* testnativex11.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testnativex11.c; sourceTree = ""; }; 001798941074392D00F5D044 /* testnative.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testnative.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 001798B5107439DF00F5D044 /* testpower */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testpower; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798B5107439DF00F5D044 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001798B910743A4900F5D044 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testpower.c; sourceTree = ""; }; - 001798F210743BEC00F5D044 /* testresample */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testresample; path = testresample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 001798F210743BEC00F5D044 /* testresample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testresample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 001798F910743E9200F5D044 /* testresample.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testresample.c; sourceTree = ""; }; - 0017991610743F1000F5D044 /* testsprite2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testsprite2; path = testsprite2.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017991610743F1000F5D044 /* testsprite2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testsprite2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0017991910743F5300F5D044 /* testsprite2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testsprite2.c; sourceTree = ""; }; - 0017993810743FB700F5D044 /* testwm2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testwm2; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0017993810743FB700F5D044 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0017993B10743FEF00F5D044 /* testwm2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testwm2.c; sourceTree = ""; }; - 002F341209CA1BFF00EBEB88 /* testfile */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testfile; path = testfile.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F341209CA1BFF00EBEB88 /* testfile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testfile.app; sourceTree = BUILT_PRODUCTS_DIR; }; 002F341709CA1C5B00EBEB88 /* testfile.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testfile.c; sourceTree = ""; }; - 002F343109CA1F0300EBEB88 /* testiconv */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testiconv; path = testiconv.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F343109CA1F0300EBEB88 /* testiconv.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testiconv.app; sourceTree = BUILT_PRODUCTS_DIR; }; 002F343609CA1F6F00EBEB88 /* testiconv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testiconv.c; sourceTree = ""; }; - 002F344D09CA1FB300EBEB88 /* testoverlay2 */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testoverlay2; path = testoverlay2.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F344D09CA1FB300EBEB88 /* testoverlay2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testoverlay2.app; sourceTree = BUILT_PRODUCTS_DIR; }; 002F345209CA201C00EBEB88 /* testoverlay2.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testoverlay2.c; sourceTree = ""; }; - 002F346A09CA204F00EBEB88 /* testplatform */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testplatform; path = testplatform.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 002F346A09CA204F00EBEB88 /* testplatform.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testplatform.app; sourceTree = BUILT_PRODUCTS_DIR; }; 002F346F09CA20A600EBEB88 /* testplatform.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testplatform.c; sourceTree = ""; }; 003FA63A093FFD41000C53B3 /* SDL.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL.xcodeproj; path = ../SDL/SDL.xcodeproj; sourceTree = SOURCE_ROOT; }; 00794E5D09D20839003FC8A1 /* icon.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = icon.bmp; sourceTree = ""; }; @@ -787,27 +1398,27 @@ 092D6D62FFB312AA7F000001 /* testjoystick.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testjoystick.c; sourceTree = ""; }; 092D6D6CFFB313437F000001 /* testkeys.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testkeys.c; sourceTree = ""; }; 092D6D75FFB313BB7F000001 /* testlock.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; path = testlock.c; sourceTree = ""; }; - 4537749212091504002F0F45 /* testshape */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testshape; path = testshape.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 4537749212091504002F0F45 /* testshape.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshape.app; sourceTree = BUILT_PRODUCTS_DIR; }; 453774A4120915E3002F0F45 /* testshape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testshape.c; sourceTree = ""; }; 66E88E8A203B778F0004D44E /* testyuv_cvt.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testyuv_cvt.c; sourceTree = ""; }; AAF02FF41F90089800B9A9FB /* SDL_test_memory.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_memory.c; sourceTree = ""; }; BBFC088E164C6820003E6A99 /* testgamecontroller.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testgamecontroller.c; sourceTree = ""; }; - BBFC08CD164C6862003E6A99 /* testgamecontroller */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testgamecontroller; path = testgamecontroller.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC566B60761D90300A33029 /* checkkeys */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = checkkeys; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC566D10761D90300A33029 /* loopwave */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = loopwave; path = loopwave.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567060761D90400A33029 /* testerror */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testerror; path = testerror.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5672E0761D90400A33029 /* testthread */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testthread; path = testthread.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5673B0761D90400A33029 /* testjoystick */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testjoystick; path = testjoystick.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567480761D90400A33029 /* testkeys */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testkeys; path = testkeys.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567550761D90400A33029 /* testlock */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testlock; path = testlock.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC5677D0761D90500A33029 /* testsem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testsem; path = testsem.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567980761D90500A33029 /* testtimer */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testtimer; path = testtimer.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567B20761D90500A33029 /* testversion */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testversion; path = testversion.app; sourceTree = BUILT_PRODUCTS_DIR; }; - BEC567F50761D90600A33029 /* torturethread */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = torturethread; path = torturethread.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BBFC08CD164C6862003E6A99 /* testgamecontroller.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgamecontroller.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC566B60761D90300A33029 /* checkkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = checkkeys.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC566D10761D90300A33029 /* loopwave.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = loopwave.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567060761D90400A33029 /* testerror.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testerror.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5672E0761D90400A33029 /* testthread.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testthread.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5673B0761D90400A33029 /* testjoystick.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testjoystick.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567480761D90400A33029 /* testkeys.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testkeys.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567550761D90400A33029 /* testlock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testlock.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC5677D0761D90500A33029 /* testsem.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testsem.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567980761D90500A33029 /* testtimer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testtimer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567B20761D90500A33029 /* testversion.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testversion.app; sourceTree = BUILT_PRODUCTS_DIR; }; + BEC567F50761D90600A33029 /* torturethread.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = torturethread.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB0F48D717CA51D2008798C5 /* testdrawchessboard.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testdrawchessboard.c; sourceTree = ""; }; DB0F48D817CA51D2008798C5 /* testfilesystem.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testfilesystem.c; sourceTree = ""; }; - DB0F48EC17CA51E5008798C5 /* testdrawchessboard */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testdrawchessboard; path = testdrawchessboard.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB0F490117CA5212008798C5 /* testfilesystem */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testfilesystem; path = testfilesystem.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F48EC17CA51E5008798C5 /* testdrawchessboard.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdrawchessboard.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB0F490117CA5212008798C5 /* testfilesystem.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testfilesystem.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB166CBB16A1C74100A1396C /* testgesture.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testgesture.c; sourceTree = ""; }; DB166CBC16A1C74100A1396C /* testgles.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testgles.c; sourceTree = ""; }; DB166CBD16A1C74100A1396C /* testmessage.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testmessage.c; sourceTree = ""; }; @@ -835,27 +1446,28 @@ DB166D9016A1D1A500A1396C /* SDL_test_log.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_log.c; sourceTree = ""; }; DB166D9116A1D1A500A1396C /* SDL_test_md5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_md5.c; sourceTree = ""; }; DB166D9216A1D1A500A1396C /* SDL_test_random.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_test_random.c; sourceTree = ""; }; - DB166DBF16A1D2F600A1396C /* testgesture */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testgesture; path = testgesture.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166DD516A1D36A00A1396C /* testmessage */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testmessage; path = testmessage.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166DEE16A1D50C00A1396C /* testrelative */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testrelative; path = testrelative.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E0516A1D57C00A1396C /* testrendercopyex */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testrendercopyex; path = testrendercopyex.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E1C16A1D5AD00A1396C /* testrendertarget */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testrendertarget; path = testrendertarget.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E3816A1D64D00A1396C /* testrumble */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testrumble; path = testrumble.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E5216A1D69000A1396C /* testscale */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testscale; path = testscale.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E6816A1D6F300A1396C /* testshader */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testshader; path = testshader.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E7E16A1D78400A1396C /* testspriteminimal */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testspriteminimal; path = testspriteminimal.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DB166E9116A1D78C00A1396C /* teststreaming */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = teststreaming; path = teststreaming.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166DBF16A1D2F600A1396C /* testgesture.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testgesture.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166DD516A1D36A00A1396C /* testmessage.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testmessage.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166DEE16A1D50C00A1396C /* testrelative.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testrelative.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E0516A1D57C00A1396C /* testrendercopyex.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testrendercopyex.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E1C16A1D5AD00A1396C /* testrendertarget.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testrendertarget.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E3816A1D64D00A1396C /* testrumble.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testrumble.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E5216A1D69000A1396C /* testscale.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testscale.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E6816A1D6F300A1396C /* testshader.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testshader.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E7E16A1D78400A1396C /* testspriteminimal.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testspriteminimal.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB166E9116A1D78C00A1396C /* teststreaming.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = teststreaming.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB166ECF16A1D87000A1396C /* shapes */ = {isa = PBXFileReference; lastKnownFileType = folder; path = shapes; sourceTree = ""; }; DB445EF818184B7000B306B0 /* testdropfile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testdropfile.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB445EFA18184BB600B306B0 /* testdropfile.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testdropfile.c; sourceTree = ""; }; - DB89957E18A19ABA0092407C /* testhotplug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = testhotplug; path = testhotplug.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DB89957E18A19ABA0092407C /* testhotplug.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testhotplug.app; sourceTree = BUILT_PRODUCTS_DIR; }; DB89958318A19B130092407C /* testhotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = testhotplug.c; sourceTree = ""; }; DBBC552C182831D700F3CA8D /* TestDropFile-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestDropFile-Info.plist"; sourceTree = SOURCE_ROOT; }; DBEC54D11A1A811D005B1EAB /* controllermap.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = controllermap.c; sourceTree = ""; }; DBEC54D61A1A8145005B1EAB /* axis.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = axis.bmp; sourceTree = ""; }; DBEC54D71A1A8145005B1EAB /* button.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = button.bmp; sourceTree = ""; }; DBEC54D81A1A8145005B1EAB /* controllermap.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = controllermap.bmp; sourceTree = ""; }; - DBEC54EA1A1A81C3005B1EAB /* controllermap */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = controllermap; path = controllermap.app; sourceTree = BUILT_PRODUCTS_DIR; }; + DBEC54EA1A1A81C3005B1EAB /* controllermap.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = controllermap.app; sourceTree = BUILT_PRODUCTS_DIR; }; + F3A24A2F2B389E1D00A5162D /* testoverlay2-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "testoverlay2-Info.plist"; sourceTree = ""; }; F3C17C6A28E3FD4400E1A26D /* config.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = config.xcconfig; sourceTree = ""; }; F3C17C7328E40ADE00E1A26D /* testutils.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = testutils.c; sourceTree = ""; }; F3C17C7528E40B6B00E1A26D /* controllermap_back.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = controllermap_back.bmp; sourceTree = ""; }; @@ -869,6 +1481,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249E72B389CF000A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -876,6 +1489,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249EA2B389CFB00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -884,6 +1498,7 @@ buildActionMask = 2147483647; files = ( DB166DA316A1D1FA00A1396C /* libSDL_test.a in Frameworks */, + F3A24A082B389D8A00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -891,6 +1506,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A0B2B389D9B00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -899,6 +1515,7 @@ buildActionMask = 2147483647; files = ( DB166DA216A1D1E900A1396C /* libSDL_test.a in Frameworks */, + F3A249ED2B389D0900A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -907,6 +1524,7 @@ buildActionMask = 2147483647; files = ( DB166DA716A1D24D00A1396C /* libSDL_test.a in Frameworks */, + F3A24A142B389DC000A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -915,6 +1533,7 @@ buildActionMask = 2147483647; files = ( DB166DAA16A1D27700A1396C /* libSDL_test.a in Frameworks */, + F3A24A172B389DCA00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -922,6 +1541,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A202B389DEB00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -929,6 +1549,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A292B389E0900A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -936,6 +1557,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A2C2B389E1400A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -943,6 +1565,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A362B389E4F00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -950,6 +1573,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A422B389E7C00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -958,6 +1582,7 @@ buildActionMask = 2147483647; files = ( DB166DAB16A1D27C00A1396C /* libSDL_test.a in Frameworks */, + F3A249DB2B389C7A00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -966,6 +1591,7 @@ buildActionMask = 2147483647; files = ( DB166DAC16A1D29000A1396C /* libSDL_test.a in Frameworks */, + F3A24A632B389EF900A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -973,6 +1599,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249F92B389D5200A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -980,6 +1607,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A112B389DB400A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -987,6 +1615,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A302B389E2800A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -994,6 +1623,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A332B389E3200A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1002,6 +1632,7 @@ buildActionMask = 2147483647; files = ( DB166DA416A1D21700A1396C /* libSDL_test.a in Frameworks */, + F3A24A512B389EB600A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1009,6 +1640,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249FF2B389D6600A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1017,6 +1649,7 @@ buildActionMask = 2147483647; files = ( F3C17C6B28E4022A00E1A26D /* libSDL_test.a in Frameworks */, + F3A249DE2B389CCA00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1024,6 +1657,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249E42B389CE700A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1031,6 +1665,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249F62B389D4400A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1038,6 +1673,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A5A2B389ED800A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1045,6 +1681,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A1A2B389DD600A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1052,6 +1689,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A1D2B389DE100A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1059,6 +1697,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A232B389DF500A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1066,6 +1705,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A4B2B389E9C00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1073,6 +1713,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A5D2B389EE200A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1080,6 +1721,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A602B389EED00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1087,6 +1729,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A662B389F0400A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1094,6 +1737,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249F02B389D3100A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1101,6 +1745,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249FC2B389D5B00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1116,6 +1761,7 @@ buildActionMask = 2147483647; files = ( F3C17C7A28E40CA600E1A26D /* libSDL_test.a in Frameworks */, + F3A24A052B389D7C00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1123,6 +1769,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A262B389DFF00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1131,6 +1778,7 @@ buildActionMask = 2147483647; files = ( DB166DEA16A1D50C00A1396C /* libSDL_test.a in Frameworks */, + F3A24A392B389E5D00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1139,6 +1787,7 @@ buildActionMask = 2147483647; files = ( DB166E0116A1D57C00A1396C /* libSDL_test.a in Frameworks */, + F3A24A3C2B389E6600A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1147,6 +1796,7 @@ buildActionMask = 2147483647; files = ( DB166E1816A1D5AD00A1396C /* libSDL_test.a in Frameworks */, + F3A24A3F2B389E7200A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1154,6 +1804,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A452B389E8700A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1162,6 +1813,7 @@ buildActionMask = 2147483647; files = ( DB166E4B16A1D69000A1396C /* libSDL_test.a in Frameworks */, + F3A24A482B389E9100A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1169,6 +1821,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A4E2B389EA500A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1176,6 +1829,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A542B389EC200A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1183,6 +1837,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A572B389ECD00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1191,6 +1846,7 @@ buildActionMask = 2147483647; files = ( DB445EF418184B7000B306B0 /* libSDL_test.a in Frameworks */, + F3A249F32B389D3B00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1198,6 +1854,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A24A0E2B389DA800A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1205,6 +1862,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F3A249E12B389CDB00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1213,6 +1871,7 @@ buildActionMask = 2147483647; files = ( F3C17CED28E417F400E1A26D /* libSDL_test.a in Frameworks */, + F3A24A022B389D6F00A5162D /* SDL2.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1260,12 +1919,14 @@ 08FB7794FE84155DC02AAC07 /* SDLTest */ = { isa = PBXGroup; children = ( + F3A24A2F2B389E1D00A5162D /* testoverlay2-Info.plist */, F3C17C6A28E3FD4400E1A26D /* config.xcconfig */, 003FA63A093FFD41000C53B3 /* SDL.xcodeproj */, 08FB7795FE84155DC02AAC07 /* Source */, DB166D8316A1D17E00A1396C /* SDL_Test */, 00794E4609D207B4003FC8A1 /* Resources */, 1AB674ADFE9D54B511CA2CBB /* Products */, + F3A249CF2B389C7A00A5162D /* Frameworks */, ); comments = "I made these tests link against our \"default\" framework which includes X11 stuff. If you didn't install the X11 headers with Xcode, you might have problems building the SDL.framework (which is a dependency). You can swap the dependencies around to get around this, or you can modify the default SDL.framework target to not include X11 stuff. (Go into its target build options and remove all the Preprocessor macros.)\n\n\n\nWe are sort of in a half-way state at the moment. Going \"all-the-way\" means we copy the SDL.framework inside the app bundle so we can run the test without the step of the user \"installing\" the framework. But there is an oversight/bug in Xcode that doesn't correctly find the location of the framework when in an embedded/nested Xcode project. We could probably try to hack this with a shell script that checks multiple directories for existence, but this is messier and more work than I prefer, so I rather just wait for Apple to fix this. In the meantime...\n\nThe \"All\" target will build the SDL framework from the Xcode project. The other targets do not have this dependency set (for flexibility reasons in case we make changes). If you have not built the framework, you will probably be unable to link. You will either need to build the framework, or you need to add \"-framework SDL\" to the link options and make sure you have the SDL.framework installed somewhere where it can be seen (like /Library/Frameworks...I think we already set this one up.) \n\nTo run though, you should have a copy of the SDL.framework in /Library/Frameworks or ~/Library/Frameworks.\n\n\n\n\ntestgl and testdyngl need -DHAVE_OPENGL\ntestgl needs to link against OpenGL.framework\n\n"; name = SDLTest; @@ -1336,53 +1997,53 @@ 1AB674ADFE9D54B511CA2CBB /* Products */ = { isa = PBXGroup; children = ( - BEC566B60761D90300A33029 /* checkkeys */, - BEC566D10761D90300A33029 /* loopwave */, - BEC567060761D90400A33029 /* testerror */, - BEC5672E0761D90400A33029 /* testthread */, - BEC5673B0761D90400A33029 /* testjoystick */, - BEC567480761D90400A33029 /* testkeys */, - BEC567550761D90400A33029 /* testlock */, - BEC5677D0761D90500A33029 /* testsem */, - BEC567980761D90500A33029 /* testtimer */, - BEC567B20761D90500A33029 /* testversion */, - BEC567F50761D90600A33029 /* torturethread */, - 002F341209CA1BFF00EBEB88 /* testfile */, - 002F343109CA1F0300EBEB88 /* testiconv */, - 002F344D09CA1FB300EBEB88 /* testoverlay2 */, - 002F346A09CA204F00EBEB88 /* testplatform */, - 0017958C10741F7900F5D044 /* testatomic */, - 001795AD107421BF00F5D044 /* testaudioinfo */, + BEC566B60761D90300A33029 /* checkkeys.app */, + BEC566D10761D90300A33029 /* loopwave.app */, + BEC567060761D90400A33029 /* testerror.app */, + BEC5672E0761D90400A33029 /* testthread.app */, + BEC5673B0761D90400A33029 /* testjoystick.app */, + BEC567480761D90400A33029 /* testkeys.app */, + BEC567550761D90400A33029 /* testlock.app */, + BEC5677D0761D90500A33029 /* testsem.app */, + BEC567980761D90500A33029 /* testtimer.app */, + BEC567B20761D90500A33029 /* testversion.app */, + BEC567F50761D90600A33029 /* torturethread.app */, + 002F341209CA1BFF00EBEB88 /* testfile.app */, + 002F343109CA1F0300EBEB88 /* testiconv.app */, + 002F344D09CA1FB300EBEB88 /* testoverlay2.app */, + 002F346A09CA204F00EBEB88 /* testplatform.app */, + 0017958C10741F7900F5D044 /* testatomic.app */, + 001795AD107421BF00F5D044 /* testaudioinfo.app */, 0017972110742F3200F5D044 /* testgl2.app */, - 00179748107430D600F5D044 /* testhaptic */, - 0017976E107431B300F5D044 /* testdraw2 */, - 0017978E107432AE00F5D044 /* testime */, - 001797AE1074334C00F5D044 /* testintersections */, - 001797D0107433C600F5D044 /* testloadso */, - 001798121074355200F5D044 /* testmultiaudio */, + 00179748107430D600F5D044 /* testhaptic.app */, + 0017976E107431B300F5D044 /* testdraw2.app */, + 0017978E107432AE00F5D044 /* testime.app */, + 001797AE1074334C00F5D044 /* testintersections.app */, + 001797D0107433C600F5D044 /* testloadso.app */, + 001798121074355200F5D044 /* testmultiaudio.app */, 001798941074392D00F5D044 /* testnative.app */, - 001798B5107439DF00F5D044 /* testpower */, - 001798F210743BEC00F5D044 /* testresample */, - 0017991610743F1000F5D044 /* testsprite2 */, - 0017993810743FB700F5D044 /* testwm2 */, - 4537749212091504002F0F45 /* testshape */, - BBFC08CD164C6862003E6A99 /* testgamecontroller */, + 001798B5107439DF00F5D044 /* testpower.app */, + 001798F210743BEC00F5D044 /* testresample.app */, + 0017991610743F1000F5D044 /* testsprite2.app */, + 0017993810743FB700F5D044 /* testwm2.app */, + 4537749212091504002F0F45 /* testshape.app */, + BBFC08CD164C6862003E6A99 /* testgamecontroller.app */, DB166D7F16A1D12400A1396C /* libSDL_test.a */, - DB166DBF16A1D2F600A1396C /* testgesture */, - DB166DD516A1D36A00A1396C /* testmessage */, - DB166DEE16A1D50C00A1396C /* testrelative */, - DB166E0516A1D57C00A1396C /* testrendercopyex */, - DB166E1C16A1D5AD00A1396C /* testrendertarget */, - DB166E3816A1D64D00A1396C /* testrumble */, - DB166E5216A1D69000A1396C /* testscale */, - DB166E6816A1D6F300A1396C /* testshader */, - DB166E7E16A1D78400A1396C /* testspriteminimal */, - DB166E9116A1D78C00A1396C /* teststreaming */, - DB0F48EC17CA51E5008798C5 /* testdrawchessboard */, - DB0F490117CA5212008798C5 /* testfilesystem */, - DB89957E18A19ABA0092407C /* testhotplug */, + DB166DBF16A1D2F600A1396C /* testgesture.app */, + DB166DD516A1D36A00A1396C /* testmessage.app */, + DB166DEE16A1D50C00A1396C /* testrelative.app */, + DB166E0516A1D57C00A1396C /* testrendercopyex.app */, + DB166E1C16A1D5AD00A1396C /* testrendertarget.app */, + DB166E3816A1D64D00A1396C /* testrumble.app */, + DB166E5216A1D69000A1396C /* testscale.app */, + DB166E6816A1D6F300A1396C /* testshader.app */, + DB166E7E16A1D78400A1396C /* testspriteminimal.app */, + DB166E9116A1D78C00A1396C /* teststreaming.app */, + DB0F48EC17CA51E5008798C5 /* testdrawchessboard.app */, + DB0F490117CA5212008798C5 /* testfilesystem.app */, + DB89957E18A19ABA0092407C /* testhotplug.app */, DB445EF818184B7000B306B0 /* testdropfile.app */, - DBEC54EA1A1A81C3005B1EAB /* controllermap */, + DBEC54EA1A1A81C3005B1EAB /* controllermap.app */, F3C17CDC28E416CF00E1A26D /* testgeometry.app */, ); name = Products; @@ -1412,6 +2073,13 @@ path = ../../src/test; sourceTree = ""; }; + F3A249CF2B389C7A00A5162D /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -1431,6 +2099,7 @@ buildPhases = ( 0017957910741F7900F5D044 /* Sources */, 0017957A10741F7900F5D044 /* Frameworks */, + F3A249E92B389CF000A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1438,7 +2107,7 @@ ); name = testatomic; productName = testalpha; - productReference = 0017958C10741F7900F5D044 /* testatomic */; + productReference = 0017958C10741F7900F5D044 /* testatomic.app */; productType = "com.apple.product-type.application"; }; 00179595107421BF00F5D044 /* testaudioinfo */ = { @@ -1447,6 +2116,7 @@ buildPhases = ( 0017959A107421BF00F5D044 /* Sources */, 0017959B107421BF00F5D044 /* Frameworks */, + F3A249EC2B389CFB00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1454,7 +2124,7 @@ ); name = testaudioinfo; productName = testalpha; - productReference = 001795AD107421BF00F5D044 /* testaudioinfo */; + productReference = 001795AD107421BF00F5D044 /* testaudioinfo.app */; productType = "com.apple.product-type.application"; }; 0017970910742F3200F5D044 /* testgl2 */ = { @@ -1463,6 +2133,7 @@ buildPhases = ( 0017970E10742F3200F5D044 /* Sources */, 0017970F10742F3200F5D044 /* Frameworks */, + F3A24A0A2B389D8A00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1479,6 +2150,7 @@ buildPhases = ( 00179735107430D600F5D044 /* Sources */, 00179736107430D600F5D044 /* Frameworks */, + F3A24A0D2B389D9B00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1486,7 +2158,7 @@ ); name = testhaptic; productName = testalpha; - productReference = 00179748107430D600F5D044 /* testhaptic */; + productReference = 00179748107430D600F5D044 /* testhaptic.app */; productType = "com.apple.product-type.application"; }; 00179756107431B300F5D044 /* testdraw2 */ = { @@ -1495,6 +2167,7 @@ buildPhases = ( 0017975B107431B300F5D044 /* Sources */, 0017975C107431B300F5D044 /* Frameworks */, + F3A249EF2B389D0900A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1502,7 +2175,7 @@ ); name = testdraw2; productName = testalpha; - productReference = 0017976E107431B300F5D044 /* testdraw2 */; + productReference = 0017976E107431B300F5D044 /* testdraw2.app */; productType = "com.apple.product-type.application"; }; 00179776107432AE00F5D044 /* testime */ = { @@ -1511,6 +2184,7 @@ buildPhases = ( 0017977B107432AE00F5D044 /* Sources */, 0017977C107432AE00F5D044 /* Frameworks */, + F3A24A162B389DC000A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1518,7 +2192,7 @@ ); name = testime; productName = testalpha; - productReference = 0017978E107432AE00F5D044 /* testime */; + productReference = 0017978E107432AE00F5D044 /* testime.app */; productType = "com.apple.product-type.application"; }; 001797961074334C00F5D044 /* testintersections */ = { @@ -1527,6 +2201,7 @@ buildPhases = ( 0017979B1074334C00F5D044 /* Sources */, 0017979C1074334C00F5D044 /* Frameworks */, + F3A24A192B389DCA00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1534,7 +2209,7 @@ ); name = testintersections; productName = testalpha; - productReference = 001797AE1074334C00F5D044 /* testintersections */; + productReference = 001797AE1074334C00F5D044 /* testintersections.app */; productType = "com.apple.product-type.application"; }; 001797B8107433C600F5D044 /* testloadso */ = { @@ -1543,6 +2218,7 @@ buildPhases = ( 001797BD107433C600F5D044 /* Sources */, 001797BE107433C600F5D044 /* Frameworks */, + F3A24A222B389DEB00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1550,7 +2226,7 @@ ); name = testloadso; productName = testalpha; - productReference = 001797D0107433C600F5D044 /* testloadso */; + productReference = 001797D0107433C600F5D044 /* testloadso.app */; productType = "com.apple.product-type.application"; }; 001797FA1074355200F5D044 /* testmultiaudio */ = { @@ -1560,6 +2236,7 @@ 001797FF1074355200F5D044 /* Sources */, 001798001074355200F5D044 /* Frameworks */, F3C17D3828E424B100E1A26D /* Resources */, + F3A24A2B2B389E0900A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1567,7 +2244,7 @@ ); name = testmultiaudio; productName = testalpha; - productReference = 001798121074355200F5D044 /* testmultiaudio */; + productReference = 001798121074355200F5D044 /* testmultiaudio.app */; productType = "com.apple.product-type.application"; }; 001798781074392D00F5D044 /* testnative */ = { @@ -1577,6 +2254,7 @@ 0017987E1074392D00F5D044 /* Sources */, 001798821074392D00F5D044 /* Frameworks */, DB166DDA16A1D40F00A1396C /* CopyFiles */, + F3A24A2E2B389E1500A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1593,6 +2271,7 @@ buildPhases = ( 001798A2107439DF00F5D044 /* Sources */, 001798A3107439DF00F5D044 /* Frameworks */, + F3A24A382B389E4F00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1600,7 +2279,7 @@ ); name = testpower; productName = testalpha; - productReference = 001798B5107439DF00F5D044 /* testpower */; + productReference = 001798B5107439DF00F5D044 /* testpower.app */; productType = "com.apple.product-type.application"; }; 001798DA10743BEC00F5D044 /* testresample */ = { @@ -1609,6 +2288,7 @@ buildPhases = ( 001798DF10743BEC00F5D044 /* Sources */, 001798E010743BEC00F5D044 /* Frameworks */, + F3A24A442B389E7C00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1616,7 +2296,7 @@ ); name = testresample; productName = testalpha; - productReference = 001798F210743BEC00F5D044 /* testresample */; + productReference = 001798F210743BEC00F5D044 /* testresample.app */; productType = "com.apple.product-type.application"; }; 001798FE10743F1000F5D044 /* testsprite2 */ = { @@ -1626,6 +2306,7 @@ 0017990310743F1000F5D044 /* Sources */, 0017990410743F1000F5D044 /* Frameworks */, F3C17D3A28E4252200E1A26D /* Resources */, + F3A249DD2B389C7A00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1633,7 +2314,7 @@ ); name = testsprite2; productName = testalpha; - productReference = 0017991610743F1000F5D044 /* testsprite2 */; + productReference = 0017991610743F1000F5D044 /* testsprite2.app */; productType = "com.apple.product-type.application"; }; 0017992010743FB700F5D044 /* testwm2 */ = { @@ -1642,6 +2323,7 @@ buildPhases = ( 0017992510743FB700F5D044 /* Sources */, 0017992610743FB700F5D044 /* Frameworks */, + F3A24A652B389EF900A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1649,7 +2331,7 @@ ); name = testwm2; productName = testalpha; - productReference = 0017993810743FB700F5D044 /* testwm2 */; + productReference = 0017993810743FB700F5D044 /* testwm2.app */; productType = "com.apple.product-type.application"; }; 002F340109CA1BFF00EBEB88 /* testfile */ = { @@ -1658,6 +2340,7 @@ buildPhases = ( 002F340709CA1BFF00EBEB88 /* Sources */, 002F340809CA1BFF00EBEB88 /* Frameworks */, + F3A249FB2B389D5200A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1665,7 +2348,7 @@ ); name = testfile; productName = testalpha; - productReference = 002F341209CA1BFF00EBEB88 /* testfile */; + productReference = 002F341209CA1BFF00EBEB88 /* testfile.app */; productType = "com.apple.product-type.application"; }; 002F342009CA1F0300EBEB88 /* testiconv */ = { @@ -1675,6 +2358,7 @@ 002F342609CA1F0300EBEB88 /* Sources */, 002F342709CA1F0300EBEB88 /* Frameworks */, 00794EEC09D2371F003FC8A1 /* CopyFiles */, + F3A24A132B389DB400A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1682,7 +2366,7 @@ ); name = testiconv; productName = testalpha; - productReference = 002F343109CA1F0300EBEB88 /* testiconv */; + productReference = 002F343109CA1F0300EBEB88 /* testiconv.app */; productType = "com.apple.product-type.application"; }; 002F343C09CA1FB300EBEB88 /* testoverlay2 */ = { @@ -1692,6 +2376,7 @@ 002F344209CA1FB300EBEB88 /* Sources */, 002F344309CA1FB300EBEB88 /* Frameworks */, 00794EF409D237C7003FC8A1 /* CopyFiles */, + F3A24A322B389E2800A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1699,7 +2384,7 @@ ); name = testoverlay2; productName = testalpha; - productReference = 002F344D09CA1FB300EBEB88 /* testoverlay2 */; + productReference = 002F344D09CA1FB300EBEB88 /* testoverlay2.app */; productType = "com.apple.product-type.application"; }; 002F345909CA204F00EBEB88 /* testplatform */ = { @@ -1708,6 +2393,7 @@ buildPhases = ( 002F345F09CA204F00EBEB88 /* Sources */, 002F346009CA204F00EBEB88 /* Frameworks */, + F3A24A352B389E3200A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1715,7 +2401,7 @@ ); name = testplatform; productName = testalpha; - productReference = 002F346A09CA204F00EBEB88 /* testplatform */; + productReference = 002F346A09CA204F00EBEB88 /* testplatform.app */; productType = "com.apple.product-type.application"; }; 4537749112091504002F0F45 /* testshape */ = { @@ -1725,6 +2411,7 @@ 4537748F12091504002F0F45 /* Sources */, 4537749012091504002F0F45 /* Frameworks */, DB166ECE16A1D85400A1396C /* CopyFiles */, + F3A24A532B389EB600A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1732,7 +2419,7 @@ ); name = testshape; productName = testshape; - productReference = 4537749212091504002F0F45 /* testshape */; + productReference = 4537749212091504002F0F45 /* testshape.app */; productType = "com.apple.product-type.application"; }; BBFC08B7164C6862003E6A99 /* testgamecontroller */ = { @@ -1742,6 +2429,7 @@ BBFC08BC164C6862003E6A99 /* Sources */, BBFC08BE164C6862003E6A99 /* Frameworks */, F3C17D3528E4242100E1A26D /* Resources */, + F3A24A012B389D6600A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1749,7 +2437,7 @@ ); name = testgamecontroller; productName = testjoystick; - productReference = BBFC08CD164C6862003E6A99 /* testgamecontroller */; + productReference = BBFC08CD164C6862003E6A99 /* testgamecontroller.app */; productType = "com.apple.product-type.application"; }; BEC566AB0761D90300A33029 /* checkkeys */ = { @@ -1758,6 +2446,7 @@ buildPhases = ( BEC566B00761D90300A33029 /* Sources */, BEC566B20761D90300A33029 /* Frameworks */, + F3A249E02B389CCA00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1765,7 +2454,7 @@ ); name = checkkeys; productName = checkkeys; - productReference = BEC566B60761D90300A33029 /* checkkeys */; + productReference = BEC566B60761D90300A33029 /* checkkeys.app */; productType = "com.apple.product-type.application"; }; BEC566C50761D90300A33029 /* loopwave */ = { @@ -1775,6 +2464,7 @@ BEC566CA0761D90300A33029 /* Sources */, BEC566CC0761D90300A33029 /* Frameworks */, 00794E6409D2084F003FC8A1 /* CopyFiles */, + F3A249E62B389CE700A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1782,7 +2472,7 @@ ); name = loopwave; productName = loopwave; - productReference = BEC566D10761D90300A33029 /* loopwave */; + productReference = BEC566D10761D90300A33029 /* loopwave.app */; productType = "com.apple.product-type.application"; }; BEC566FB0761D90300A33029 /* testerror */ = { @@ -1791,6 +2481,7 @@ buildPhases = ( BEC567000761D90300A33029 /* Sources */, BEC567020761D90300A33029 /* Frameworks */, + F3A249F82B389D4400A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1798,7 +2489,7 @@ ); name = testerror; productName = testerror; - productReference = BEC567060761D90400A33029 /* testerror */; + productReference = BEC567060761D90400A33029 /* testerror.app */; productType = "com.apple.product-type.application"; }; BEC567230761D90400A33029 /* testthread */ = { @@ -1807,6 +2498,7 @@ buildPhases = ( BEC567280761D90400A33029 /* Sources */, BEC5672A0761D90400A33029 /* Frameworks */, + F3A24A5C2B389ED800A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1814,7 +2506,7 @@ ); name = testthread; productName = testthread; - productReference = BEC5672E0761D90400A33029 /* testthread */; + productReference = BEC5672E0761D90400A33029 /* testthread.app */; productType = "com.apple.product-type.application"; }; BEC567300761D90400A33029 /* testjoystick */ = { @@ -1823,6 +2515,7 @@ buildPhases = ( BEC567350761D90400A33029 /* Sources */, BEC567370761D90400A33029 /* Frameworks */, + F3A24A1C2B389DD600A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1830,7 +2523,7 @@ ); name = testjoystick; productName = testjoystick; - productReference = BEC5673B0761D90400A33029 /* testjoystick */; + productReference = BEC5673B0761D90400A33029 /* testjoystick.app */; productType = "com.apple.product-type.application"; }; BEC5673D0761D90400A33029 /* testkeys */ = { @@ -1839,6 +2532,7 @@ buildPhases = ( BEC567420761D90400A33029 /* Sources */, BEC567440761D90400A33029 /* Frameworks */, + F3A24A1F2B389DE100A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1846,7 +2540,7 @@ ); name = testkeys; productName = testkeys; - productReference = BEC567480761D90400A33029 /* testkeys */; + productReference = BEC567480761D90400A33029 /* testkeys.app */; productType = "com.apple.product-type.application"; }; BEC5674A0761D90400A33029 /* testlock */ = { @@ -1855,6 +2549,7 @@ buildPhases = ( BEC5674F0761D90400A33029 /* Sources */, BEC567510761D90400A33029 /* Frameworks */, + F3A24A252B389DF500A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1862,7 +2557,7 @@ ); name = testlock; productName = testlock; - productReference = BEC567550761D90400A33029 /* testlock */; + productReference = BEC567550761D90400A33029 /* testlock.app */; productType = "com.apple.product-type.application"; }; BEC567720761D90500A33029 /* testsem */ = { @@ -1871,6 +2566,7 @@ buildPhases = ( BEC567770761D90500A33029 /* Sources */, BEC567790761D90500A33029 /* Frameworks */, + F3A24A4D2B389E9C00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1878,7 +2574,7 @@ ); name = testsem; productName = testsem; - productReference = BEC5677D0761D90500A33029 /* testsem */; + productReference = BEC5677D0761D90500A33029 /* testsem.app */; productType = "com.apple.product-type.application"; }; BEC5678D0761D90500A33029 /* testtimer */ = { @@ -1887,6 +2583,7 @@ buildPhases = ( BEC567920761D90500A33029 /* Sources */, BEC567940761D90500A33029 /* Frameworks */, + F3A24A5F2B389EE200A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1894,7 +2591,7 @@ ); name = testtimer; productName = testtimer; - productReference = BEC567980761D90500A33029 /* testtimer */; + productReference = BEC567980761D90500A33029 /* testtimer.app */; productType = "com.apple.product-type.application"; }; BEC567A70761D90500A33029 /* testversion */ = { @@ -1903,6 +2600,7 @@ buildPhases = ( BEC567AC0761D90500A33029 /* Sources */, BEC567AE0761D90500A33029 /* Frameworks */, + F3A24A622B389EED00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1910,7 +2608,7 @@ ); name = testversion; productName = testversion; - productReference = BEC567B20761D90500A33029 /* testversion */; + productReference = BEC567B20761D90500A33029 /* testversion.app */; productType = "com.apple.product-type.application"; }; BEC567EA0761D90600A33029 /* torturethread */ = { @@ -1919,6 +2617,7 @@ buildPhases = ( BEC567EF0761D90600A33029 /* Sources */, BEC567F10761D90600A33029 /* Frameworks */, + F3A24A682B389F0400A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1926,7 +2625,7 @@ ); name = torturethread; productName = torturethread; - productReference = BEC567F50761D90600A33029 /* torturethread */; + productReference = BEC567F50761D90600A33029 /* torturethread.app */; productType = "com.apple.product-type.application"; }; DB0F48D917CA51E5008798C5 /* testdrawchessboard */ = { @@ -1935,6 +2634,7 @@ buildPhases = ( DB0F48DA17CA51E5008798C5 /* Sources */, DB0F48DC17CA51E5008798C5 /* Frameworks */, + F3A249F22B389D3100A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1942,7 +2642,7 @@ ); name = testdrawchessboard; productName = testalpha; - productReference = DB0F48EC17CA51E5008798C5 /* testdrawchessboard */; + productReference = DB0F48EC17CA51E5008798C5 /* testdrawchessboard.app */; productType = "com.apple.product-type.application"; }; DB0F48EF17CA5212008798C5 /* testfilesystem */ = { @@ -1951,6 +2651,7 @@ buildPhases = ( DB0F48F017CA5212008798C5 /* Sources */, DB0F48F217CA5212008798C5 /* Frameworks */, + F3A249FE2B389D5B00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1958,7 +2659,7 @@ ); name = testfilesystem; productName = testalpha; - productReference = DB0F490117CA5212008798C5 /* testfilesystem */; + productReference = DB0F490117CA5212008798C5 /* testfilesystem.app */; productType = "com.apple.product-type.application"; }; DB166D7E16A1D12400A1396C /* SDL_test */ = { @@ -1984,6 +2685,7 @@ buildPhases = ( DB166DAE16A1D2F600A1396C /* Sources */, DB166DB016A1D2F600A1396C /* Frameworks */, + F3A24A072B389D7C00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -1991,7 +2693,7 @@ ); name = testgesture; productName = testalpha; - productReference = DB166DBF16A1D2F600A1396C /* testgesture */; + productReference = DB166DBF16A1D2F600A1396C /* testgesture.app */; productType = "com.apple.product-type.application"; }; DB166DC416A1D36A00A1396C /* testmessage */ = { @@ -2000,6 +2702,7 @@ buildPhases = ( DB166DC516A1D36A00A1396C /* Sources */, DB166DC716A1D36A00A1396C /* Frameworks */, + F3A24A282B389E0000A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2007,7 +2710,7 @@ ); name = testmessage; productName = testalpha; - productReference = DB166DD516A1D36A00A1396C /* testmessage */; + productReference = DB166DD516A1D36A00A1396C /* testmessage.app */; productType = "com.apple.product-type.application"; }; DB166DDC16A1D50C00A1396C /* testrelative */ = { @@ -2016,6 +2719,7 @@ buildPhases = ( DB166DDD16A1D50C00A1396C /* Sources */, DB166DDF16A1D50C00A1396C /* Frameworks */, + F3A24A3B2B389E5D00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2023,7 +2727,7 @@ ); name = testrelative; productName = testalpha; - productReference = DB166DEE16A1D50C00A1396C /* testrelative */; + productReference = DB166DEE16A1D50C00A1396C /* testrelative.app */; productType = "com.apple.product-type.application"; }; DB166DF316A1D57C00A1396C /* testrendercopyex */ = { @@ -2033,6 +2737,7 @@ DB166DF416A1D57C00A1396C /* Sources */, DB166DF616A1D57C00A1396C /* Frameworks */, DB166E2116A1D5DF00A1396C /* CopyFiles */, + F3A24A3E2B389E6600A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2040,7 +2745,7 @@ ); name = testrendercopyex; productName = testalpha; - productReference = DB166E0516A1D57C00A1396C /* testrendercopyex */; + productReference = DB166E0516A1D57C00A1396C /* testrendercopyex.app */; productType = "com.apple.product-type.application"; }; DB166E0A16A1D5AD00A1396C /* testrendertarget */ = { @@ -2050,6 +2755,7 @@ DB166E0B16A1D5AD00A1396C /* Sources */, DB166E0D16A1D5AD00A1396C /* Frameworks */, DB166E2416A1D61000A1396C /* CopyFiles */, + F3A24A412B389E7200A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2057,7 +2763,7 @@ ); name = testrendertarget; productName = testalpha; - productReference = DB166E1C16A1D5AD00A1396C /* testrendertarget */; + productReference = DB166E1C16A1D5AD00A1396C /* testrendertarget.app */; productType = "com.apple.product-type.application"; }; DB166E2716A1D64D00A1396C /* testrumble */ = { @@ -2066,6 +2772,7 @@ buildPhases = ( DB166E2816A1D64D00A1396C /* Sources */, DB166E2A16A1D64D00A1396C /* Frameworks */, + F3A24A472B389E8700A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2073,7 +2780,7 @@ ); name = testrumble; productName = testalpha; - productReference = DB166E3816A1D64D00A1396C /* testrumble */; + productReference = DB166E3816A1D64D00A1396C /* testrumble.app */; productType = "com.apple.product-type.application"; }; DB166E3D16A1D69000A1396C /* testscale */ = { @@ -2083,6 +2790,7 @@ DB166E3E16A1D69000A1396C /* Sources */, DB166E4016A1D69000A1396C /* Frameworks */, DB166E4C16A1D69000A1396C /* CopyFiles */, + F3A24A4A2B389E9100A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2090,7 +2798,7 @@ ); name = testscale; productName = testalpha; - productReference = DB166E5216A1D69000A1396C /* testscale */; + productReference = DB166E5216A1D69000A1396C /* testscale.app */; productType = "com.apple.product-type.application"; }; DB166E5716A1D6F300A1396C /* testshader */ = { @@ -2099,6 +2807,7 @@ buildPhases = ( DB166E5816A1D6F300A1396C /* Sources */, DB166E5A16A1D6F300A1396C /* Frameworks */, + F3A24A502B389EA600A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2106,7 +2815,7 @@ ); name = testshader; productName = testsem; - productReference = DB166E6816A1D6F300A1396C /* testshader */; + productReference = DB166E6816A1D6F300A1396C /* testshader.app */; productType = "com.apple.product-type.application"; }; DB166E6D16A1D78400A1396C /* testspriteminimal */ = { @@ -2116,6 +2825,7 @@ DB166E6E16A1D78400A1396C /* Sources */, DB166E7016A1D78400A1396C /* Frameworks */, DB166E9B16A1D7FC00A1396C /* CopyFiles */, + F3A24A562B389EC200A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2123,7 +2833,7 @@ ); name = testspriteminimal; productName = testspriteminimal; - productReference = DB166E7E16A1D78400A1396C /* testspriteminimal */; + productReference = DB166E7E16A1D78400A1396C /* testspriteminimal.app */; productType = "com.apple.product-type.application"; }; DB166E8016A1D78C00A1396C /* teststreaming */ = { @@ -2133,6 +2843,7 @@ DB166E8116A1D78C00A1396C /* Sources */, DB166E8316A1D78C00A1396C /* Frameworks */, DB166E9916A1D7EE00A1396C /* CopyFiles */, + F3A24A592B389ECD00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2140,7 +2851,7 @@ ); name = teststreaming; productName = teststreaming; - productReference = DB166E9116A1D78C00A1396C /* teststreaming */; + productReference = DB166E9116A1D78C00A1396C /* teststreaming.app */; productType = "com.apple.product-type.application"; }; DB445EE618184B7000B306B0 /* testdropfile */ = { @@ -2149,6 +2860,7 @@ buildPhases = ( DB445EE718184B7000B306B0 /* Sources */, DB445EE918184B7000B306B0 /* Frameworks */, + F3A249F52B389D3B00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2165,6 +2877,7 @@ buildPhases = ( DB89956E18A19ABA0092407C /* Sources */, DB89957018A19ABA0092407C /* Frameworks */, + F3A24A102B389DA800A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2172,7 +2885,7 @@ ); name = testhotplug; productName = testalpha; - productReference = DB89957E18A19ABA0092407C /* testhotplug */; + productReference = DB89957E18A19ABA0092407C /* testhotplug.app */; productType = "com.apple.product-type.application"; }; DBEC54D91A1A81C3005B1EAB /* controllermap */ = { @@ -2182,6 +2895,7 @@ DBEC54DA1A1A81C3005B1EAB /* Sources */, DBEC54DC1A1A81C3005B1EAB /* Frameworks */, DBEC54EC1A1A827C005B1EAB /* CopyFiles */, + F3A249E32B389CDB00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2189,7 +2903,7 @@ ); name = controllermap; productName = checkkeys; - productReference = DBEC54EA1A1A81C3005B1EAB /* controllermap */; + productReference = DBEC54EA1A1A81C3005B1EAB /* controllermap.app */; productType = "com.apple.product-type.application"; }; F3C17CDB28E416CF00E1A26D /* testgeometry */ = { @@ -2198,6 +2912,7 @@ buildPhases = ( F3C17CD828E416CF00E1A26D /* Sources */, F3C17CD928E416CF00E1A26D /* Frameworks */, + F3A24A042B389D6F00A5162D /* Embed Frameworks */, ); buildRules = ( ); @@ -2217,8 +2932,153 @@ LastSwiftUpdateCheck = 1400; LastUpgradeCheck = 0420; TargetAttributes = { + 0017957410741F7900F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 00179595107421BF00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 0017970910742F3200F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 00179730107430D600F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 00179756107431B300F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 00179776107432AE00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001797961074334C00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001797B8107433C600F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001797FA1074355200F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001798781074392D00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 0017989D107439DF00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001798DA10743BEC00F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 001798FE10743F1000F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 0017992010743FB700F5D044 = { + DevelopmentTeam = EH385AYQ6F; + }; + 002F340109CA1BFF00EBEB88 = { + DevelopmentTeam = EH385AYQ6F; + }; + 002F342009CA1F0300EBEB88 = { + DevelopmentTeam = EH385AYQ6F; + }; + 002F343C09CA1FB300EBEB88 = { + DevelopmentTeam = EH385AYQ6F; + }; + 002F345909CA204F00EBEB88 = { + DevelopmentTeam = EH385AYQ6F; + }; + 4537749112091504002F0F45 = { + DevelopmentTeam = EH385AYQ6F; + }; + BBFC08B7164C6862003E6A99 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC566920761D90300A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC566AB0761D90300A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC566C50761D90300A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC566FB0761D90300A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC567230761D90400A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC567300761D90400A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC5673D0761D90400A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC5674A0761D90400A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC567720761D90500A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC5678D0761D90500A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC567A70761D90500A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + BEC567EA0761D90600A33029 = { + DevelopmentTeam = EH385AYQ6F; + }; + DB0F48D917CA51E5008798C5 = { + DevelopmentTeam = EH385AYQ6F; + }; + DB0F48EF17CA5212008798C5 = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166D7E16A1D12400A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166DAD16A1D2F600A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166DC416A1D36A00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166DDC16A1D50C00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166DF316A1D57C00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E0A16A1D5AD00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E2716A1D64D00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E3D16A1D69000A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E5716A1D6F300A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E6D16A1D78400A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB166E8016A1D78C00A1396C = { + DevelopmentTeam = EH385AYQ6F; + }; + DB445EE618184B7000B306B0 = { + DevelopmentTeam = EH385AYQ6F; + }; + DB89956D18A19ABA0092407C = { + DevelopmentTeam = EH385AYQ6F; + }; + DBEC54D91A1A81C3005B1EAB = { + DevelopmentTeam = EH385AYQ6F; + }; F3C17CDB28E416CF00E1A26D = { CreatedOnToolsVersion = 14.0.1; + DevelopmentTeam = EH385AYQ6F; }; }; }; @@ -3387,6 +4247,8 @@ 002A85C51073008E007319AE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + INFOPLIST_FILE = "testoverlay2-Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; PRODUCT_NAME = testoverlay2; }; name = Debug; @@ -3524,6 +4386,8 @@ 002A85E71073009D007319AE /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + INFOPLIST_FILE = "testoverlay2-Info.plist"; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; PRODUCT_NAME = testoverlay2; }; name = Release; diff --git a/vs/sdl2/acinclude/libtool.m4 b/vs/sdl2/acinclude/libtool.m4 index 3236ddab00..5afe55ea09 100644 --- a/vs/sdl2/acinclude/libtool.m4 +++ b/vs/sdl2/acinclude/libtool.m4 @@ -219,8 +219,8 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). +# All known linkers require a '.a' archive for static linking (except MSVC and +# ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld @@ -1365,7 +1365,7 @@ mips64*-*linux*) ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) +s390*-*linux*|s390*-*tpf*|sparc*-*linux*|x86_64-gnu*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when @@ -1380,7 +1380,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" @@ -1409,7 +1409,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*|powerpc64le-*linux*) @@ -1540,15 +1540,8 @@ old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then - case $host_os in - bitrig* | openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -1687,7 +1680,7 @@ AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl lt_cv_sys_max_cmd_len=-1; ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, @@ -1930,7 +1923,7 @@ else lt_cv_dlopen_self=yes ;; - mingw* | pw32* | cegcc*) + mingw* | windows* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; @@ -2298,7 +2291,7 @@ if test yes = "$GCC"; then *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + mingw* | windows* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` @@ -2356,7 +2349,7 @@ BEGIN {RS = " "; FS = "/|\n";} { # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + mingw* | windows* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` @@ -2525,7 +2518,7 @@ bsdi[[45]]*) # libtool to hard-code these into programs ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no @@ -2558,7 +2551,7 @@ cygwin* | mingw* | pw32* | cegcc*) m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; - mingw* | cegcc*) + mingw* | windows* | cegcc*) # MinGW DLLs use traditional 'lib' prefix #soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization @@ -2571,14 +2564,14 @@ m4_if([$1], [],[ dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in - mingw*) + mingw* | windows*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' @@ -2628,7 +2621,7 @@ m4_if([$1], [],[ ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -3267,7 +3260,7 @@ if test yes = "$GCC"; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in - *-*-mingw*) + *-*-mingw* | *-*-windows*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) @@ -3376,7 +3369,7 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi @@ -3476,7 +3469,7 @@ cygwin*) lt_cv_deplibs_check_method=pass_all # SDL customization ;; -mingw* | pw32*) +mingw* | windows* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. @@ -3641,7 +3634,7 @@ file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in - mingw* | pw32*) + mingw* | windows* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else @@ -3693,7 +3686,7 @@ else # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in - mingw*) lt_bad_file=conftest.nm/nofile ;; + mingw* | windows*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in @@ -3784,7 +3777,7 @@ lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in @@ -3929,7 +3922,7 @@ case $host_os in aix*) symcode='[[BCDT]]' ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) @@ -4008,7 +4001,7 @@ $lt_c_name_lib_hook\ # Handle CRLF in mingw tool chain opt_cr= case $build_os in -mingw*) +mingw* | windows*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac @@ -4023,7 +4016,7 @@ for ac_symprfx in "" "_"; do if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. - # Also find C++ and __fastcall symbols from MSVC++, + # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ @@ -4235,7 +4228,7 @@ m4_if([$1], [CXX], [ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -4311,7 +4304,7 @@ m4_if([$1], [CXX], [ ;; esac ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], @@ -4559,7 +4552,7 @@ m4_if([$1], [CXX], [ # PIC is the default for these OSes. ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -4663,7 +4656,7 @@ m4_if([$1], [CXX], [ esac ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). m4_if([$1], [GCJ], [], @@ -4938,9 +4931,9 @@ m4_if([$1], [CXX], [ pw32*) _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) case $cc_basename in - cl*) + cl* | icl*) _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) @@ -4996,16 +4989,16 @@ dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time + cygwin* | mingw* | windows* | pw32* | cegcc*) + # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) + # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) @@ -5111,7 +5104,7 @@ _LT_EOF fi ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' @@ -5568,14 +5561,14 @@ _LT_EOF _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in - cl*) - # Native MSVC + cl* | icl*) + # Native MSVC or ICC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes @@ -5585,14 +5578,14 @@ _LT_EOF # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_cmds, $1)='$CC -Fe $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + $CC -Fe $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' @@ -5616,7 +5609,7 @@ _LT_EOF fi' ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. @@ -6435,7 +6428,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else GXX=no @@ -6644,10 +6637,10 @@ if test yes != "$_lt_caught_CXX_error"; then esac ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC + ,cl* | no,cl* | ,icl* | no,icl*) + # Native MSVC or ICC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' @@ -6811,7 +6804,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "[[-]]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -6876,7 +6869,7 @@ if test yes != "$_lt_caught_CXX_error"; then # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "[[-]]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -7215,7 +7208,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else # FIXME: insert proper C++ library support @@ -7299,7 +7292,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -7310,7 +7303,7 @@ if test yes != "$_lt_caught_CXX_error"; then # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[[-]]L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' @@ -8331,7 +8324,7 @@ AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) @@ -8344,7 +8337,7 @@ AC_CACHE_VAL(lt_cv_to_host_file_cmd, ;; *-*-cygwin* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) @@ -8370,9 +8363,9 @@ AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in - *-*-mingw* ) + *-*-mingw* | *-*-windows* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac diff --git a/vs/sdl2/acinclude/ltoptions.m4 b/vs/sdl2/acinclude/ltoptions.m4 index 94b0829766..7d7e68864b 100644 --- a/vs/sdl2/acinclude/ltoptions.m4 +++ b/vs/sdl2/acinclude/ltoptions.m4 @@ -128,7 +128,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) +*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) diff --git a/vs/sdl2/android-project/app/build.gradle b/vs/sdl2/android-project/app/build.gradle index baa0edc8de..c6043616d9 100644 --- a/vs/sdl2/android-project/app/build.gradle +++ b/vs/sdl2/android-project/app/build.gradle @@ -8,22 +8,22 @@ else { } android { - compileSdkVersion 31 + if (buildAsApplication) { + namespace "org.libsdl.app" + } + compileSdkVersion 34 defaultConfig { - if (buildAsApplication) { - applicationId "org.libsdl.app" - } - minSdkVersion 16 - targetSdkVersion 31 + minSdkVersion 19 + targetSdkVersion 34 versionCode 1 versionName "1.0" externalNativeBuild { ndkBuild { - arguments "APP_PLATFORM=android-16" + arguments "APP_PLATFORM=android-19" abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' } // cmake { - // arguments "-DANDROID_APP_PLATFORM=android-16", "-DANDROID_STL=c++_static" + // arguments "-DANDROID_APP_PLATFORM=android-19", "-DANDROID_STL=c++_static" // // abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' // abiFilters 'arm64-v8a' // } @@ -53,10 +53,10 @@ android { } } - lintOptions { + lint { abortOnError false } - + if (buildAsLibrary) { libraryVariants.all { variant -> variant.outputs.each { output -> diff --git a/vs/sdl2/android-project/app/src/main/AndroidManifest.xml b/vs/sdl2/android-project/app/src/main/AndroidManifest.xml index d997afe4a4..5157374b52 100644 --- a/vs/sdl2/android-project/app/src/main/AndroidManifest.xml +++ b/vs/sdl2/android-project/app/src/main/AndroidManifest.xml @@ -3,7 +3,6 @@ com.gamemaker.game --> @@ -63,7 +62,7 @@ - - diff --git a/vs/sdl2/android-project/build.gradle b/vs/sdl2/android-project/build.gradle index 6f629c8aa7..2c911c6ff1 100644 --- a/vs/sdl2/android-project/build.gradle +++ b/vs/sdl2/android-project/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.3' + classpath 'com.android.tools.build:gradle:8.1.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/vs/sdl2/android-project/gradle/wrapper/gradle-wrapper.properties b/vs/sdl2/android-project/gradle/wrapper/gradle-wrapper.properties index ada5af48a6..5b9d759973 100644 --- a/vs/sdl2/android-project/gradle/wrapper/gradle-wrapper.properties +++ b/vs/sdl2/android-project/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Nov 11 18:20:34 PST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/vs/sdl2/build-scripts/config.guess b/vs/sdl2/build-scripts/config.guess index 1817bdce90..f6d217a49f 100755 --- a/vs/sdl2/build-scripts/config.guess +++ b/vs/sdl2/build-scripts/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-05-25' +timestamp='2024-01-01' # 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 @@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] -Output the configuration name of the system \`$me' is run on. +Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit @@ -60,13 +60,13 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2024 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -102,8 +102,8 @@ GUESS= # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. @@ -155,6 +155,9 @@ Linux|GNU|GNU/*) set_cc_for_build cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else #include #if defined(__UCLIBC__) LIBC=uclibc @@ -162,6 +165,8 @@ Linux|GNU|GNU/*) LIBC=dietlibc #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm #else #include /* First heuristic to detect musl libc. */ @@ -169,6 +174,7 @@ Linux|GNU|GNU/*) LIBC=musl #endif #endif + #endif EOF cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` eval "$cc_set_libc" @@ -459,7 +465,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in UNAME_RELEASE=`uname -v` ;; esac - # Japanese Language versions have a version number like `4.1.3-JL'. + # Japanese Language versions have a version number like '4.1.3-JL'. SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` GUESS=sparc-sun-sunos$SUN_REL ;; @@ -904,7 +910,7 @@ EOF fi ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` + UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; @@ -966,11 +972,37 @@ EOF GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; *:Minix:*:*) GUESS=$UNAME_MACHINE-unknown-minix ;; aarch64:Linux:*:*) - GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be @@ -1036,7 +1068,16 @@ EOF k1om:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; - loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) GUESS=$UNAME_MACHINE-unknown-linux-$LIBC ;; m32r*:Linux:*:*) @@ -1191,7 +1232,7 @@ EOF GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION ;; i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility + # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. GUESS=$UNAME_MACHINE-pc-os2-emx ;; @@ -1332,7 +1373,7 @@ EOF GUESS=ns32k-sni-sysv fi ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says GUESS=i586-unisys-sysv4 ;; @@ -1554,6 +1595,9 @@ EOF *:Unleashed:*:*) GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE ;; + *:Ironclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad + ;; esac # Do we have a guess based on uname results? diff --git a/vs/sdl2/build-scripts/config.sub b/vs/sdl2/build-scripts/config.sub index 312ad817c6..2c6a07ab3c 100755 --- a/vs/sdl2/build-scripts/config.sub +++ b/vs/sdl2/build-scripts/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2022 Free Software Foundation, Inc. +# Copyright 1992-2024 Free Software Foundation, Inc. # shellcheck disable=SC2006,SC2268 # see below for rationale -timestamp='2022-01-03' +timestamp='2024-01-01' # 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 @@ -76,13 +76,13 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2022 Free Software Foundation, Inc. +Copyright 1992-2024 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -130,7 +130,7 @@ IFS=$saved_IFS # Separate into logical components for further validation case $1 in *-*-*-*-*) - echo Invalid configuration \`"$1"\': more than four components >&2 + echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) @@ -145,7 +145,8 @@ case $1 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*) + | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \ + | windows-* ) basic_machine=$field1 basic_os=$maybe_os ;; @@ -943,7 +944,7 @@ $basic_machine EOF IFS=$saved_IFS ;; - # We use `pc' rather than `unknown' + # We use 'pc' rather than 'unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) @@ -1180,7 +1181,7 @@ case $cpu-$vendor in case $cpu in 1750a | 580 \ | a29k \ - | aarch64 | aarch64_be \ + | aarch64 | aarch64_be | aarch64c | arm64ec \ | abacus \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ @@ -1199,50 +1200,29 @@ case $cpu-$vendor in | d10v | d30v | dlx | dsp16xx \ | e2k | elxsi | epiphany \ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | javascript \ | h8300 | h8500 \ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i*86 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ + | kvx \ | le32 | le64 \ | lm32 \ - | loongarch32 | loongarch64 | loongarchx32 \ + | loongarch32 | loongarch64 \ | 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 \ - | mipsisa32r3 | mipsisa32r3el \ - | mipsisa32r5 | mipsisa32r5el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r3 | mipsisa64r3el \ - | mipsisa64r5 | mipsisa64r5el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ + | mips* \ | mmix \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ + | nanomips* \ | nds32 | nds32le | nds32be \ | nfp \ | nios | nios2 | nios2eb | nios2el \ @@ -1274,6 +1254,7 @@ case $cpu-$vendor in | ubicom32 \ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ | vax \ + | vc4 \ | visium \ | w65 \ | wasm32 | wasm64 \ @@ -1285,7 +1266,7 @@ case $cpu-$vendor in ;; *) - echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac @@ -1306,11 +1287,12 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if test x$basic_os != x +if test x"$basic_os" != x then # First recognize some ad-hoc cases, or perhaps split kernel-os, or else just # set os. +obj= case $basic_os in gnu/linux*) kernel=linux @@ -1341,6 +1323,10 @@ EOF kernel=linux os=`echo "$basic_os" | sed -e 's|linux|gnu|'` ;; + managarm*) + kernel=managarm + os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'` + ;; *) kernel= os=$basic_os @@ -1506,10 +1492,16 @@ case $os in os=eabi ;; *) - os=elf + os= + obj=elf ;; esac ;; + aout* | coff* | elf* | pe*) + # These are machine code file formats, not OSes + obj=$os + os= + ;; *) # No normalization, but not necessarily accepted, that comes below. ;; @@ -1528,12 +1520,15 @@ else # system, and we'll never get to this point. kernel= +obj= case $cpu-$vendor in score-*) - os=elf + os= + obj=elf ;; spu-*) - os=elf + os= + obj=elf ;; *-acorn) os=riscix1.2 @@ -1543,28 +1538,35 @@ case $cpu-$vendor in os=gnu ;; arm*-semi) - os=aout + os= + obj=aout ;; c4x-* | tic4x-*) - os=coff + os= + obj=coff ;; c8051-*) - os=elf + os= + obj=elf ;; clipper-intergraph) os=clix ;; hexagon-*) - os=elf + os= + obj=elf ;; tic54x-*) - os=coff + os= + obj=coff ;; tic55x-*) - os=coff + os= + obj=coff ;; tic6x-*) - os=coff + os= + obj=coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1586,19 +1588,24 @@ case $cpu-$vendor in os=sunos3 ;; m68*-cisco) - os=aout + os= + obj=aout ;; mep-*) - os=elf + os= + obj=elf ;; mips*-cisco) - os=elf + os= + obj=elf ;; - mips*-*) - os=elf + mips*-*|nanomips*-*) + os= + obj=elf ;; or32-*) - os=coff + os= + obj=coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=sysv3 @@ -1607,7 +1614,8 @@ case $cpu-$vendor in os=sunos4.1.1 ;; pru-*) - os=elf + os= + obj=elf ;; *-be) os=beos @@ -1688,10 +1696,12 @@ case $cpu-$vendor in os=uxpv ;; *-rom68k) - os=coff + os= + obj=coff ;; *-*bug) - os=coff + os= + obj=coff ;; *-apple) os=macos @@ -1709,10 +1719,11 @@ esac fi -# Now, validate our (potentially fixed-up) OS. +# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ). + case $os in # Sometimes we do "kernel-libc", so those need to count as OSes. - musl* | newlib* | relibc* | uclibc*) + llvm* | musl* | newlib* | relibc* | uclibc*) ;; # Likewise for "kernel-abi" eabi* | gnueabi*) @@ -1720,6 +1731,9 @@ case $os in # VxWorks passes extra cpu info in the 4th filed. simlinux | simwindows | spe) ;; + # See `case $cpu-$os` validation below + ghcjs) + ;; # Now accept the basic system types. # The portable systems comes first. # Each alternative MUST end in a * to match a version number. @@ -1728,7 +1742,7 @@ case $os in | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ | hiux* | abug | nacl* | netware* | windows* \ - | os9* | macos* | osx* | ios* \ + | os9* | macos* | osx* | ios* | tvos* | watchos* \ | mpw* | magic* | mmixware* | mon960* | lnews* \ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* | twizzler* \ @@ -1737,11 +1751,11 @@ case $os in | mirbsd* | netbsd* | dicos* | openedition* | ose* \ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | bosx* | nextstep* | cxux* | oabi* \ + | ptx* | ecoff* | winnt* | domain* | vsta* \ | udi* | lites* | ieee* | go32* | aux* | hcos* \ | chorusrdb* | cegcc* | glidix* | serenity* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | cygwin* | msys* | moss* | proelf* | rtems* \ | midipix* | mingw32* | mingw64* | mint* \ | uxpv* | beos* | mpeix* | udk* | moxiebox* \ | interix* | uwin* | mks* | rhapsody* | darwin* \ @@ -1754,49 +1768,116 @@ case $os in | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ - | fiwix* ) + | fiwix* | mlibc* | cos* | mbr* | ironclad* ) ;; # 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. ;; + # This refers to builds using the UEFI calling convention + # (which depends on the architecture) and PE file format. + # Note that this is both a different calling convention and + # different file format than that of GNU-EFI + # (x86_64-w64-mingw32). + uefi) + ;; none) ;; + kernel* | msvc* ) + # Restricted further below + ;; + '') + if test x"$obj" = x + then + echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2 + fi + ;; + *) + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; *) - echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 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-relibc* | linux-uclibc* ) +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- ) + ;; + uclinux-uclibc*- ) + ;; + managarm-mlibc*- | managarm-kernel*- ) ;; - uclinux-uclibc* ) + windows*-msvc*-) ;; - -dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* ) + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -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 + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 exit 1 ;; - kfreebsd*-gnu* | kopensolaris*-gnu*) + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 + exit 1 ;; - vxworks-simlinux | vxworks-simwindows | vxworks-spe) + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 + exit 1 ;; - nto-qnx*) + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 ;; - os2-emx) + kfreebsd*-gnu*- | kopensolaris*-gnu*-) + ;; + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) + ;; + nto-qnx*-) + ;; + os2-emx-) ;; - *-eabi* | *-gnueabi*) + *-eabi*- | *-gnueabi*-) ;; - -*) + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) # Blank kernel with real OS is always fine. ;; - *-*) - echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 exit 1 ;; esac @@ -1879,7 +1960,7 @@ case $vendor in ;; esac -echo "$cpu-$vendor-${kernel:+$kernel-}$os" +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: diff --git a/vs/sdl2/build-scripts/gen_audio_channel_conversion.c b/vs/sdl2/build-scripts/gen_audio_channel_conversion.c index 99c40b71d3..5d5841d9ef 100644 --- a/vs/sdl2/build-scripts/gen_audio_channel_conversion.c +++ b/vs/sdl2/build-scripts/gen_audio_channel_conversion.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -395,7 +395,7 @@ int main(void) printf( "/*\n" " Simple DirectMedia Layer\n" - " Copyright (C) 1997-2023 Sam Lantinga \n" + " Copyright (C) 1997-2024 Sam Lantinga \n" "\n" " This software is provided 'as-is', without any express or implied\n" " warranty. In no event will the authors be held liable for any damages\n" diff --git a/vs/sdl2/build-scripts/gen_audio_resampler_filter.c b/vs/sdl2/build-scripts/gen_audio_resampler_filter.c index d5c3013737..22b743740a 100644 --- a/vs/sdl2/build-scripts/gen_audio_resampler_filter.c +++ b/vs/sdl2/build-scripts/gen_audio_resampler_filter.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ int main(void) printf( "/*\n" " Simple DirectMedia Layer\n" - " Copyright (C) 1997-2023 Sam Lantinga \n" + " Copyright (C) 1997-2024 Sam Lantinga \n" "\n" " This software is provided 'as-is', without any express or implied\n" " warranty. In no event will the authors be held liable for any damages\n" diff --git a/vs/sdl2/build-scripts/ltmain.sh b/vs/sdl2/build-scripts/ltmain.sh index 70a3e8253f..7be7193b4b 100755 --- a/vs/sdl2/build-scripts/ltmain.sh +++ b/vs/sdl2/build-scripts/ltmain.sh @@ -2418,7 +2418,7 @@ libtool_validate_options () case $host in # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 - *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) + *cygwin* | *mingw* | *windows* | *pw32* | *cegcc* | *solaris2* | *os2*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; @@ -2750,7 +2750,7 @@ EOF # func_convert_core_file_wine_to_w32 ARG # Helper function used by file name conversion functions when $build is *nix, -# and $host is mingw, cygwin, or some other w32 environment. Relies on a +# and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a # correctly configured wine environment available, with the winepath program # in $build's $PATH. # @@ -2782,9 +2782,10 @@ func_convert_core_file_wine_to_w32 () # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and -# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly -# configured wine environment available, with the winepath program in $build's -# $PATH. Assumes ARG has no leading or trailing path separator characters. +# $host is mingw, windows, cygwin, or some other w32 environment. Relies on a +# correctly configured wine environment available, with the winepath program +# in $build's $PATH. Assumes ARG has no leading or trailing path separator +# characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. @@ -3439,7 +3440,7 @@ func_mode_compile () # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in - cygwin* | mingw* | pw32* | os2* | cegcc*) + cygwin* | mingw* | windows* | pw32* | os2* | cegcc*) pic_mode=default ;; esac @@ -4316,7 +4317,7 @@ func_mode_install () 'exit $?' tstripme=$stripme case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $realname in *.dll.a) tstripme= @@ -4429,7 +4430,7 @@ func_mode_install () # Do a test to see if this is really a libtool program. case $host in - *cygwin* | *mingw*) + *cygwin* | *mingw* | *windows*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result @@ -4657,7 +4658,7 @@ extern \"C\" { $RM $export_symbols eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; @@ -4669,7 +4670,7 @@ extern \"C\" { eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; @@ -4683,7 +4684,7 @@ extern \"C\" { func_basename "$dlprefile" name=$func_basename_result case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" @@ -4858,7 +4859,7 @@ static const void *lt_preloaded_setup() { # Transform the symbol file into the correct name. symfileobj=$output_objdir/${my_outputname}S.$objext case $host in - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` @@ -5201,7 +5202,7 @@ func_extract_archives () # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to -# incorporate the script contents within a cygwin/mingw +# incorporate the script contents within a cygwin/mingw/windows # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. @@ -5209,7 +5210,7 @@ func_extract_archives () # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory where it is stored is -# the $objdir directory. This is a cygwin/mingw-specific +# the $objdir directory. This is a cygwin/mingw/windows-specific # behavior. func_emit_wrapper () { @@ -5333,7 +5334,7 @@ func_exec_program_core () " case $host in # Backslashes separate directories on plain windows - *-*-mingw | *-*-os2* | *-cegcc*) + *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 @@ -5401,7 +5402,7 @@ func_exec_program () file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done - # Usually 'no', except on cygwin/mingw when embedded into + # Usually 'no', except on cygwin/mingw/windows when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then @@ -5558,7 +5559,7 @@ EOF /* declarations of non-ANSI functions */ #if defined __MINGW32__ # ifdef __STRICT_ANSI__ -int _putenv (const char *); +_CRTIMP int __cdecl _putenv (const char *); # endif #elif defined __CYGWIN__ # ifdef __STRICT_ANSI__ @@ -5756,7 +5757,7 @@ main (int argc, char *argv[]) { EOF case $host in - *mingw* | *cygwin* ) + *mingw* | *windows* | *cygwin* ) # make stdout use "unix" line endings echo " setmode(1,_O_BINARY);" ;; @@ -5859,7 +5860,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" { char* p; @@ -5901,7 +5902,7 @@ EOF EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* execv doesn't actually work on mingw as expected on unix */ newargz = prepare_spawn (newargz); @@ -6320,7 +6321,7 @@ lt_update_lib_path (const char *name, const char *value) EOF case $host_os in - mingw*) + mingw* | windows*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). @@ -6495,7 +6496,7 @@ func_mode_link () $debug_cmd case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # what system we are compiling for in order to pass an extra @@ -7003,7 +7004,7 @@ func_mode_link () ;; esac case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; @@ -7023,7 +7024,7 @@ func_mode_link () -l*) if test X-lc = "X$arg" || test X-lm = "X$arg"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; @@ -7118,7 +7119,7 @@ func_mode_link () -no-install) case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "'-no-install' is ignored for $host" @@ -7303,13 +7304,26 @@ func_mode_link () # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -specs=* GCC specs files # -stdlib=* select c++ std lib with clang + # -fdiagnostics-color* simply affects output + # -frecord-gcc-switches used to verify flags were respected # -fsanitize=* Clang/GCC memory and address sanitizer + # -fno-sanitize* Clang/GCC memory and address sanitizer + # -shared-libsan Link with shared sanitizer runtimes (Clang) + # -static-libsan Link with static sanitizer runtimes (Clang) # -fuse-ld=* Linker select flags for GCC + # -rtlib=* select c runtime lib with clang + # --unwindlib=* select unwinder library with clang + # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking # -Wa,* Pass flags directly to the assembler + # -Werror, -Werror=* Report (specified) warnings as errors -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ - -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ - -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) + -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*| \ + -stdlib=*|-rtlib=*|--unwindlib=*| \ + -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \ + -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \ + -fdiagnostics-color*|-frecord-gcc-switches| \ + -fuse-ld=*|-Wa,*|-Werror|-Werror=*) func_quote_for_eval "$arg" arg=$func_quote_for_eval_result func_append compile_command " $arg" @@ -8022,7 +8036,7 @@ func_mode_link () fi case $host in # special handling for platforms with PE-DLLs. - *cygwin* | *mingw* | *cegcc* ) + *cygwin* | *mingw* | *windows* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present @@ -8166,7 +8180,7 @@ func_mode_link () if test -n "$library_names" && { test no = "$use_static_libs" || test -z "$old_library"; }; then case $host in - *cygwin* | *mingw* | *cegcc* | *os2*) + *cygwin* | *mingw* | *windows* | *cegcc* | *os2*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no @@ -8236,7 +8250,7 @@ func_mode_link () elif test -n "$soname_spec"; then # bleh windows case $host in - *cygwin* | mingw* | *cegcc*) # | *os2* # SDL customization: removed OS/2 versioning support. + *cygwin* | mingw* | *windows* | *cegcc*) # | *os2* # SDL customization: removed OS/2 versioning support. func_arith $current - $age major=$func_arith_result versuffix=-$major @@ -8845,7 +8859,7 @@ func_mode_link () age=$number_minor revision=$number_revision ;; - freebsd-aout|qnx|sunos) + freebsd-aout|qnx|sco|sunos) current=$number_major revision=$number_minor age=0 @@ -9146,7 +9160,7 @@ func_mode_link () if test yes = "$build_libtool_libs"; then if test -n "$rpath"; then case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) @@ -9660,7 +9674,7 @@ EOF orig_export_symbols= case $host_os in - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile func_dll_def_p "$export_symbols" || { @@ -10330,7 +10344,7 @@ EOF esac fi case $host in - *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) + *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; @@ -10408,7 +10422,7 @@ EOF # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=false ;; - *cygwin* | *mingw* ) + *cygwin* | *mingw* | *windows* ) test yes = "$build_libtool_libs" || wrappers_required=false ;; *) @@ -10561,7 +10575,7 @@ EOF *) exeext= ;; esac case $host in - *cygwin* | *mingw* ) + *cygwin* | *mingw* | windows* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result @@ -10893,7 +10907,7 @@ EOF # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in - *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test -n "$bindir"; then func_relative_path "$install_libdir" "$bindir" diff --git a/vs/sdl2/build-scripts/update-copyright.sh b/vs/sdl2/build-scripts/update-copyright.sh index c69ec72934..9bb46eac5b 100755 --- a/vs/sdl2/build-scripts/update-copyright.sh +++ b/vs/sdl2/build-scripts/update-copyright.sh @@ -1,7 +1,15 @@ #!/bin/sh -find . -type f -exec grep -Il "Copyright" {} \; \ +if [ "$SED" = "" ]; then + if type gsed >/dev/null; then + SED=gsed + else + SED=sed + fi +fi + +find . -type f \ | 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"; \ + LC_ALL=C $SED -b -i "s/\(.*Copyright.*\)[0-9]\{4\}\( *Sam Lantinga\)/\1`date +%Y`\2/" "$file"; \ done diff --git a/vs/sdl2/cmake/CheckCPUArchitecture.cmake b/vs/sdl2/cmake/CheckCPUArchitecture.cmake index ab53b9f28f..7e3e459470 100644 --- a/vs/sdl2/cmake/CheckCPUArchitecture.cmake +++ b/vs/sdl2/cmake/CheckCPUArchitecture.cmake @@ -1,42 +1,42 @@ -include(CheckCSourceCompiles) -include(CMakePushCheckState) - -function(_internal_check_cpu_architecture macro_check NAME VARIABLE) - cmake_push_check_state(RESET) - string(TOUPPER "${NAME}" UPPER_NAME) - set(CACHE_VARIABLE "CHECK_CPU_ARCHITECTURE_${UPPER_NAME}") - set(test_src " -int main(int argc, char *argv[]) { -#if ${macro_check} - return 0; -#else - choke -#endif -} -") - check_c_source_compiles("${test_src}" "${CACHE_VARIABLE}") - cmake_pop_check_state() - if(${CACHE_VARIABLE}) - set(${VARIABLE} "TRUE" PARENT_SCOPE) - else() - set(${VARIABLE} "FALSE" PARENT_SCOPE) - endif() -endfunction() - -function(check_cpu_architecture ARCH VARIABLE) - if(ARCH STREQUAL "x86") - _internal_check_cpu_architecture("defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" x86 ${VARIABLE}) - elseif(ARCH STREQUAL "x64") - _internal_check_cpu_architecture("defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" x64 ${VARIABLE}) - elseif(ARCH STREQUAL "arm32") - _internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE}) - elseif(ARCH STREQUAL "arm64") - _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) - elseif(ARCH STREQUAL "loongarch64") - _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) - else() - message(WARNING "Unknown CPU architectures (${ARCH}).") - set(${VARIABLE} FALSE) - endif() - set("${VARIABLE}" "${${VARIABLE}}" PARENT_SCOPE) -endfunction() +include(CheckCSourceCompiles) +include(CMakePushCheckState) + +function(_internal_check_cpu_architecture macro_check NAME VARIABLE) + cmake_push_check_state(RESET) + string(TOUPPER "${NAME}" UPPER_NAME) + set(CACHE_VARIABLE "CHECK_CPU_ARCHITECTURE_${UPPER_NAME}") + set(test_src " +int main(int argc, char *argv[]) { +#if ${macro_check} + return 0; +#else + choke +#endif +} +") + check_c_source_compiles("${test_src}" "${CACHE_VARIABLE}") + cmake_pop_check_state() + if(${CACHE_VARIABLE}) + set(${VARIABLE} "TRUE" PARENT_SCOPE) + else() + set(${VARIABLE} "FALSE" PARENT_SCOPE) + endif() +endfunction() + +function(check_cpu_architecture ARCH VARIABLE) + if(ARCH STREQUAL "x86") + _internal_check_cpu_architecture("defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" x86 ${VARIABLE}) + elseif(ARCH STREQUAL "x64") + _internal_check_cpu_architecture("defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" x64 ${VARIABLE}) + elseif(ARCH STREQUAL "arm32") + _internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE}) + elseif(ARCH STREQUAL "arm64") + _internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE}) + elseif(ARCH STREQUAL "loongarch64") + _internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE}) + else() + message(WARNING "Unknown CPU architectures (${ARCH}).") + set(${VARIABLE} FALSE) + endif() + set("${VARIABLE}" "${${VARIABLE}}" PARENT_SCOPE) +endfunction() diff --git a/vs/sdl2/cmake/macros.cmake b/vs/sdl2/cmake/macros.cmake index 69a5d5464a..5060923e8e 100644 --- a/vs/sdl2/cmake/macros.cmake +++ b/vs/sdl2/cmake/macros.cmake @@ -124,3 +124,25 @@ if(CMAKE_VERSION VERSION_LESS 3.13.0) link_directories(${ARGN}) endmacro() endif() + +# CMP0087: install(CODE) and install(SCRIPT) support generator expressions. +if(POLICY CMP0087) + cmake_policy(SET CMP0087 NEW) +endif() +function(SDL_install_pdb TARGET DIRECTORY) + get_property(type TARGET ${TARGET} PROPERTY TYPE) + if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$") + if(NOT CMAKE_VERSION VERSION_LESS 3.1) + install(FILES $ DESTINATION "${DIRECTORY}" OPTIONAL) + endif() + elseif(type STREQUAL "STATIC_LIBRARY") + if(NOT CMAKE_VERSION VERSION_LESS 3.15) + # FIXME: Use $) + target_include_directories(sdl-build-options SYSTEM INTERFACE $) set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"") set(HAVE_ALSA_SHARED TRUE) else() @@ -160,7 +166,7 @@ endmacro() # - HAVE_SDL_LOADSO opt macro(CheckPulseAudio) if(SDL_PULSEAUDIO) - pkg_check_modules(PKG_PULSEAUDIO libpulse-simple) + pkg_check_modules(PKG_PULSEAUDIO libpulse>=0.9.15) if(PKG_PULSEAUDIO_FOUND) set(HAVE_PULSEAUDIO TRUE) file(GLOB PULSEAUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/pulseaudio/*.c) @@ -170,9 +176,9 @@ macro(CheckPulseAudio) if(SDL_PULSEAUDIO_SHARED AND NOT HAVE_SDL_LOADSO) message_warn("You must have SDL_LoadObject() support for dynamic PulseAudio loading") endif() - FindLibraryAndSONAME("pulse-simple" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS}) - if(SDL_PULSEAUDIO_SHARED AND PULSE_SIMPLE_LIB AND HAVE_SDL_LOADSO) - set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_SIMPLE_LIB_SONAME}\"") + FindLibraryAndSONAME("pulse" LIBDIRS ${PKG_PULSEAUDIO_LIBRARY_DIRS}) + if(SDL_PULSEAUDIO_SHARED AND PULSE_LIB AND HAVE_SDL_LOADSO) + set(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC "\"${PULSE_LIB_SONAME}\"") set(HAVE_PULSEAUDIO_SHARED TRUE) else() list(APPEND EXTRA_LDFLAGS ${PKG_PULSEAUDIO_LDFLAGS}) @@ -374,7 +380,7 @@ macro(CheckLibSampleRate) set(HAVE_LIBSAMPLERATE TRUE) set(HAVE_LIBSAMPLERATE_H TRUE) if(SDL_LIBSAMPLERATE_SHARED) - target_include_directories(sdl-build-options INTERFACE $) + target_include_directories(sdl-build-options SYSTEM INTERFACE $) if(NOT HAVE_SDL_LOADSO) message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading") else() @@ -465,7 +471,9 @@ macro(CheckX11) list(APPEND SOURCE_FILES ${X11_SOURCES}) set(SDL_VIDEO_DRIVER_X11 1) - # !!! FIXME: why is this disabled for Apple? + # Note: Disabled on Apple because the dynamic mode backend for X11 doesn't + # work properly on Apple during several issues like inconsistent paths + # among platforms. See #6778 (https://github.com/libsdl-org/SDL/issues/6778) if(APPLE) set(SDL_X11_SHARED OFF) endif() @@ -677,7 +685,7 @@ macro(CheckWayland) if(WAYLAND_FOUND) target_link_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_LIBRARY_DIRS}") - target_include_directories(sdl-build-options INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}") + target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_WAYLAND_INCLUDE_DIRS}") set(HAVE_WAYLAND TRUE) set(HAVE_SDL_VIDEO TRUE) @@ -687,7 +695,7 @@ macro(CheckWayland) # We have to generate some protocol interface code for some unstable Wayland features. file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols") - target_include_directories(sdl-build-options INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols") + target_include_directories(sdl-build-options SYSTEM INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/wayland-generated-protocols") file(GLOB WAYLAND_PROTOCOLS_XML RELATIVE "${SDL2_SOURCE_DIR}/wayland-protocols/" "${SDL2_SOURCE_DIR}/wayland-protocols/*.xml") foreach(_XML ${WAYLAND_PROTOCOLS_XML}) @@ -723,7 +731,7 @@ macro(CheckWayland) set(HAVE_WAYLAND_LIBDECOR TRUE) set(HAVE_LIBDECOR_H 1) target_link_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_LIBRARY_DIRS}") - target_include_directories(sdl-build-options INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}") + target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_LIBDECOR_INCLUDE_DIRS}") if(SDL_WAYLAND_LIBDECOR_SHARED AND NOT HAVE_SDL_LOADSO) message_warn("You must have SDL_LoadObject() support for dynamic libdecor loading") endif() @@ -905,6 +913,22 @@ macro(CheckOpenGLES) endif() endmacro() +# Requires: +# - EGL +macro(CheckQNXScreen) + if(QNX AND HAVE_OPENGL_EGL) + check_c_source_compiles(" + #include + int main (int argc, char** argv) { return 0; }" HAVE_QNX_SCREEN) + if(HAVE_QNX_SCREEN) + set(SDL_VIDEO_DRIVER_QNX 1) + file(GLOB QNX_VIDEO_SOURCES ${SDL2_SOURCE_DIR}/src/video/qnx/*.c) + list(APPEND SOURCE_FILES ${QNX_VIDEO_SOURCES}) + list(APPEND EXTRA_LIBS screen EGL) + endif() + endif() +endmacro() + # Requires: # - nada # Optional: @@ -955,6 +979,8 @@ macro(CheckPTHREAD) elseif(EMSCRIPTEN) set(PTHREAD_CFLAGS "-D_REENTRANT -pthread") set(PTHREAD_LDFLAGS "-pthread") + elseif(QNX) + # pthread support is baked in else() set(PTHREAD_CFLAGS "-D_REENTRANT") set(PTHREAD_LDFLAGS "-lpthread") @@ -1297,7 +1323,7 @@ macro(CheckKMSDRM) pkg_check_modules(PKG_KMSDRM libdrm gbm egl) if(PKG_KMSDRM_FOUND AND HAVE_OPENGL_EGL) target_link_directories(sdl-build-options INTERFACE ${PKG_KMSDRM_LIBRARY_DIRS}) - target_include_directories(sdl-build-options INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}") + target_include_directories(sdl-build-options SYSTEM INTERFACE "${PKG_KMSDRM_INCLUDE_DIRS}") set(HAVE_KMSDRM TRUE) set(HAVE_SDL_VIDEO TRUE) @@ -1336,3 +1362,50 @@ macro(CheckLibUDev) endif() endif() endmacro() + + +macro(CheckLibUnwind) + set(found_libunwind FALSE) + set(_libunwind_src "#include \nint main() {unw_context_t context; unw_getcontext(&context); return 0;}") + + if(NOT found_libunwind) + cmake_push_check_state() + check_c_source_compiles("${_libunwind_src}" LIBC_HAS_WORKING_LIBUNWIND) + cmake_pop_check_state() + if(LIBC_HAS_WORKING_LIBUNWIND) + set(found_libunwind TRUE) + endif() + endif() + + if(NOT found_libunwind) + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_LIBRARIES "unwind") + check_c_source_compiles("${_libunwind_src}" LIBUNWIND_HAS_WORKINGLIBUNWIND) + cmake_pop_check_state() + if(LIBUNWIND_HAS_WORKINGLIBUNWIND) + set(found_libunwind TRUE) + list(APPEND EXTRA_TEST_LIBS unwind) + endif() + endif() + + if(NOT found_libunwind) + set(LibUnwind_PKG_CONFIG_SPEC libunwind libunwind-generic) + pkg_check_modules(PC_LIBUNWIND IMPORTED_TARGET ${LibUnwind_PKG_CONFIG_SPEC}) + if(PC_LIBUNWIND_FOUND) + cmake_push_check_state() + list(APPEND CMAKE_REQUIRED_LIBRARIES ${PC_LIBUNWIND_LIBRARIES}) + list(APPEND CMAKE_REQUIRED_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS}) + check_c_source_compiles("${_libunwind_src}" PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) + cmake_pop_check_state() + if(PC_LIBUNWIND_HAS_WORKING_LIBUNWIND) + set(found_libunwind TRUE) + list(APPEND EXTRA_TEST_LIBS ${PC_LIBUNWIND_LIBRARIES}) + list(APPEND EXTRA_TEST_INCLUDES ${PC_LIBUNWIND_INCLUDE_DIRS}) + endif() + endif() + endif() + + if(found_libunwind) + set(HAVE_LIBUNWIND_H TRUE) + endif() +endmacro() diff --git a/vs/sdl2/cmake/sdlplatform.cmake b/vs/sdl2/cmake/sdlplatform.cmake index 7daaa2352e..6d8ece6ac5 100644 --- a/vs/sdl2/cmake/sdlplatform.cmake +++ b/vs/sdl2/cmake/sdlplatform.cmake @@ -28,6 +28,8 @@ macro(SDL_DetectCMakePlatform) set(SDL_CMAKE_PLATFORM AIX) elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*") set(SDL_CMAKE_PLATFORM MINIX) + elseif(CMAKE_SYSTEM_NAME MATCHES "QNX") + set(SDL_CMAKE_PLATFORM QNX) endif() elseif(APPLE) if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*") diff --git a/vs/sdl2/cmake/test/main_gui.c b/vs/sdl2/cmake/test/main_gui.c index 4ffe9be1c4..ca2d92ecd4 100644 --- a/vs/sdl2/cmake/test/main_gui.c +++ b/vs/sdl2/cmake/test/main_gui.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { 640, 480, SDL_WINDOW_SHOWN ); - if (window == NULL) { + if (!window) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return 1; } diff --git a/vs/sdl2/configure b/vs/sdl2/configure index bc4f7f628e..4c2bb0444a 100755 --- a/vs/sdl2/configure +++ b/vs/sdl2/configure @@ -845,6 +845,7 @@ enable_assertions enable_dependency_tracking enable_libc enable_system_iconv +enable_libiconv enable_gcc_atomics enable_atomic enable_audio @@ -872,7 +873,6 @@ enable_sse2 enable_sse3 enable_altivec enable_lsx -enable_lasx enable_oss enable_alsa with_alsa_prefix @@ -1641,7 +1641,9 @@ Optional Features: Use gcc -MMD -MT dependency tracking [default=yes] --enable-libc Use the system C library [default=yes] --enable-system-iconv Use iconv() from system-installed libraries - [default=yes] + [default=no for windows, yes for others] + --enable-libiconv Prefer iconv() from libiconv, if available, over + libc version [default=no] --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] @@ -1672,7 +1674,6 @@ Optional Features: --enable-sse3 use SSE3 assembly routines [default=maybe] --enable-altivec use Altivec assembly routines [default=yes] --enable-lsx use LSX assembly routines [default=yes] - --enable-lasx use LASX 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 @@ -3506,8 +3507,8 @@ orig_CFLAGS="$CFLAGS" # See docs/release_checklist.md SDL_MAJOR_VERSION=2 -SDL_MINOR_VERSION=28 -SDL_MICRO_VERSION=2 +SDL_MINOR_VERSION=30 +SDL_MICRO_VERSION=4 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` @@ -5032,7 +5033,7 @@ if test yes = "$GCC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 printf %s "checking for ld used by $CC... " >&6; } case $host in - *-*-mingw*) + *-*-mingw* | *-*-windows*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) @@ -5159,7 +5160,7 @@ else # Tru64's nm complains that /dev/null is an invalid object file # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty case $build_os in - mingw*) lt_bad_file=conftest.nm/nofile ;; + mingw* | windows*) lt_bad_file=conftest.nm/nofile ;; *) lt_bad_file=/dev/null ;; esac case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in @@ -5388,7 +5389,7 @@ else $as_nop lt_cv_sys_max_cmd_len=-1; ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, @@ -5552,7 +5553,7 @@ else $as_nop case $host in *-*-mingw* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) @@ -5565,7 +5566,7 @@ else $as_nop ;; *-*-cygwin* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) @@ -5600,9 +5601,9 @@ else $as_nop #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in - *-*-mingw* ) + *-*-mingw* | *-*-windows* ) case $build in - *-*-mingw* ) # actually msys + *-*-mingw* | *-*-windows* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac @@ -5636,7 +5637,7 @@ case $reload_flag in esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) if test yes != "$GCC"; then reload_cmds=false fi @@ -5809,7 +5810,7 @@ cygwin*) lt_cv_deplibs_check_method=pass_all # SDL customization ;; -mingw* | pw32*) +mingw* | windows* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. @@ -5977,7 +5978,7 @@ file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in - mingw* | pw32*) + mingw* | windows* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else @@ -6131,7 +6132,7 @@ else $as_nop lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh; # decide which one to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in @@ -6569,15 +6570,8 @@ old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then - case $host_os in - bitrig* | openbsd*) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" - ;; - *) - old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" - ;; - esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" fi case $host_os in @@ -6704,7 +6698,7 @@ case $host_os in aix*) symcode='[BCDT]' ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) @@ -6783,7 +6777,7 @@ $lt_c_name_lib_hook\ # Handle CRLF in mingw tool chain opt_cr= case $build_os in -mingw*) +mingw* | windows*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac @@ -6798,7 +6792,7 @@ for ac_symprfx in "" "_"; do if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function, # D for any global variable and I for any imported variable. - # Also find C++ and __fastcall symbols from MSVC++, + # Also find C++ and __fastcall symbols from MSVC++ or ICC, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ @@ -7232,7 +7226,7 @@ mips64*-*linux*) ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ -s390*-*linux*|s390*-*tpf*|sparc*-*linux*) +s390*-*linux*|s390*-*tpf*|sparc*-*linux*|x86_64-gnu*) # Find out what ABI is being produced by ac_compile, and set linker # options accordingly. Note that the listed cases only cover the # situations where additional linker options are needed (such as when @@ -7251,7 +7245,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) case `/usr/bin/file conftest.o` in *x86-64*) LD="${LD-ld} -m elf32_x86_64" @@ -7280,7 +7274,7 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; - x86_64-*linux*) + x86_64-*linux*|x86_64-gnu*) LD="${LD-ld} -m elf_x86_64" ;; powerpcle-*linux*|powerpc64le-*linux*) @@ -8276,7 +8270,7 @@ fi enable_win32_dll=yes case $host in -*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) +*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 @@ -8892,8 +8886,8 @@ esac ofile=libtool can_build_shared=yes -# All known linkers require a '.a' archive for static linking (except MSVC, -# which needs '.lib'). +# All known linkers require a '.a' archive for static linking (except MSVC and +# ICC, which need '.lib'). libext=a with_gnu_ld=$lt_cv_prog_gnu_ld @@ -9217,7 +9211,7 @@ lt_prog_compiler_static= # PIC is the default for these OSes. ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -9320,7 +9314,7 @@ lt_prog_compiler_static= esac ;; - mingw* | cygwin* | pw32* | os2* | cegcc*) + mingw* | windows* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' @@ -9827,16 +9821,16 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries extract_expsyms_cmds= case $host_os in - cygwin* | mingw* | pw32* | cegcc*) - # FIXME: the MSVC++ port hasn't been tested in a loooong time + cygwin* | mingw* | windows* | pw32* | cegcc*) + # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. if test yes != "$GCC"; then with_gnu_ld=no fi ;; interix*) - # we just hope/assume this is gcc and not c89 (= MSVC++) + # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) with_gnu_ld=yes ;; openbsd* | bitrig*) @@ -9942,7 +9936,7 @@ _LT_EOF fi ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' @@ -10487,14 +10481,14 @@ fi export_dynamic_flag_spec=-rdynamic ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) # When not using gcc, we currently assume that we are using - # Microsoft Visual C++. + # Microsoft Visual C++ or Intel C++ Compiler. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. case $cc_basename in - cl*) - # Native MSVC + cl* | icl*) + # Native MSVC or ICC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes @@ -10504,14 +10498,14 @@ fi # Tell ltmain to make .dll files, not .so files. shrext_cmds=.dll # FIXME: Setting linknames here is a bad hack. - archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + archive_cmds='$CC -Fe $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then cp "$export_symbols" "$output_objdir/$soname.def"; echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; else $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; fi~ - $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + $CC -Fe $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' @@ -10535,7 +10529,7 @@ fi fi' ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. @@ -11301,7 +11295,7 @@ if test yes = "$GCC"; then *) lt_awk_arg='/^libraries:/' ;; esac case $host_os in - mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; + mingw* | windows* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;; *) lt_sed_strip_eq='s|=/|/|g' ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` @@ -11359,7 +11353,7 @@ BEGIN {RS = " "; FS = "/|\n";} { # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in - mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + mingw* | windows* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's|/\([A-Za-z]:\)|\1|g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` @@ -11527,7 +11521,7 @@ bsdi[45]*) # libtool to hard-code these into programs ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no @@ -11560,7 +11554,7 @@ cygwin* | mingw* | pw32* | cegcc*) sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; - mingw* | cegcc*) + mingw* | windows* | cegcc*) # MinGW DLLs use traditional 'lib' prefix #soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization @@ -11573,14 +11567,14 @@ cygwin* | mingw* | pw32* | cegcc*) dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in - mingw*) + mingw* | windows*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' @@ -11630,7 +11624,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -12300,7 +12294,7 @@ else lt_cv_dlopen_self=yes ;; - mingw* | pw32* | cegcc*) + mingw* | windows* | pw32* | cegcc*) lt_cv_dlopen=LoadLibrary lt_cv_dlopen_libs= ;; @@ -14576,7 +14570,7 @@ if test yes = "$GCC"; then { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 printf %s "checking for ld used by $CC... " >&6; } case $host in - *-*-mingw*) + *-*-mingw* | *-*-windows*) # gcc leaves a trailing carriage return, which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) @@ -14710,7 +14704,7 @@ with_gnu_ld=$lt_cv_prog_gnu_ld # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[-]L"' else GXX=no @@ -15008,10 +15002,10 @@ fi esac ;; - cygwin* | mingw* | pw32* | cegcc*) + cygwin* | mingw* | windows* | pw32* | cegcc*) case $GXX,$cc_basename in - ,cl* | no,cl*) - # Native MSVC + ,cl* | no,cl* | ,icl* | no,icl*) + # Native MSVC or ICC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec_CXX=' ' @@ -15207,7 +15201,7 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "[-]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -15272,7 +15266,7 @@ fi # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. - output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "[-]L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test yes = "$GXX"; then @@ -15611,7 +15605,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[-]L"' else # FIXME: insert proper C++ library support @@ -15695,7 +15689,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[-]L"' else # g++ 2.7 appears to require '-G' NOT '-shared' on this # platform. @@ -15706,7 +15700,7 @@ fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. - output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "[-]L"' fi hardcode_libdir_flag_spec_CXX='$wl-R $wl$libdir' @@ -16020,7 +16014,7 @@ lt_prog_compiler_static_CXX= beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). # Although the cygwin gcc ignores -fPIC, still need this for old-style @@ -16095,7 +16089,7 @@ lt_prog_compiler_static_CXX= ;; esac ;; - mingw* | cygwin* | os2* | pw32* | cegcc*) + mingw* | windows* | cygwin* | os2* | pw32* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic_CXX='-DDLL_EXPORT' @@ -16589,9 +16583,9 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries pw32*) export_symbols_cmds_CXX=$ltdll_cmds ;; - cygwin* | mingw* | cegcc*) + cygwin* | mingw* | windows* | cegcc*) case $cc_basename in - cl*) + cl* | icl*) exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' ;; *) @@ -16911,7 +16905,7 @@ bsdi[45]*) # libtool to hard-code these into programs ;; -cygwin* | mingw* | pw32* | cegcc*) +cygwin* | mingw* | windows* | pw32* | cegcc*) version_type=windows shrext_cmds=.dll need_version=no @@ -16943,7 +16937,7 @@ cygwin* | mingw* | pw32* | cegcc*) soname_spec='`echo $libname | sed -e 's/^lib//'`$shared_ext' # SDL customization ;; - mingw* | cegcc*) + mingw* | windows* | cegcc*) # MinGW DLLs use traditional 'lib' prefix #soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' soname_spec='`echo $libname | $SED -e 's/^lib//'`$shared_ext' # SDL customization @@ -16956,14 +16950,14 @@ cygwin* | mingw* | pw32* | cegcc*) dynamic_linker='Win32 ld.exe' ;; - *,cl*) - # Native MSVC + *,cl* | *,icl*) + # Native MSVC or ICC libname_spec='$name' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='$libname.dll.lib' case $build_os in - mingw*) + mingw* | windows*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' @@ -17013,7 +17007,7 @@ cygwin* | mingw* | pw32* | cegcc*) ;; *) - # Assume MSVC wrapper + # Assume MSVC and ICC wrapper library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' dynamic_linker='Win32 ld.exe' ;; @@ -18820,12 +18814,26 @@ else $as_nop fi +enable_system_iconv_default=yes +case "$host" in + *-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*) + enable_system_iconv_default=no + ;; +esac # Check whether --enable-system-iconv was given. if test ${enable_system_iconv+y} then : enableval=$enable_system_iconv; else $as_nop - enable_system_iconv=yes + enable_system_iconv=$enable_system_iconv_default +fi + +# Check whether --enable-libiconv was given. +if test ${enable_libiconv+y} +then : + enableval=$enable_libiconv; +else $as_nop + enable_libiconv=no fi @@ -18942,12 +18950,6 @@ if test "x$ac_cv_header_signal_h" = xyes then : printf "%s\n" "#define HAVE_SIGNAL_H 1" >>confdefs.h -fi -ac_fn_c_check_header_compile "$LINENO" "linux/input.h" "ac_cv_header_linux_input_h" "$ac_includes_default" -if test "x$ac_cv_header_linux_input_h" = xyes -then : - printf "%s\n" "#define HAVE_LINUX_INPUT_H 1" >>confdefs.h - fi @@ -19745,6 +19747,18 @@ if test "x$ac_cv_func_poll" = xyes then : printf "%s\n" "#define HAVE_POLL 1" >>confdefs.h +fi +ac_fn_c_check_func "$LINENO" "memfd_create" "ac_cv_func_memfd_create" +if test "x$ac_cv_func_memfd_create" = xyes +then : + printf "%s\n" "#define HAVE_MEMFD_CREATE 1" >>confdefs.h + +fi +ac_fn_c_check_func "$LINENO" "posix_fallocate" "ac_cv_func_posix_fallocate" +if test "x$ac_cv_func_posix_fallocate" = xyes +then : + printf "%s\n" "#define HAVE_POSIX_FALLOCATE 1" >>confdefs.h + fi ac_fn_c_check_func "$LINENO" "_Exit" "ac_cv_func__Exit" if test "x$ac_cv_func__Exit" = xyes @@ -20049,53 +20063,90 @@ fi if test x$enable_system_iconv = xyes; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv_open in -liconv" >&5 -printf %s "checking for iconv_open in -liconv... " >&6; } -if test ${ac_cv_lib_iconv_iconv_open+y} -then : - printf %s "(cached) " >&6 -else $as_nop - ac_check_lib_save_LIBS=$LIBS -LIBS="-liconv $LIBS" -cat confdefs.h - <<_ACEOF >conftest.$ac_ext + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv in libc" >&5 +printf %s "checking for iconv in libc... " >&6; } + 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. */ -char iconv_open (); + #define LIBICONV_PLUG 1 /* in case libiconv header is in include path */ + #include + #include + int main (void) { -return iconv_open (); + + iconv_open(NULL,NULL); + ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO" then : - ac_cv_lib_iconv_iconv_open=yes + have_libc_iconv=yes else $as_nop - ac_cv_lib_iconv_iconv_open=no + have_libc_iconv=no fi rm -f core conftest.err conftest.$ac_objext conftest.beam \ conftest$ac_exeext conftest.$ac_ext -LIBS=$ac_check_lib_save_LIBS -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_iconv_iconv_open" >&5 -printf "%s\n" "$ac_cv_lib_iconv_iconv_open" >&6; } -if test "x$ac_cv_lib_iconv_iconv_open" = xyes + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_libc_iconv" >&5 +printf "%s\n" "$have_libc_iconv" >&6; } + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv in libiconv" >&5 +printf %s "checking for iconv in libiconv... " >&6; } + save_LIBS="$LIBS" + LIBS="$LIBS -liconv" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #include + #include + +int +main (void) +{ + + iconv_open(NULL,NULL); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO" then : - LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv" + have_libiconv=yes +else $as_nop + have_libiconv=no fi +rm -f core conftest.err conftest.$ac_objext conftest.beam \ + conftest$ac_exeext conftest.$ac_ext + LIBS="$save_LIBS" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_libiconv" >&5 +printf "%s\n" "$have_libiconv" >&6; } - ac_fn_c_check_func "$LINENO" "iconv" "ac_cv_func_iconv" -if test "x$ac_cv_func_iconv" = xyes -then : - printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h + if test x$have_libc_iconv = xyes || test x$have_libiconv = xyes; then + +printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h -fi + if test x$have_libiconv = xyes; then + if test x$have_libc_iconv != xyes; then + use_libiconv=yes + elif test x$enable_libiconv = xyes; then + use_libiconv=yes + fi + fi + if test x$use_libiconv = xyes; then + +printf "%s\n" "#define SDL_USE_LIBICONV 1" >>confdefs.h + + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv" + echo "-- Using iconv from libiconv" + else + echo "-- Using iconv from libc" + fi + fi fi ac_fn_c_check_member "$LINENO" "struct sigaction" "sa_sigaction" "ac_cv_member_struct_sigaction_sa_sigaction" "#include @@ -21059,80 +21110,6 @@ printf "%s\n" "#define HAVE_LSXINTRIN_H 1" >>confdefs.h fi - # Check whether --enable-lasx was given. -if test ${enable_lasx+y} -then : - enableval=$enable_lasx; -else $as_nop - enable_LASX=yes -fi - - if test x$enable_LASX = xyes; then - save_CFLAGS="$CFLAGS" - have_gcc_lasx=no - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -mlasx option" >&5 -printf %s "checking for GCC -mlasx option... " >&6; } - lasx_CFLAGS="-mlasx" - CFLAGS="$save_CFLAGS $lasx_CFLAGS" - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - have_gcc_lasx=yes -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_lasx" >&5 -printf "%s\n" "$have_gcc_lasx" >&6; } - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_lasx = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS" - SUMMARY_math="${SUMMARY_math} lasx" - fi - fi - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for lasxintrin.h" >&5 -printf %s "checking for lasxintrin.h... " >&6; } - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - have_lasxintrin_h_hdr=yes -else $as_nop - have_lasxintrin_h_hdr=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_lasxintrin_h_hdr" >&5 -printf "%s\n" "$have_lasxintrin_h_hdr" >&6; } - if test x$have_lasxintrin_h_hdr = xyes; then - -printf "%s\n" "#define HAVE_LASXINTRIN_H 1" >>confdefs.h - - fi - CheckOSS() { # Check whether --enable-oss was given. @@ -22083,19 +22060,19 @@ fi if test x$enable_audio = xyes -a x$enable_pulseaudio = xyes; then pkg_failed=no -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libpulse-simple >= 0.9" >&5 -printf %s "checking for libpulse-simple >= 0.9... " >&6; } +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libpulse >= 0.9.15" >&5 +printf %s "checking for libpulse >= 0.9.15... " >&6; } if test -n "$PULSEAUDIO_CFLAGS"; then pkg_cv_PULSEAUDIO_CFLAGS="$PULSEAUDIO_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse-simple >= 0.9") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse >= 0.9.15\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpulse >= 0.9.15") 2>&5 ac_status=$? printf "%s\n" "$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` + pkg_cv_PULSEAUDIO_CFLAGS=`$PKG_CONFIG --cflags "libpulse >= 0.9.15" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22107,12 +22084,12 @@ if test -n "$PULSEAUDIO_LIBS"; then pkg_cv_PULSEAUDIO_LIBS="$PULSEAUDIO_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ - { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse-simple >= 0.9\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libpulse-simple >= 0.9") 2>&5 + { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libpulse >= 0.9.15\""; } >&5 + ($PKG_CONFIG --exists --print-errors "libpulse >= 0.9.15") 2>&5 ac_status=$? printf "%s\n" "$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` + pkg_cv_PULSEAUDIO_LIBS=`$PKG_CONFIG --libs "libpulse >= 0.9.15" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes @@ -22133,9 +22110,9 @@ else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpulse-simple >= 0.9" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libpulse >= 0.9.15" 2>&1` else - PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpulse-simple >= 0.9" 2>&1` + PULSEAUDIO_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libpulse >= 0.9.15" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$PULSEAUDIO_PKG_ERRORS" >&5 @@ -22162,7 +22139,7 @@ else $as_nop enable_pulseaudio_shared=yes fi - pulseaudio_lib=`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` + pulseaudio_lib=`find_lib "libpulse.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'` printf "%s\n" "#define SDL_AUDIO_DRIVER_PULSEAUDIO 1" >>confdefs.h @@ -22176,7 +22153,7 @@ printf "%s\n" "$as_me: WARNING: You must have SDL_LoadObject() support for dynam fi if test x$have_loadso = xyes && \ test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then - echo "-- dynamic libpulse-simple -> $pulseaudio_lib" + echo "-- dynamic libpulse -> $pulseaudio_lib" printf "%s\n" "#define SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC \"$pulseaudio_lib\"" >>confdefs.h @@ -26405,6 +26382,14 @@ printf "%s\n" "#define SDL_VIDEO_VULKAN 1" >>confdefs.h CheckInputEvents() { + ac_fn_c_check_header_compile "$LINENO" "linux/input.h" "ac_cv_header_linux_input_h" "$ac_includes_default" +if test "x$ac_cv_header_linux_input_h" = xyes +then : + printf "%s\n" "#define HAVE_LINUX_INPUT_H 1" >>confdefs.h + +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for Linux 2.4 unified input interface" >&5 printf %s "checking for Linux 2.4 unified input interface... " >&6; } use_input_events=no @@ -27528,18 +27513,14 @@ then : have_d3d11=yes fi - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for d3d12 Windows SDK version" >&5 -printf %s "checking for d3d12 Windows SDK version... " >&6; } + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for compatible d3d12 headers" >&5 +printf %s "checking for compatible d3d12 headers... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include -#include #include +#include ID3D12Device1 *device; -#if WDK_NTDDI_VERSION <= 0x0A000008 -asdf -#endif int main (void) @@ -27558,6 +27539,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_d3d12" >&5 printf "%s\n" "$have_d3d12" >&6; } + ac_fn_c_check_header_compile "$LINENO" "ddraw.h" "ac_cv_header_ddraw_h" "$ac_includes_default" if test "x$ac_cv_header_ddraw_h" = xyes then : @@ -27622,77 +27604,16 @@ else $as_nop fi if test x$enable_xinput = xyes; then - have_xinput_gamepadex=no - have_xinput_stateex=no ac_fn_c_check_header_compile "$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 - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_GAMEPAD_EX" >&5 -printf %s "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 (void) -{ - - ; - 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.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xinput_gamepadex" >&5 -printf "%s\n" "$have_xinput_gamepadex" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for struct XINPUT_STATE_EX" >&5 -printf %s "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 (void) -{ - - ; - 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.beam conftest.$ac_ext - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_xinput_stateex" >&5 -printf "%s\n" "$have_xinput_stateex" >&6; } - if test x$have_xinput = xyes; then printf "%s\n" "#define HAVE_XINPUT_H 1" >>confdefs.h - fi - if test x$have_xinput_gamepadex = xyes; then - -printf "%s\n" "#define HAVE_XINPUT_GAMEPAD_EX 1" >>confdefs.h - - fi - if test x$have_xinput_stateex = xyes; then - -printf "%s\n" "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h - fi fi diff --git a/vs/sdl2/configure.ac b/vs/sdl2/configure.ac index 48625e7c16..67ef7ebfce 100644 --- a/vs/sdl2/configure.ac +++ b/vs/sdl2/configure.ac @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -AC_PREREQ([2.63]) +AC_PREREQ([2.65]) AC_INIT AC_CONFIG_SRCDIR([src/SDL.c]) AC_CONFIG_HEADERS([include/SDL_config.h]) @@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS" dnl Set various version strings - taken gratefully from the GTk sources # See docs/release_checklist.md SDL_MAJOR_VERSION=2 -SDL_MINOR_VERSION=28 -SDL_MICRO_VERSION=2 +SDL_MINOR_VERSION=30 +SDL_MICRO_VERSION=4 SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION` @@ -319,10 +319,20 @@ AC_ARG_ENABLE(libc, [AS_HELP_STRING([--enable-libc], [Use the system C library [default=yes]])], , enable_libc=yes) -dnl See whether we are allowed to use libiconv +dnl See whether we are allowed to use system iconv +enable_system_iconv_default=yes +case "$host" in + *-*-cygwin*|*-*-mingw*|*-*-darwin*|*-ios-*) + enable_system_iconv_default=no + ;; +esac AC_ARG_ENABLE(system-iconv, -[AS_HELP_STRING([--enable-system-iconv], [Use iconv() from system-installed libraries [default=yes]])], - , enable_system_iconv=yes) +[AS_HELP_STRING([--enable-system-iconv], [Use iconv() from system-installed libraries [default=no for windows, yes for others]])], + , enable_system_iconv=$enable_system_iconv_default) +dnl See whether we prefer libiconv over libc +AC_ARG_ENABLE(libiconv, +[AS_HELP_STRING([--enable-libiconv], [Prefer iconv() from libiconv, if available, over libc version [default=no]])], + , enable_libiconv=no) if test x$enable_libc = xyes; then AC_DEFINE(HAVE_LIBC, 1, [ ]) @@ -330,7 +340,7 @@ if test x$enable_libc = xyes; then dnl Check for C library headers dnl AC_CHECK_INCLUDES_DEFAULT is an autoconf-2.7x thing where AC_HEADER_STDC is deprecated. m4_ifdef([AC_CHECK_INCLUDES_DEFAULT], [AC_CHECK_INCLUDES_DEFAULT], [AC_HEADER_STDC]) - AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h linux/input.h) + AC_CHECK_HEADERS(sys/types.h stdio.h stdlib.h stddef.h stdarg.h malloc.h memory.h string.h strings.h wchar.h inttypes.h stdint.h limits.h ctype.h math.h float.h iconv.h signal.h) dnl Check for typedefs, structures, etc. AC_TYPE_SIZE_T @@ -349,14 +359,52 @@ dnl Checks for library functions. AC_DEFINE(HAVE_MPROTECT, 1, [ ]) ],[]), ) - AC_CHECK_FUNCS(malloc calloc realloc free getenv setenv putenv unsetenv bsearch qsort abs bcopy memset memcmp 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 strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr 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 bsearch qsort abs bcopy memset memcmp 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 strtod strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp strcasestr vsscanf vsnprintf fopen64 fseeko fseeko64 sigaction setjmp nanosleep sysconf sysctlbyname getauxval elf_aux_info poll memfd_create posix_fallocate _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 lround lroundf pow powf round roundf scalbn scalbnf sin sinf sqrt sqrtf tan tanf) if test x$enable_system_iconv = xyes; then - AC_CHECK_LIB(iconv, iconv_open, [LIBS="$LIBS -liconv"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv"]) - AC_CHECK_FUNCS(iconv) + AC_MSG_CHECKING(for iconv in libc) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #define LIBICONV_PLUG 1 /* in case libiconv header is in include path */ + #include + #include + ]],[[ + iconv_open(NULL,NULL); + ]])], [have_libc_iconv=yes],[have_libc_iconv=no]) + AC_MSG_RESULT($have_libc_iconv) + + AC_MSG_CHECKING(for iconv in libiconv) + save_LIBS="$LIBS" + LIBS="$LIBS -liconv" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]],[[ + iconv_open(NULL,NULL); + ]])], [have_libiconv=yes],[have_libiconv=no]) + LIBS="$save_LIBS" + AC_MSG_RESULT($have_libiconv) + + if test x$have_libc_iconv = xyes || test x$have_libiconv = xyes; then + AC_DEFINE(HAVE_ICONV,1,[ ]) + + if test x$have_libiconv = xyes; then + if test x$have_libc_iconv != xyes; then + use_libiconv=yes + elif test x$enable_libiconv = xyes; then + use_libiconv=yes + fi + fi + if test x$use_libiconv = xyes; then + AC_DEFINE(SDL_USE_LIBICONV,1,[ ]) + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -liconv" + echo "-- Using iconv from libiconv" + else + echo "-- Using iconv from libc" + fi + fi fi AC_CHECK_MEMBER(struct sigaction.sa_sigaction,[AC_DEFINE([HAVE_SA_SIGACTION], 1, [ ])], ,[#include ]) @@ -890,38 +938,6 @@ fi AC_DEFINE(HAVE_LSXINTRIN_H, 1, [ ]) fi - AC_ARG_ENABLE(lasx, -[AS_HELP_STRING([--enable-lasx], [use LASX assembly routines [default=yes]])], - , enable_LASX=yes) - if test x$enable_LASX = xyes; then - save_CFLAGS="$CFLAGS" - have_gcc_lasx=no - AC_MSG_CHECKING(for GCC -mlasx option) - lasx_CFLAGS="-mlasx" - CFLAGS="$save_CFLAGS $lasx_CFLAGS" - - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #ifndef __loongarch_asx - #error Assembler CPP flag not enabled - #endif - ]], [])], [have_gcc_lasx=yes], []) - AC_MSG_RESULT($have_gcc_lasx) - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_lasx = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS $lasx_CFLAGS" - SUMMARY_math="${SUMMARY_math} lasx" - fi - fi - - AC_MSG_CHECKING(for lasxintrin.h) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]])], - [have_lasxintrin_h_hdr=yes],[have_lasxintrin_h_hdr=no]) - AC_MSG_RESULT($have_lasxintrin_h_hdr) - if test x$have_lasxintrin_h_hdr = xyes; then - AC_DEFINE(HAVE_LASXINTRIN_H, 1, [ ]) - fi - dnl See if the OSS audio interface is supported CheckOSS() { @@ -1122,13 +1138,13 @@ CheckPulseAudio() [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) + PKG_CHECK_MODULES([PULSEAUDIO], [libpulse >= 0.9.15], 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]])], , enable_pulseaudio_shared=yes) - pulseaudio_lib=[`find_lib "libpulse-simple.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] + pulseaudio_lib=[`find_lib "libpulse.so.*" "$PULSEAUDIO_LIBS" | sed 's/.*\/\(.*\)/\1/; q'`] AC_DEFINE(SDL_AUDIO_DRIVER_PULSEAUDIO, 1, [ ]) SOURCES="$SOURCES $srcdir/src/audio/pulseaudio/*.c" @@ -1139,7 +1155,7 @@ CheckPulseAudio() fi if test x$have_loadso = xyes && \ test x$enable_pulseaudio_shared = xyes && test x$pulseaudio_lib != x; then - echo "-- dynamic libpulse-simple -> $pulseaudio_lib" + echo "-- dynamic libpulse -> $pulseaudio_lib" AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC, "$pulseaudio_lib", [ ]) SUMMARY_audio="${SUMMARY_audio} pulse(dynamic)" @@ -1604,17 +1620,22 @@ CheckNoErrorDeprecatedDeclarationsWerror() dnl See if GCC's -Wdeclaration-after-statement is supported. dnl This lets us catch things that would fail on a C89 compiler when using dnl a modern GCC. -dnl EDIT 2023/04/01 DOSBox-X: We don't care about ancient compilers. A compiler -dnl that old doesn't support C++ and even if it did, it wouldn't be new enough -dnl for this code base. We have to disable this because this is preventing -dnl DOSBox-X from compiling with the latest XCode on ARM-based Macbooks because -dnl the *.m files have variable declarations after statements. At no point is -dnl this code going to compile itself like it's 1993. Come on guys. --J.C. - CheckDeclarationAfterStatement() { - dnl We don't care about C89 compilers. - true + AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option) + have_gcc_declaration_after_statement=no + + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + int x = 0; + ]],[])], [have_gcc_declaration_after_statement=yes],[]) + AC_MSG_RESULT($have_gcc_declaration_after_statement) + CFLAGS="$save_CFLAGS" + + if test x$have_gcc_declaration_after_statement = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement" + fi } dnl See if GCC's -Wall is supported. @@ -2753,6 +2774,8 @@ dnl See if we can use the new unified event interface in Linux 2.4 CheckInputEvents() { dnl Check for Linux 2.4 unified input event interface support + AC_CHECK_HEADERS(linux/input.h) + AC_MSG_CHECKING(for Linux 2.4 unified input interface) use_input_events=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ @@ -3320,17 +3343,14 @@ CheckDIRECTX() if test x$enable_directx = xyes; then AC_CHECK_HEADER(d3d9.h, have_d3d=yes) AC_CHECK_HEADER(d3d11_1.h, have_d3d11=yes) - AC_MSG_CHECKING(for d3d12 Windows SDK version) + AC_MSG_CHECKING(for compatible d3d12 headers) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ -#include -#include #include +#include ID3D12Device1 *device; -#if WDK_NTDDI_VERSION <= 0x0A000008 -asdf -#endif ]])], [have_d3d12=yes],[have_d3d12=no]) AC_MSG_RESULT($have_d3d12) + AC_CHECK_HEADER(ddraw.h, have_ddraw=yes) AC_CHECK_HEADER(dsound.h, have_dsound=yes) AC_CHECK_HEADER(dinput.h, have_dinput=yes) @@ -3362,33 +3382,10 @@ asdf [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 - if test x$have_xinput_gamepadex = xyes; then - AC_DEFINE(HAVE_XINPUT_GAMEPAD_EX, 1, [ ]) - fi - if test x$have_xinput_stateex = xyes; then - AC_DEFINE(HAVE_XINPUT_STATE_EX, 1, [ ]) - fi fi AC_MSG_CHECKING(for windows.gaming.input.h) diff --git a/vs/sdl2/docs/README-android.md b/vs/sdl2/docs/README-android.md index dc7eb5bf25..b886f06db5 100644 --- a/vs/sdl2/docs/README-android.md +++ b/vs/sdl2/docs/README-android.md @@ -13,13 +13,13 @@ supported, but you can use the "android-project-ant" directory as a template. Requirements ================================================================================ -Android SDK (version 31 or later) +Android SDK (version 34 or later) https://developer.android.com/sdk/index.html Android NDK r15c or later https://developer.android.com/tools/sdk/ndk/index.html -Minimum API level supported by SDL: 16 (Android 4.1) +Minimum API level supported by SDL: 19 (Android 4.4) How the port works @@ -72,7 +72,7 @@ done in the build directory for the app! For more complex projects, follow these instructions: 1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT). - + (The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.) 2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory @@ -431,13 +431,13 @@ 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 19 the minimum required? ================================================================================ -The latest NDK toolchain doesn't support targeting earlier than API level 16. -As of this writing, according to https://developer.android.com/about/dashboards/index.html -about 99% of the Android devices accessing Google Play support API level 16 or -higher (January 2018). +The latest NDK toolchain doesn't support targeting earlier than API level 19. +As of this writing, according to https://www.composables.com/tools/distribution-chart +about 99.7% of the Android devices accessing Google Play support API level 19 or +higher (August 2023). A note regarding the use of the "dirty rectangles" rendering technique diff --git a/vs/sdl2/docs/README-cmake.md b/vs/sdl2/docs/README-cmake.md index a86be338c1..cfd40664c5 100644 --- a/vs/sdl2/docs/README-cmake.md +++ b/vs/sdl2/docs/README-cmake.md @@ -48,7 +48,7 @@ SDL can be included in your project in 2 major ways: The following CMake script supports both, depending on the value of `MYGAME_VENDORED`. ```cmake -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.5) project(mygame) # Create an option to switch between a system sdl library and a vendored sdl library diff --git a/vs/sdl2/docs/README-dynapi.md b/vs/sdl2/docs/README-dynapi.md index 7649c1d93a..76b868ce64 100644 --- a/vs/sdl2/docs/README-dynapi.md +++ b/vs/sdl2/docs/README-dynapi.md @@ -35,7 +35,7 @@ SDL now has, internally, a table of function pointers. So, this is what SDL_Init now looks like: ```c -UInt32 SDL_Init(Uint32 flags) +Uint32 SDL_Init(Uint32 flags) { return jump_table.SDL_Init(flags); } @@ -100,7 +100,7 @@ a shared library of its own). If so, it loads that library and looks for and calls a single function: ```c -SInt32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize); +Sint32 SDL_DYNAPI_entry(Uint32 version, void *table, Uint32 tablesize); ``` That function takes a version number (more on that in a moment), the address of diff --git a/vs/sdl2/docs/README-emscripten.md b/vs/sdl2/docs/README-emscripten.md index 5f8c277863..1a13eb1c33 100644 --- a/vs/sdl2/docs/README-emscripten.md +++ b/vs/sdl2/docs/README-emscripten.md @@ -1,27 +1,187 @@ # Emscripten -(This documentation is not very robust; we will update and expand this later.) +## The state of things -## A quick note about audio +(As of September 2023, but things move quickly and we don't update this +document often.) + +In modern times, all the browsers you probably care about (Chrome, Firefox, +Edge, and Safari, on Windows, macOS, Linux, iOS and Android), support some +reasonable base configurations: + +- WebAssembly (don't bother with asm.js any more) +- WebGL (which will look like OpenGL ES 2 or 3 to your app). +- Threads (see caveats, though!) +- Game controllers +- Autoupdating (so you can assume they have a recent version of the browser) + +All this to say we're at the point where you don't have to make a lot of +concessions to get even a fairly complex SDL-based game up and running. + + +## RTFM + +This document is a quick rundown of some high-level details. The +documentation at [emscripten.org](https://emscripten.org/) is vast +and extremely detailed for a wide variety of topics, and you should at +least skim through it at some point. + + +## Porting your app to Emscripten + +Many many things just need some simple adjustments and they'll compile +like any other C/C++ code, as long as SDL was handling the platform-specific +work for your program. + +First, you probably need this in at least one of your source files: + +```c +#ifdef __EMSCRIPTEN__ +#include +#endif +``` + +Second: assembly language code has to go. Replace it with C. You can even use +[x86 SIMD intrinsic functions in Emscripten](https://emscripten.org/docs/porting/simd.html)! + +Third: Middleware has to go. If you have a third-party library you link +against, you either need an Emscripten port of it, or the source code to it +to compile yourself, or you need to remove it. + +Fourth: You still start in a function called main(), but you need to get out of +it and into a function that gets called repeatedly, and returns quickly, +called a mainloop. + +Somewhere in your program, you probably have something that looks like a more +complicated version of this: + +```c +void main(void) +{ + initialize_the_game(); + while (game_is_still_running) { + check_for_new_input(); + think_about_stuff(); + draw_the_next_frame(); + } + deinitialize_the_game(); +} +``` + +This will not work on Emscripten, because the main thread needs to be free +to do stuff and can't sit in this loop forever. So Emscripten lets you set up +a [mainloop](https://emscripten.org/docs/porting/emscripten-runtime-environment.html#browser-main-loop). + +```c +static void mainloop(void) /* this will run often, possibly at the monitor's refresh rate */ +{ + if (!game_is_still_running) { + deinitialize_the_game(); + #ifdef __EMSCRIPTEN__ + emscripten_cancel_main_loop(); /* this should "kill" the app. */ + #else + exit(0); + #endif + } + + check_for_new_input(); + think_about_stuff(); + draw_the_next_frame(); +} + +void main(void) +{ + initialize_the_game(); + #ifdef __EMSCRIPTEN__ + emscripten_set_main_loop(mainloop, 0, 1); + #else + while (1) { mainloop(); } + #endif +} +``` + +Basically, `emscripten_set_main_loop(mainloop, 0, 1);` says "run +`mainloop` over and over until I end the program." The function will +run, and return, freeing the main thread for other tasks, and then +run again when it's time. The `1` parameter does some magic to make +your main() function end immediately; this is useful because you +don't want any shutdown code that might be sitting below this code +to actually run if main() were to continue on, since we're just +getting started. + +There's a lot of little details that are beyond the scope of this +document, but that's the biggest intial set of hurdles to porting +your app to the web. + + +## Do you need threads? + +If you plan to use threads, they work on all major browsers now. HOWEVER, +they bring with them a lot of careful considerations. Rendering _must_ +be done on the main thread. This is a general guideline for many +platforms, but a hard requirement on the web. + +Many other things also must happen on the main thread; often times SDL +and Emscripten make efforts to "proxy" work to the main thread that +must be there, but you have to be careful (and read more detailed +documentation than this for the finer points). + +Even when using threads, your main thread needs to set an Emscripten +mainloop that runs quickly and returns, or things will fail to work +correctly. + +You should definitely read [Emscripten's pthreads docs](https://emscripten.org/docs/porting/pthreads.html) +for all the finer points. Mostly SDL's thread API will work as expected, +but is built on pthreads, so it shares the same little incompatibilities +that are documented there, such as where you can use a mutex, and when +a thread will start running, etc. + + +IMPORTANT: You have to decide to either build something that uses +threads or something that doesn't; you can't have one build +that works everywhere. This is an Emscripten (or maybe WebAssembly? +Or just web browsers in general?) limitation. If you aren't using +threads, it's easier to not enable them at all, at build time. + +If you use threads, you _have to_ run from a web server that has +[COOP/COEP headers set correctly](https://web.dev/why-coop-coep/) +or your program will fail to start at all. + +If building with threads, `__EMSCRIPTEN_PTHREADS__` will be defined +for checking with the C preprocessor, so you can build something +different depending on what sort of build you're compiling. + + +## Audio + +Audio works as expected at the API level, but not exactly like other +platforms. + +You'll only see a single default audio device. Audio capture also works; +if the browser pops up a prompt to ask for permission to access the +microphone, the SDL_OpenAudioDevice call will succeed and start producing +silence at a regular interval. Once the user approves the request, real +audio data will flow. If the user denies it, the app is not informed and +will just continue to receive silence. Modern web browsers will not permit web pages to produce sound before the -user has interacted with them; this is for several reasons, not the least -of which being that no one likes when a random browser tab suddenly starts -making noise and the user has to scramble to figure out which and silence -it. - -To solve this, most browsers will refuse to let a web app use the audio -subsystem at all before the user has interacted with (clicked on) the page -in a meaningful way. SDL-based apps also have to deal with this problem; if -the user hasn't interacted with the page, SDL_OpenAudioDevice will fail. - -There are two reasonable ways to deal with this: if you are writing some -sort of media player thing, where the user expects there to be a volume -control when you mouseover the canvas, just default that control to a muted -state; if the user clicks on the control to unmute it, on this first click, -open the audio device. This allows the media to play at start, the user can -reasonably opt-in to listening, and you never get access denied to the audio -device. +user has interacted with them (clicked or tapped on them, usually); this is +for several reasons, not the least of which being that no one likes when a +random browser tab suddenly starts making noise and the user has to scramble +to figure out which and silence it. + +SDL will allow you to open the audio device for playback in this +circumstance, and your audio callback will fire, but SDL will throw the audio +data away until the user interacts with the page. This helps apps that depend +on the audio callback to make progress, and also keeps audio playback in sync +once the app is finally allowed to make noise. + +There are two reasonable ways to deal with the silence at the app level: +if you are writing some sort of media player thing, where the user expects +there to be a volume control when you mouseover the canvas, just default +that control to a muted state; if the user clicks on the control to unmute +it, on this first click, open the audio device. This allows the media to +play at start, and the user can reasonably opt-in to listening. Many games do not have this sort of UI, and are more rigid about starting audio along with everything else at the start of the process. For these, your @@ -36,41 +196,179 @@ Please see the discussion at https://github.com/libsdl-org/SDL/issues/6385 for some Javascript code to steal for this approach. +## Rendering + +If you use SDL's 2D render API, it will use GLES2 internally, which +Emscripten will turn into WebGL calls. You can also use OpenGL ES 2 +directly by creating a GL context and drawing into it. + +Calling SDL_RenderPresent (or SDL_GL_SwapWindow) will not actually +present anything on the screen until your return from your mainloop +function. + + ## Building SDL/emscripten -SDL currently requires at least Emscripten 2.0.32 to build. Newer versions +First: do you _really_ need to build SDL from source? + +If you aren't developing SDL itself, have a desire to mess with its source +code, or need something on the bleeding edge, don't build SDL. Just use +Emscripten's packaged version! + +Compile and link your app with `-sUSE_SDL=2` and it'll use a build of +SDL packaged with Emscripten. This comes from the same source code and +fixes the Emscripten project makes to SDL are generally merged into SDL's +revision control, so often this is much easier for app developers. + +`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL +1.2 instead; if you need SDL 1.2, this might be fine, but we generally +recommend you don't use SDL 1.2 in modern times. + + +If you want to build SDL, though... + +SDL currently requires at least Emscripten 3.1.35 to build. Newer versions are likely to work, as well. Build: - $ mkdir build - $ cd build - $ emconfigure ../configure --host=asmjs-unknown-emscripten --disable-assembly --disable-threads --disable-cpuinfo CFLAGS="-O2" - $ emmake make +This works on Linux/Unix and macOS. Please send comments about Windows. + +Make sure you've [installed emsdk](https://emscripten.org/docs/getting_started/downloads.html) +first, and run `source emsdk_env.sh` at the command line so it finds the +tools. + +(These configure options might be overkill, but this has worked for me.) + +```bash +cd SDL +mkdir build +cd build +emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3" +emmake make -j4 +``` + +If you want to build with thread support, something like this works: + +```bash +emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread" +``` Or with cmake: - $ mkdir build - $ cd build - $ emcmake cmake .. - $ emmake make +```bash +mkdir build +cd build +emcmake cmake .. +emmake make -j4 +``` To build one of the tests: - $ cd test/ - $ emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html +```bash +cd test/ +emcc -O2 --js-opts 0 -g4 testdraw2.c -I../include ../build/.libs/libSDL2.a ../build/libSDL2_test.a -o a.html +``` + +## Building your app + +You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but +mostly it uses the same command line arguments as Clang. + +Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL, +link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build. + +Usually you would produce a binary like this: + +```bash +gcc -o mygame mygame.c # or whatever +``` + +But for Emscripten, you want to output something else: + +```bash +emcc -o index.html mygame.c +``` + +This will produce several files...support Javascript and WebAssembly (.wasm) +files. The `-o index.html` will produce a simple HTML page that loads and +runs your app. You will (probably) eventually want to replace or customize +that file and do `-o index.js` instead to just build the code pieces. + +If you're working on a program of any serious size, you'll likely need to +link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access +to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb` +or the app will fail to start on iOS browsers, but this might be a bug that +goes away in the future. + + +## Data files + +Your game probably has data files. Here's how to access them. + +Filesystem access works like a Unix filesystem; you have a single directory +tree, possibly interpolated from several mounted locations, no drive letters, +'/' for a path separator. You can access them with standard file APIs like +open() or fopen() or SDL_RWops. You can read or write from the filesystem. + +By default, you probably have a "MEMFS" filesystem (all files are stored in +memory, but access to them is immediate and doesn't need to block). There are +other options, like "IDBFS" (files are stored in a local database, so they +don't need to be in RAM all the time and they can persist between runs of the +program, but access is not synchronous). You can mix and match these file +systems, mounting a MEMFS filesystem at one place and idbfs elsewhere, etc, +but that's beyond the scope of this document. Please refer to Emscripten's +[page on the topic](https://emscripten.org/docs/porting/files/file_systems_overview.html) +for more info. + +The _easiest_ (but not the best) way to get at your data files is to embed +them in the app itself. Emscripten's linker has support for automating this. + +```bash +emcc -o index.html loopwave.c --embed-file=../test/sample.wav@/sounds/sample.wav +``` + +This will pack ../test/sample.wav in your app, and make it available at +"/sounds/sample.wav" at runtime. Emscripten makes sure this data is available +before your main() function runs, and since it's in MEMFS, you can just +read it like you do on other platforms. `--embed-file` can also accept a +directory to pack an entire tree, and you can specify the argument multiple +times to pack unrelated things into the final installation. + +Note that this is absolutely the best approach if you have a few small +files to include and shouldn't worry about the issue further. However, if you +have hundreds of megabytes and/or thousands of files, this is not so great, +since the user will download it all every time they load your page, and it +all has to live in memory at runtime. + +[Emscripten's documentation on the matter](https://emscripten.org/docs/porting/files/packaging_files.html) +gives other options and details, and is worth a read. + + +## Debugging + +Debugging web apps is a mixed bag. You should compile and link with +`-gsource-map`, which embeds a ton of source-level debugging information into +the build, and make sure _the app source code is available on the web server_, +which is often a scary proposition for various reasons. + +When you debug from the browser's tools and hit a breakpoint, you can step +through the actual C/C++ source code, though, which can be nice. + +If you try debugging in Firefox and it doesn't work well for no apparent +reason, try Chrome, and vice-versa. These tools are still relatively new, +and improving all the time. + +SDL_Log() (or even plain old printf) will write to the Javascript console, +and honestly I find printf-style debugging to be easier than setting up a build +for proper debugging, so use whatever tools work best for you. -Uses GLES2 renderer or software -Some other SDL2 libraries can be easily built (assuming SDL2 is installed somewhere): +## Questions? -SDL_mixer (http://www.libsdl.org/projects/SDL_mixer/): +Please give us feedback on this document at [the SDL bug tracker](https://github.com/libsdl-org/SDL/issues). +If something is wrong or unclear, we want to know! - $ EMCONFIGURE_JS=1 emconfigure ../configure - build as usual... -SDL_gfx (http://cms.ferzkopp.net/index.php/software/13-sdl-gfx): - $ EMCONFIGURE_JS=1 emconfigure ../configure --disable-mmx - build as usual... diff --git a/vs/sdl2/docs/README-gdk.md b/vs/sdl2/docs/README-gdk.md index 903265f32f..6718a61772 100644 --- a/vs/sdl2/docs/README-gdk.md +++ b/vs/sdl2/docs/README-gdk.md @@ -1,155 +1,176 @@ -GDK -===== - -This port allows SDL applications to run via Microsoft's Game Development Kit (GDK). - -Windows (GDK) and Xbox One/Xbox Series (GDKX) are supported. Although most of the Xbox code is included in the public SDL source code, NDA access is required for a small number of source files. If you have access to GDKX, these required Xbox files are posted on the GDK forums [here](https://forums.xboxlive.com/questions/130003/). - - -Requirements ------------- - -* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested) -* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022)) -* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work. - - -Windows GDK Status ------- - -The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL. - -* Additionally, the GDK port adds the following: - * Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.) - * GDK-specific setup: - * Initializing/uninitializing the game runtime, and initializing Xbox Live services - * Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue. - - * An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. - * Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`). - * You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak). - -* What doesn't work: - * Compilation with anything other than through the included Visual C++ solution file - -## VisualC-GDK Solution - -The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration: - -* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64. -* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs. -* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality. -* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live. - *NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this. -* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality. - -If you set one of the test programs as a startup project, you can run it directly from Visual Studio. - -Windows GDK Setup, Detailed Steps ---------------------- - -These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below. - -### 1. Add a Gaming.Desktop.x64 Configuration ### - -In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration. - -### 2. Build SDL2 and SDL2main for GDK ### - -Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project. - -*Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built. - -### 3. Configuring Project Settings ### - -While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration: - -* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced -* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are -* Under Linker > Input > Additional Dependencies, you need the following: - * `SDL2.lib` - * `SDL2main.lib` (unless not using) - * `xgameruntime.lib` - * `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib` -* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK. - -### 4. Setting up SDL_main ### - -Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. - -### 5. Required DLLs ### - -The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory: - -* Your SDL2.dll -* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll" -* XCurl.dll - -You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory. - -### 6. Setting up MicrosoftGame.config ### - -You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description. - -This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type. - -For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center. - -Then, you need to set the following values to the values from Partner Center: - -* Identity tag - Name and Publisher attributes -* TitleId -* MSAAppId - -### 7. Adding Required Logos - -Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file. - - -### 8. Copying any Data Files ### - -When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step. - - -### 9. Build and Run from Visual Studio ### - -At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs. - -If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this: - -1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu -2. Switch the sandbox name with: - `XblPCSandbox SANDBOX.#` -3. (To switch back to the retail sandbox): - `XblPCSandbox RETAIL` - -### 10. Packaging and Installing Locally - -You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files. - -To create the package: - -1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu -2. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory) -3. `mkdir Package` to create an output directory -4. To package the file into the `Package` directory, use: - `makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package` -5. To install the package, use: - `wdapp install PACKAGENAME.msixvc` -6. Once the package is installed, you can run it from the start menu. -7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox. - - -Troubleshooting ---------------- - -#### Xbox Live Login does not work - -As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values. - -Furthermore, confirm that your PC is set to the correct sandbox. - - -#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing - -Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it). +GDK +===== + +This port allows SDL applications to run via Microsoft's Game Development Kit (GDK). + +Windows (GDK) and Xbox One/Xbox Series (GDKX) are both supported and all the required code is included in this public SDL release. However, only licensed Xbox developers have access to the GDKX libraries which will allow you to build the Xbox targets. + + +Requirements +------------ + +* Microsoft Visual Studio 2022 (in theory, it should also work in 2017 or 2019, but this has not been tested) +* Microsoft GDK June 2022 or newer (public release [here](https://github.com/microsoft/GDK/releases/tag/June_2022)) +* For Xbox, you will need the corresponding GDKX version (licensed developers only) +* To publish a package or successfully authenticate a user, you will need to create an app id/configure services in Partner Center. However, for local testing purposes (without authenticating on Xbox Live), the identifiers used by the GDK test programs in the included solution will work. + + +Windows GDK Status +------ + +The Windows GDK port supports the full set of Win32 APIs, renderers, controllers, input devices, etc., as the normal Windows x64 build of SDL. + +* Additionally, the GDK port adds the following: + * Compile-time platform detection for SDL programs. The `__GDK__` is `#define`d on every GDK platform, and the `__WINGDK__` is `#define`d on Windows GDK, specifically. (This distinction exists because other GDK platforms support a smaller subset of functionality. This allows you to mark code for "any" GDK separate from Windows GDK.) + * GDK-specific setup: + * Initializing/uninitializing the game runtime, and initializing Xbox Live services + * Creating a global task queue and setting it as the default for the process. When running any async operations, passing in `NULL` as the task queue will make the task get added to the global task queue. + + * An implementation on `WinMain` that performs the above GDK setup (you should link against SDL2main.lib, as in Windows x64). If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. + * Global task queue callbacks are dispatched during `SDL_PumpEvents` (which is also called internally if using `SDL_PollEvent`). + * You can get the handle of the global task queue through `SDL_GDKGetTaskQueue`, if needed. When done with the queue, be sure to use `XTaskQueueCloseHandle` to decrement the reference count (otherwise it will cause a resource leak). + +* Single-player games have some additional features available: + * Call `SDL_GDKGetDefaultUser` to get the default XUserHandle pointer. + * `SDL_GetPrefPath` still works, but only for single-player titles. + + These functions mostly wrap around async APIs, and thus should be treated as synchronous alternatives. Also note that the single-player functions return on any OS errors, so be sure to validate the return values! + +* What doesn't work: + * Compilation with anything other than through the included Visual C++ solution file + +## VisualC-GDK Solution + +The included `VisualC-GDK/SDL.sln` solution includes the following targets for the Gaming.Desktop.x64 configuration: + +* SDL2 (DLL) - This is the typical SDL2.dll, but for Gaming.Desktop.x64. +* SDL2main (lib) - This contains a drop-in implementation of `WinMain` that is used as the entry point for GDK programs. +* tests/testgamecontroller - Standard SDL test program demonstrating controller functionality. +* tests/testgdk - GDK-specific test program that demonstrates using the global task queue to login a user into Xbox Live. + *NOTE*: As of the June 2022 GDK, you cannot test user logins without a valid Title ID and MSAAppId. You will need to manually change the identifiers in the `MicrosoftGame.config` to your valid IDs from Partner Center if you wish to test this. +* tests/testsprite2 - Standard SDL test program demonstrating sprite drawing functionality. + +If you set one of the test programs as a startup project, you can run it directly from Visual Studio. + +Windows GDK Setup, Detailed Steps +--------------------- + +These steps assume you already have a game using SDL that runs on Windows x64 along with a corresponding Visual Studio solution file for the x64 version. If you don't have this, it's easiest to use one of the test program vcxproj files in the `VisualC-GDK` directory as a starting point, though you will still need to do most of the steps below. + +### 1. Add a Gaming.Desktop.x64 Configuration ### + +In your game's existing Visual Studio Solution, go to Build > Configuration Manager. From the "Active solution platform" drop-down select "New...". From the drop-down list, select Gaming.Desktop.x64 and copy the settings from the x64 configuration. + +### 2. Build SDL2 and SDL2main for GDK ### + +Open `VisualC-GDK/SDL.sln` in Visual Studio, you need to build the SDL2 and SDL2main targets for the Gaming.Desktop.x64 platform (Release is recommended). You will need to copy/keep track of the `SDL2.dll`, `XCurl.dll` (which is output by Gaming.Desktop.x64), `SDL2.lib`, and `SDL2main.lib` output files for your game project. + +*Alternatively*, you could setup your solution file to instead reference the SDL2/SDL2main project file targets from the SDL source, and add those projects as a dependency. This would mean that SDL2 and SDL2main would both be built when your game is built. + +### 3. Configuring Project Settings ### + +While the Gaming.Desktop.x64 configuration sets most of the required settings, there are some additional items to configure for your game project under the Gaming.Desktop.x64 Configuration: + +* Under C/C++ > General > Additional Include Directories, make sure the `SDL/include` path is referenced +* Under Linker > General > Additional Library Directories, make sure to reference the path where the newly-built SDL2.lib and SDL2main.lib are +* Under Linker > Input > Additional Dependencies, you need the following: + * `SDL2.lib` + * `SDL2main.lib` (unless not using) + * `xgameruntime.lib` + * `../Microsoft.Xbox.Services.141.GDK.C.Thunks.lib` +* Note that in general, the GDK libraries depend on the MSVC C/C++ runtime, so there is no way to remove this dependency from a GDK program that links against GDK. + +### 4. Setting up SDL_main ### + +Rather than using your own implementation of `WinMain`, it's recommended that you instead `#include "SDL_main.h"` and declare a standard main function. If you are unable to do this, you can instead manually call `SDL_GDKRunApp` from your entry point, passing in your `SDL_main` function and `NULL` as the parameters. + +### 5. Required DLLs ### + +The game will not launch in the debugger unless required DLLs are included in the directory that contains the game's .exe file. You need to make sure that the following files are copied into the directory: + +* Your SDL2.dll +* "$(Console_GRDKExtLibRoot)Xbox.Services.API.C\DesignTime\CommonConfiguration\Neutral\Lib\Release\Microsoft.Xbox.Services.141.GDK.C.Thunks.dll" +* XCurl.dll + +You can either copy these in a post-build step, or you can add the dlls into the project and set its Configuration Properties > General > Item type to "Copy file," which will also copy them into the output directory. + +### 6. Setting up MicrosoftGame.config ### + +You can copy `VisualC-GDK/tests/testgdk/MicrosoftGame.config` and use that as a starting point in your project. Minimally, you will want to change the Executable Name attribute, the DefaultDisplayName, and the Description. + +This file must be copied into the same directory as the game's .exe file. As with the DLLs, you can either use a post-build step or the "Copy file" item type. + +For basic testing, you do not need to change anything else in `MicrosoftGame.config`. However, if you want to test any Xbox Live services (such as logging in users) _or_ publish a package, you will need to setup a Game app on Partner Center. + +Then, you need to set the following values to the values from Partner Center: + +* Identity tag - Name and Publisher attributes +* TitleId +* MSAAppId + +### 7. Adding Required Logos + +Several logo PNG files are required to be able to launch the game, even from the debugger. You can use the sample logos provided in `VisualC-GDK/logos`. As with the other files, they must be copied into the same directory as the game's .exe file. + + +### 8. Copying any Data Files ### + +When debugging GDK games, there is no way to specify a working directory. Therefore, any required game data must also be copied into the output directory, likely in a post-build step. + + +### 9. Build and Run from Visual Studio ### + +At this point, you should be able to build and run your game from the Visual Studio Debugger. If you get any linker errors, make sure you double-check that you referenced all the required libs. + +If you are testing Xbox Live functionality, it's likely you will need to change to the Sandbox for your title. To do this: + +1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu +2. Switch the sandbox name with: + `XblPCSandbox SANDBOX.#` +3. (To switch back to the retail sandbox): + `XblPCSandbox RETAIL` + +### 10. Packaging and Installing Locally + +You can use one of the test program's `PackageLayout.xml` as a starting point. Minimally, you will need to change the exe to the correct name and also reference any required game data. As with the other data files, it's easiest if you have this copy to the output directory, although it's not a requirement as you can specify relative paths to files. + +To create the package: + +1. Run "Desktop VS 2022 Gaming Command Prompt" from the Start Menu +2. `cd` to the directory containing the `PackageLayout.xml` with the correct paths (if you use the local path as in the sample package layout, this would be from your .exe output directory) +3. `mkdir Package` to create an output directory +4. To package the file into the `Package` directory, use: + `makepkg pack /f PackageLayout.xml /lt /d . /nogameos /pc /pd Package` +5. To install the package, use: + `wdapp install PACKAGENAME.msixvc` +6. Once the package is installed, you can run it from the start menu. +7. As with when running from Visual Studio, if you need to test any Xbox Live functionality you must switch to the correct sandbox. + +Xbox GDKX Setup +--------------------- +In general, the same process in the Windows GDK instructions work. There are just a few additional notes: +* For Xbox One consoles, use the Gaming.Xbox.XboxOne.x64 target +* For Xbox Series consoles, use the Gaming.Xbox.Scarlett.x64 target +* The Xbox One target sets the `__XBOXONE__` define and the Xbox Series target sets the `__XBOXSERIES__` define +* You don't need to link against the Xbox.Services Thunks lib nor include that dll in your package (it doesn't exist for Xbox) +* The shader blobs for Xbox are created in a pre-build step for the Xbox targets, rather than included in the source (due to NDA and version compatability reasons) +* To create a package, use: + `makepkg pack /f PackageLayout.xml /lt /d . /pd Package` +* To install the package, use: + `xbapp install [PACKAGE].xvc` +* For some reason, if you make changes that require SDL2.dll to build, and you are running through the debugger (instead of a package), you have to rebuild your .exe target for the debugger to recognize the dll has changed and needs to be transferred to the console again +* While there are successful releases of Xbox titles using this port, it is not as extensively tested as other targets + +Troubleshooting +--------------- + +#### Xbox Live Login does not work + +As of June 2022 GDK, you must have a valid Title Id and MSAAppId in order to test Xbox Live functionality such as user login. Make sure these are set correctly in the `MicrosoftGame.config`. This means that even testgdk will not let you login without setting these properties to valid values. + +Furthermore, confirm that your PC is set to the correct sandbox. + + +#### "The current user has already installed an unpackaged version of this app. A packaged version cannot replace this." error when installing + +Prior to June 2022 GDK, running from the Visual Studio debugger would still locally register the app (and it would appear on the start menu). To fix this, you have to uninstall it (it's simplest to right click on it from the start menu to uninstall it). diff --git a/vs/sdl2/docs/README-git.md b/vs/sdl2/docs/README-git.md index 3f03488ae8..fd12fd9f65 100644 --- a/vs/sdl2/docs/README-git.md +++ b/vs/sdl2/docs/README-git.md @@ -1,19 +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/ - +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/vs/sdl2/docs/README-ios.md b/vs/sdl2/docs/README-ios.md index 90ef987a9a..94c24b5033 100644 --- a/vs/sdl2/docs/README-ios.md +++ b/vs/sdl2/docs/README-ios.md @@ -273,7 +273,7 @@ e.g. { ... initialize game ... - #if __IPHONEOS__ + #ifdef __IPHONEOS__ // Initialize the Game Center for scoring and matchmaking InitGameCenter(); diff --git a/vs/sdl2/docs/README-kmsbsd.md b/vs/sdl2/docs/README-kmsbsd.md index 01db5e8aaf..1aad380921 100644 --- a/vs/sdl2/docs/README-kmsbsd.md +++ b/vs/sdl2/docs/README-kmsbsd.md @@ -1,27 +1,27 @@ -KMSDRM on *BSD -================================================== - -KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. 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. +KMSDRM on *BSD +================================================== + +KMSDRM is supported on FreeBSD and OpenBSD. DragonFlyBSD works but requires being a root user. 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/vs/sdl2/docs/README-macos.md b/vs/sdl2/docs/README-macos.md index af8a47506a..634d456bf8 100644 --- a/vs/sdl2/docs/README-macos.md +++ b/vs/sdl2/docs/README-macos.md @@ -1,285 +1,285 @@ -# Mac OS X (aka macOS). - -These instructions are for people using Apple's Mac OS X (pronounced -"ten"), which in newer versions is just referred to as "macOS". - -From the developer's point of view, macOS is a sort of hybrid Mac and -Unix system, and you have the option of using either traditional -command line tools or Apple's IDE Xcode. - -# Command Line Build - -To build SDL using the command line, use the standard configure and make -process: - -```bash -mkdir build -cd build -../configure -make -sudo make install -``` - -CMake is also known to work, although it continues to be a work in progress: - -```bash -mkdir build -cd build -cmake -DCMAKE_BUILD_TYPE=Release .. -make -sudo make install -``` - - -You can also build SDL as a Universal library (a single binary for both -64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh -script. - -```bash -mkdir build -cd build -CC=$PWD/../build-scripts/clang-fat.sh ../configure -make -sudo make install -``` - -This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0 -ABI compatibility on ARM64 architectures. For best compatibility you -should compile your application the same way. - -Please note that building SDL requires at least Xcode 6 and the 10.9 SDK. -PowerPC support for macOS has been officially dropped as of SDL 2.0.2. -32-bit Intel and macOS 10.8 runtime support has been officially dropped as -of SDL 2.24.0. - -To use the library once it's built, you essential have two possibilities: -use the traditional autoconf/automake/make method, or use Xcode. - - -# Caveats for using SDL with Mac OS X - -If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), -SDL will not register its own. This means that SDL will not terminate using -SDL_Quit if it receives a termination request, it will terminate like a -normal app, and it will not send a SDL_DROPFILE when you request to open a -file with the app. To solve these issues, put the following code in your -NSApplicationDelegate implementation: - - -```objc -- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender -{ - if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { - SDL_Event event; - event.type = SDL_QUIT; - SDL_PushEvent(&event); - } - - return NSTerminateCancel; -} - -- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename -{ - if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { - SDL_Event event; - event.type = SDL_DROPFILE; - event.drop.file = SDL_strdup([filename UTF8String]); - return (SDL_PushEvent(&event) > 0); - } - - return NO; -} -``` - -# Using the Simple DirectMedia Layer with a traditional Makefile - -An existing autoconf/automake build system for your SDL app has good chances -to work almost unchanged on macOS. However, to produce a "real" Mac binary -that you can distribute to users, you need to put the generated binary into a -so called "bundle", which is basically a fancy folder with a name like -"MyCoolGame.app". - -To get this build automatically, add something like the following rule to -your Makefile.am: - -```make -bundle_contents = APP_NAME.app/Contents -APP_NAME_bundle: EXE_NAME - mkdir -p $(bundle_contents)/MacOS - mkdir -p $(bundle_contents)/Resources - echo "APPL????" > $(bundle_contents)/PkgInfo - $(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/ -``` - -You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is -what will be visible to the user in the Finder. Usually it will be the same -as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME` -usually is "TestGame". You might also want to use `@PACKAGE@` to use the -package name as specified in your configure.ac file. - -If your project builds more than one application, you will have to do a bit -more. For each of your target applications, you need a separate rule. - -If you want the created bundles to be installed, you may want to add this -rule to your Makefile.am: - -```make -install-exec-hook: APP_NAME_bundle - rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app - mkdir -p $(DESTDIR)$(prefix)/Applications/ - cp -r $< /$(DESTDIR)$(prefix)Applications/ -``` - -This rule takes the Bundle created by the rule from step 3 and installs them -into "$(DESTDIR)$(prefix)/Applications/". - -Again, if you want to install multiple applications, you will have to augment -the make rule accordingly. - -But beware! That is only part of the story! With the above, you end up with -a barebones .app bundle, which is double-clickable from the Finder. But -there are some more things you should do before shipping your product... - -1. The bundle right now probably is dynamically linked against SDL. That - means that when you copy it to another computer, *it will not run*, - unless you also install SDL on that other computer. A good solution - for this dilemma is to static link against SDL. On OS X, you can - achieve that by linking against the libraries listed by - - ```bash - sdl-config --static-libs - ``` - - instead of those listed by - - ```bash - sdl-config --libs - ``` - - Depending on how exactly SDL is integrated into your build systems, the - way to achieve that varies, so I won't describe it here in detail - -2. Add an 'Info.plist' to your application. That is a special XML file which - contains some meta-information about your application (like some copyright - information, the version of your app, the name of an optional icon file, - and other things). Part of that information is displayed by the Finder - when you click on the .app, or if you look at the "Get Info" window. - More information about Info.plist files can be found on Apple's homepage. - - -As a final remark, let me add that I use some of the techniques (and some -variations of them) in [Exult](https://github.com/exult/exult) and -[ScummVM](https://github.com/scummvm/scummvm); both are available in source on -the net, so feel free to take a peek at them for inspiration! - - -# Using the Simple DirectMedia Layer with Xcode - -These instructions are for using Apple's Xcode IDE to build SDL applications. - -## First steps - -The first thing to do is to unpack the Xcode.tar.gz archive in the -top level SDL directory (where the Xcode.tar.gz archive resides). -Because Stuffit Expander will unpack the archive into a subdirectory, -you should unpack the archive manually from the command line: - -```bash -cd [path_to_SDL_source] -tar zxf Xcode.tar.gz -``` - -This will create a new folder called Xcode, which you can browse -normally from the Finder. - -## Building the Framework - -The SDL Library is packaged as a framework bundle, an organized -relocatable folder hierarchy of executable code, interface headers, -and additional resources. For practical purposes, you can think of a -framework as a more user and system-friendly shared library, whose library -file behaves more or less like a standard UNIX shared library. - -To build the framework, simply open the framework project and build it. -By default, the framework bundle "SDL.framework" is installed in -/Library/Frameworks. Therefore, the testers and project stationary expect -it to be located there. However, it will function the same in any of the -following locations: - -* ~/Library/Frameworks -* /Local/Library/Frameworks -* /System/Library/Frameworks - -## Build Options - -There are two "Build Styles" (See the "Targets" tab) for SDL. -"Deployment" should be used if you aren't tweaking the SDL library. -"Development" should be used to debug SDL apps or the library itself. - -## Building the Testers - -Open the SDLTest project and build away! - -## Using the Project Stationary - -Copy the stationary to the indicated folders to access it from -the "New Project" and "Add target" menus. What could be easier? - -## Setting up a new project by hand - -Some of you won't want to use the Stationary so I'll give some tips: - -(this is accurate as of Xcode 12.5.) - -* Click "File" -> "New" -> "Project... -* Choose "macOS" and then "App" from the "Application" section. -* Fill out the options in the next window. User interface is "XIB" and - Language is "Objective-C". -* Remove "main.m" from your project -* Remove "MainMenu.xib" from your project -* Remove "AppDelegates.*" from your project -* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path -* Add "\$(HOME)/Library/Frameworks" to the frameworks search path -* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" -* Add your files -* Clean and build - -## Building from command line - -Use `xcode-build` in the same directory as your .pbxproj file - -## Running your app - -You can send command line args to your app by either invoking it from -the command line (in *.app/Contents/MacOS) or by entering them in the -Executables" panel of the target settings. - -# Implementation Notes - -Some things that may be of interest about how it all works... - -## Working directory - -In SDL 1.2, the working directory of your SDL app is by default set to its -parent, but this is no longer the case in SDL 2.0. SDL2 does change the -working directory, which means it'll be whatever the command line prompt -that launched the program was using, or if launched by double-clicking in -the finger, it will be "/", the _root of the filesystem_. Plan accordingly! -You can use SDL_GetBasePath() to find where the program is running from and -chdir() there directly. - - -## You have a Cocoa App! - -Your SDL app is essentially a Cocoa application. When your app -starts up and the libraries finish loading, a Cocoa procedure is called, -which sets up the working directory and calls your main() method. -You are free to modify your Cocoa app with generally no consequence -to SDL. You cannot, however, easily change the SDL window itself. -Functionality may be added in the future to help this. - -# Bug reports - -Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/). -Please feel free to report bugs there! - +# Mac OS X (aka macOS). + +These instructions are for people using Apple's Mac OS X (pronounced +"ten"), which in newer versions is just referred to as "macOS". + +From the developer's point of view, macOS is a sort of hybrid Mac and +Unix system, and you have the option of using either traditional +command line tools or Apple's IDE Xcode. + +# Command Line Build + +To build SDL using the command line, use the standard configure and make +process: + +```bash +mkdir build +cd build +../configure +make +sudo make install +``` + +CMake is also known to work, although it continues to be a work in progress: + +```bash +mkdir build +cd build +cmake -DCMAKE_BUILD_TYPE=Release .. +make +sudo make install +``` + + +You can also build SDL as a Universal library (a single binary for both +64-bit Intel and ARM architectures), by using the build-scripts/clang-fat.sh +script. + +```bash +mkdir build +cd build +CC=$PWD/../build-scripts/clang-fat.sh ../configure +make +sudo make install +``` + +This script builds SDL with 10.9 ABI compatibility on 64-bit Intel and 11.0 +ABI compatibility on ARM64 architectures. For best compatibility you +should compile your application the same way. + +Please note that building SDL requires at least Xcode 6 and the 10.9 SDK. +PowerPC support for macOS has been officially dropped as of SDL 2.0.2. +32-bit Intel and macOS 10.8 runtime support has been officially dropped as +of SDL 2.24.0. + +To use the library once it's built, you essential have two possibilities: +use the traditional autoconf/automake/make method, or use Xcode. + + +# Caveats for using SDL with Mac OS X + +If you register your own NSApplicationDelegate (using [NSApp setDelegate:]), +SDL will not register its own. This means that SDL will not terminate using +SDL_Quit if it receives a termination request, it will terminate like a +normal app, and it will not send a SDL_DROPFILE when you request to open a +file with the app. To solve these issues, put the following code in your +NSApplicationDelegate implementation: + + +```objc +- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender +{ + if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_QUIT; + SDL_PushEvent(&event); + } + + return NSTerminateCancel; +} + +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup([filename UTF8String]); + return (SDL_PushEvent(&event) > 0); + } + + return NO; +} +``` + +# Using the Simple DirectMedia Layer with a traditional Makefile + +An existing autoconf/automake build system for your SDL app has good chances +to work almost unchanged on macOS. However, to produce a "real" Mac binary +that you can distribute to users, you need to put the generated binary into a +so called "bundle", which is basically a fancy folder with a name like +"MyCoolGame.app". + +To get this build automatically, add something like the following rule to +your Makefile.am: + +```make +bundle_contents = APP_NAME.app/Contents +APP_NAME_bundle: EXE_NAME + mkdir -p $(bundle_contents)/MacOS + mkdir -p $(bundle_contents)/Resources + echo "APPL????" > $(bundle_contents)/PkgInfo + $(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/ +``` + +You should replace `EXE_NAME` with the name of the executable. `APP_NAME` is +what will be visible to the user in the Finder. Usually it will be the same +as `EXE_NAME` but capitalized. E.g. if `EXE_NAME` is "testgame" then `APP_NAME` +usually is "TestGame". You might also want to use `@PACKAGE@` to use the +package name as specified in your configure.ac file. + +If your project builds more than one application, you will have to do a bit +more. For each of your target applications, you need a separate rule. + +If you want the created bundles to be installed, you may want to add this +rule to your Makefile.am: + +```make +install-exec-hook: APP_NAME_bundle + rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app + mkdir -p $(DESTDIR)$(prefix)/Applications/ + cp -r $< /$(DESTDIR)$(prefix)Applications/ +``` + +This rule takes the Bundle created by the rule from step 3 and installs them +into "$(DESTDIR)$(prefix)/Applications/". + +Again, if you want to install multiple applications, you will have to augment +the make rule accordingly. + +But beware! That is only part of the story! With the above, you end up with +a barebones .app bundle, which is double-clickable from the Finder. But +there are some more things you should do before shipping your product... + +1. The bundle right now probably is dynamically linked against SDL. That + means that when you copy it to another computer, *it will not run*, + unless you also install SDL on that other computer. A good solution + for this dilemma is to static link against SDL. On OS X, you can + achieve that by linking against the libraries listed by + + ```bash + sdl-config --static-libs + ``` + + instead of those listed by + + ```bash + sdl-config --libs + ``` + + Depending on how exactly SDL is integrated into your build systems, the + way to achieve that varies, so I won't describe it here in detail + +2. Add an 'Info.plist' to your application. That is a special XML file which + contains some meta-information about your application (like some copyright + information, the version of your app, the name of an optional icon file, + and other things). Part of that information is displayed by the Finder + when you click on the .app, or if you look at the "Get Info" window. + More information about Info.plist files can be found on Apple's homepage. + + +As a final remark, let me add that I use some of the techniques (and some +variations of them) in [Exult](https://github.com/exult/exult) and +[ScummVM](https://github.com/scummvm/scummvm); both are available in source on +the net, so feel free to take a peek at them for inspiration! + + +# Using the Simple DirectMedia Layer with Xcode + +These instructions are for using Apple's Xcode IDE to build SDL applications. + +## First steps + +The first thing to do is to unpack the Xcode.tar.gz archive in the +top level SDL directory (where the Xcode.tar.gz archive resides). +Because Stuffit Expander will unpack the archive into a subdirectory, +you should unpack the archive manually from the command line: + +```bash +cd [path_to_SDL_source] +tar zxf Xcode.tar.gz +``` + +This will create a new folder called Xcode, which you can browse +normally from the Finder. + +## Building the Framework + +The SDL Library is packaged as a framework bundle, an organized +relocatable folder hierarchy of executable code, interface headers, +and additional resources. For practical purposes, you can think of a +framework as a more user and system-friendly shared library, whose library +file behaves more or less like a standard UNIX shared library. + +To build the framework, simply open the framework project and build it. +By default, the framework bundle "SDL.framework" is installed in +/Library/Frameworks. Therefore, the testers and project stationary expect +it to be located there. However, it will function the same in any of the +following locations: + +* ~/Library/Frameworks +* /Local/Library/Frameworks +* /System/Library/Frameworks + +## Build Options + +There are two "Build Styles" (See the "Targets" tab) for SDL. +"Deployment" should be used if you aren't tweaking the SDL library. +"Development" should be used to debug SDL apps or the library itself. + +## Building the Testers + +Open the SDLTest project and build away! + +## Using the Project Stationary + +Copy the stationary to the indicated folders to access it from +the "New Project" and "Add target" menus. What could be easier? + +## Setting up a new project by hand + +Some of you won't want to use the Stationary so I'll give some tips: + +(this is accurate as of Xcode 12.5.) + +* Click "File" -> "New" -> "Project... +* Choose "macOS" and then "App" from the "Application" section. +* Fill out the options in the next window. User interface is "XIB" and + Language is "Objective-C". +* Remove "main.m" from your project +* Remove "MainMenu.xib" from your project +* Remove "AppDelegates.*" from your project +* Add "\$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path +* Add "\$(HOME)/Library/Frameworks" to the frameworks search path +* Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" +* Add your files +* Clean and build + +## Building from command line + +Use `xcode-build` in the same directory as your .pbxproj file + +## Running your app + +You can send command line args to your app by either invoking it from +the command line (in *.app/Contents/MacOS) or by entering them in the +Executables" panel of the target settings. + +# Implementation Notes + +Some things that may be of interest about how it all works... + +## Working directory + +In SDL 1.2, the working directory of your SDL app is by default set to its +parent, but this is no longer the case in SDL 2.0. SDL2 does change the +working directory, which means it'll be whatever the command line prompt +that launched the program was using, or if launched by double-clicking in +the finger, it will be "/", the _root of the filesystem_. Plan accordingly! +You can use SDL_GetBasePath() to find where the program is running from and +chdir() there directly. + + +## You have a Cocoa App! + +Your SDL app is essentially a Cocoa application. When your app +starts up and the libraries finish loading, a Cocoa procedure is called, +which sets up the working directory and calls your main() method. +You are free to modify your Cocoa app with generally no consequence +to SDL. You cannot, however, easily change the SDL window itself. +Functionality may be added in the future to help this. + +# Bug reports + +Bugs are tracked at [the GitHub issue tracker](https://github.com/libsdl-org/SDL/issues/). +Please feel free to report bugs there! + diff --git a/vs/sdl2/docs/README-n3ds.md b/vs/sdl2/docs/README-n3ds.md index ff528eba54..e9e7c7d01d 100644 --- a/vs/sdl2/docs/README-n3ds.md +++ b/vs/sdl2/docs/README-n3ds.md @@ -1,28 +1,28 @@ -# Nintendo 3DS - -SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by: - -- [Pierre Wendling](https://github.com/FtZPetruska) - -Credits to: - -- The awesome people who ported SDL to other homebrew platforms. -- The Devkitpro team for making all the tools necessary to achieve this. - -## Building - -To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run: - -```bash -cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release -cmake --build build -cmake --install build -``` - -## Notes - -- Currently only software rendering is supported. -- SDL2main should be used to ensure ROMFS is enabled. -- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function. -- `SDL_GetBasePath` returns the romfs root instead of the executable's directory. -- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information. +# Nintendo 3DS + +SDL port for the Nintendo 3DS [Homebrew toolchain](https://devkitpro.org/) contributed by: + +- [Pierre Wendling](https://github.com/FtZPetruska) + +Credits to: + +- The awesome people who ported SDL to other homebrew platforms. +- The Devkitpro team for making all the tools necessary to achieve this. + +## Building + +To build for the Nintendo 3DS, make sure you have devkitARM and cmake installed and run: + +```bash +cmake -S. -Bbuild -DCMAKE_TOOLCHAIN_FILE="$DEVKITPRO/cmake/3DS.cmake" -DCMAKE_BUILD_TYPE=Release +cmake --build build +cmake --install build +``` + +## Notes + +- Currently only software rendering is supported. +- SDL2main should be used to ensure ROMFS is enabled. +- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function. +- `SDL_GetBasePath` returns the romfs root instead of the executable's directory. +- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information. diff --git a/vs/sdl2/docs/README-ngage.md b/vs/sdl2/docs/README-ngage.md index 83c2e3384c..e480965218 100644 --- a/vs/sdl2/docs/README-ngage.md +++ b/vs/sdl2/docs/README-ngage.md @@ -1,44 +1,44 @@ -Nokia N-Gage -============ - -SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage -(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev). - -Compiling ---------- - -SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project. -The library is included in the -[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a -sub-module. - -A complete example project based on SDL2 can be found in the GitHub -account of the SDK: [Wordle](https://github.com/ngagesdk/wordle). - -Current level of implementation -------------------------------- - -The video driver currently provides full screen video support with -keyboard input. - -At the moment only the software renderer works. - -Audio is not yet implemented. - -Acknowledgements ----------------- - -Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the -valuable insight into Symbian programming. Without the SDL 1.2 port -which was specially developed for CDoom (Doom for the Nokia 9210), this -adaptation would not have been possible. - -I would like to thank my friends -[Razvan](https://twitter.com/bewarerazvan) and [Dan -Whelan](https://danwhelan.ie/), for their continuous support. Without -you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would -have lost my patience long ago. - -Last but not least, I would like to thank the development team of -[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your -patience and support in troubleshooting helped me a lot. +Nokia N-Gage +============ + +SDL2 port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage +(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev). + +Compiling +--------- + +SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project. +The library is included in the +[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a +sub-module. + +A complete example project based on SDL2 can be found in the GitHub +account of the SDK: [Wordle](https://github.com/ngagesdk/wordle). + +Current level of implementation +------------------------------- + +The video driver currently provides full screen video support with +keyboard input. + +At the moment only the software renderer works. + +Audio is not yet implemented. + +Acknowledgements +---------------- + +Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the +valuable insight into Symbian programming. Without the SDL 1.2 port +which was specially developed for CDoom (Doom for the Nokia 9210), this +adaptation would not have been possible. + +I would like to thank my friends +[Razvan](https://twitter.com/bewarerazvan) and [Dan +Whelan](https://danwhelan.ie/), for their continuous support. Without +you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would +have lost my patience long ago. + +Last but not least, I would like to thank the development team of +[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your +patience and support in troubleshooting helped me a lot. diff --git a/vs/sdl2/docs/README-os2.md b/vs/sdl2/docs/README-os2.md index 148eb33a60..6870ee3ecc 100644 --- a/vs/sdl2/docs/README-os2.md +++ b/vs/sdl2/docs/README-os2.md @@ -1,92 +1,92 @@ -Simple DirectMedia Layer 2 for OS/2 & eComStation -================================================================================ -SDL port for OS/2, authored by Andrey Vasilkin , 2016 - - -OpenGL not supported by this port. - -Additional optional environment variables: - -SDL_AUDIO_SHARE - Values: 0 or 1, default is 0 - Initializes the device as shareable or exclusively acquired. - -SDL_VIDEODRIVER - Values: DIVE or VMAN, default is DIVE - Use video subsystem: Direct interface video extensions (DIVE) or - Video Manager (VMAN). - -You may significantly increase video output speed with OS4 kernel and patched -files vman.dll and dive.dll or with latest versions of ACPI support and video -driver Panorama. - -Latest versions of OS/4 kernel: - http://gus.biysk.ru/os4/ - (Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4) - -Patched files vman.dll and dive.dll: - http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR - - -Compiling: ----------- - -Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see: -https://github.com/open-watcom/ and https://open-watcom.github.io -WATCOM environment variable must to be set to the Open Watcom install -directory. To compile, run: wmake -f Makefile.os2 - - -Installing: ------------ - -- eComStation: - - If you have previously installed SDL2, make a Backup copy of SDL2.dll - located in D:\ecs\dll (where D: is disk on which installed eComStation). - Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll - -- OS/2: - - Copy SDL2.dll to any directory on your LIBPATH. If you have a previous - version installed, close all SDL2 applications before replacing the old - copy. Also make sure that any other older versions of DLLs are removed - from your system. - - -Joysticks in SDL2: ------------------- - -The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version. -Here is the original documentation from SDL-1.2: - -The Joystick detection only works for standard joysticks (2 buttons, 2 axes -and the like). Therefore, if you use a non-standard joystick, you should -specify its features in the SDL_OS2_JOYSTICK environment variable in a batch -file or CONFIG.SYS, so SDL applications can provide full capability to your -device. The syntax is: - -SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS] - -So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls, -the line should be: - -SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0 - -If you want to add spaces in your joystick name, just surround it with -quotes or double-quotes: - -SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0 - -or - -SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0 - - Note however that Balls and Hats are not supported under OS/2, and the -value will be ignored... but it is wise to define these correctly because -in the future those can be supported. - - Also the number of buttons is limited to 2 when using two joysticks, -4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes -and 8 when using a joystick with 2 axes. Notice however these are limitations -of the Joystick Port hardware, not OS/2. +Simple DirectMedia Layer 2 for OS/2 & eComStation +================================================================================ +SDL port for OS/2, authored by Andrey Vasilkin , 2016 + + +OpenGL not supported by this port. + +Additional optional environment variables: + +SDL_AUDIO_SHARE + Values: 0 or 1, default is 0 + Initializes the device as shareable or exclusively acquired. + +SDL_VIDEODRIVER + Values: DIVE or VMAN, default is DIVE + Use video subsystem: Direct interface video extensions (DIVE) or + Video Manager (VMAN). + +You may significantly increase video output speed with OS4 kernel and patched +files vman.dll and dive.dll or with latest versions of ACPI support and video +driver Panorama. + +Latest versions of OS/4 kernel: + http://gus.biysk.ru/os4/ + (Info: https://www.os2world.com/wiki/index.php/Phoenix_OS/4) + +Patched files vman.dll and dive.dll: + http://gus.biysk.ru/os4/test/pached_dll/PATCHED_DLL.RAR + + +Compiling: +---------- + +Open Watcom 1.9 or newer is tested. For the new Open Watcom V2 fork, see: +https://github.com/open-watcom/ and https://open-watcom.github.io +WATCOM environment variable must to be set to the Open Watcom install +directory. To compile, run: wmake -f Makefile.os2 + + +Installing: +----------- + +- eComStation: + + If you have previously installed SDL2, make a Backup copy of SDL2.dll + located in D:\ecs\dll (where D: is disk on which installed eComStation). + Stop all programs running with SDL2. Copy SDL2.dll to D:\ecs\dll + +- OS/2: + + Copy SDL2.dll to any directory on your LIBPATH. If you have a previous + version installed, close all SDL2 applications before replacing the old + copy. Also make sure that any other older versions of DLLs are removed + from your system. + + +Joysticks in SDL2: +------------------ + +The joystick code in SDL2 is a direct forward-port from the SDL-1.2 version. +Here is the original documentation from SDL-1.2: + +The Joystick detection only works for standard joysticks (2 buttons, 2 axes +and the like). Therefore, if you use a non-standard joystick, you should +specify its features in the SDL_OS2_JOYSTICK environment variable in a batch +file or CONFIG.SYS, so SDL applications can provide full capability to your +device. The syntax is: + +SET SDL_OS2_JOYSTICK=[JOYSTICK_NAME] [AXES] [BUTTONS] [HATS] [BALLS] + +So, it you have a Gravis GamePad with 4 axes, 2 buttons, 2 hats and 0 balls, +the line should be: + +SET SDL_OS2_JOYSTICK=Gravis_GamePad 4 2 2 0 + +If you want to add spaces in your joystick name, just surround it with +quotes or double-quotes: + +SET SDL_OS2_JOYSTICK='Gravis GamePad' 4 2 2 0 + +or + +SET SDL_OS2_JOYSTICK="Gravis GamePad" 4 2 2 0 + + Note however that Balls and Hats are not supported under OS/2, and the +value will be ignored... but it is wise to define these correctly because +in the future those can be supported. + + Also the number of buttons is limited to 2 when using two joysticks, +4 when using one joystick with 4 axes, 6 when using a joystick with 3 axes +and 8 when using a joystick with 2 axes. Notice however these are limitations +of the Joystick Port hardware, not OS/2. diff --git a/vs/sdl2/docs/README-ps2.md b/vs/sdl2/docs/README-ps2.md index 3f07580d14..f422da9edb 100644 --- a/vs/sdl2/docs/README-ps2.md +++ b/vs/sdl2/docs/README-ps2.md @@ -1,51 +1,51 @@ -PS2 -====== -SDL2 port for the Sony Playstation 2 contributed by: -- Francisco Javier Trujillo Mata - - -Credit to - - The guys that ported SDL to PSP & Vita because I'm taking them as reference. - - David G. F. for helping me with several issues and tests. - -## Building -To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run: -```bash -cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake -cmake --build build -cmake --install build -``` - -## Hints -The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`. -If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30. - -## Notes -If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer. -So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`. -It could be something similar as: -```c -..... - -SDL_PS2_SKIP_IOP_RESET(); - -int main(int argc, char *argv[]) -{ -..... -``` -For a release binary is recommendable to reset the IOP always. - -Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected. - -## Getting PS2 Dev -[Installing PS2 Dev](https://github.com/ps2dev/ps2dev) - -## Running on PCSX2 Emulator -[PCSX2](https://github.com/PCSX2/pcsx2) - -[More PCSX2 information](https://pcsx2.net/) - -## To Do -- PS2 Screen Keyboard -- Dialogs -- Others +PS2 +====== +SDL2 port for the Sony Playstation 2 contributed by: +- Francisco Javier Trujillo Mata + + +Credit to + - The guys that ported SDL to PSP & Vita because I'm taking them as reference. + - David G. F. for helping me with several issues and tests. + +## Building +To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run: +```bash +cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake +cmake --build build +cmake --install build +``` + +## Hints +The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`. +If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30. + +## Notes +If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer. +So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`. +It could be something similar as: +```c +..... + +SDL_PS2_SKIP_IOP_RESET(); + +int main(int argc, char *argv[]) +{ +..... +``` +For a release binary is recommendable to reset the IOP always. + +Remember to do a clean compilation everytime you enable or disable the `SDL_PS2_SKIP_IOP_RESET` otherwise the change won't be reflected. + +## Getting PS2 Dev +[Installing PS2 Dev](https://github.com/ps2dev/ps2dev) + +## Running on PCSX2 Emulator +[PCSX2](https://github.com/PCSX2/pcsx2) + +[More PCSX2 information](https://pcsx2.net/) + +## To Do +- PS2 Screen Keyboard +- Dialogs +- Others diff --git a/vs/sdl2/docs/README-riscos.md b/vs/sdl2/docs/README-riscos.md index 76b27e0aa3..e4e056b3b5 100644 --- a/vs/sdl2/docs/README-riscos.md +++ b/vs/sdl2/docs/README-riscos.md @@ -1,41 +1,41 @@ -RISC OS -======= - -Requirements: - -* RISC OS 3.5 or later. -* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm). -* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support. -* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions. - - -Compiling: ----------- - -Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported. - -The following commands can be used to build SDL2 for RISC OS using autoconf: - - ./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics - make - make install - -The following commands can be used to build SDL2 for RISC OS using CMake: - - cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF - cmake --build build-riscos - cmake --build build-riscos --target install - - -Current level of implementation -------------------------------- - -The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported. - -The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions. - -The audio, loadso, thread and timer APIs are currently provided by UnixLib. - -GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake. - -The joystick, locale and power APIs are not yet implemented. +RISC OS +======= + +Requirements: + +* RISC OS 3.5 or later. +* [SharedUnixLibrary](http://www.riscos.info/packages/LibraryDetails.html#SharedUnixLibraryarm). +* [DigitalRenderer](http://www.riscos.info/packages/LibraryDetails.html#DRendererarm), for audio support. +* [Iconv](http://www.netsurf-browser.org/projects/iconv/), for `SDL_iconv` and related functions. + + +Compiling: +---------- + +Currently, SDL2 for RISC OS only supports compiling with GCCSDK under Linux. Both the autoconf and CMake build systems are supported. + +The following commands can be used to build SDL2 for RISC OS using autoconf: + + ./configure --host=arm-unknown-riscos --prefix=$GCCSDK_INSTALL_ENV --disable-gcc-atomics + make + make install + +The following commands can be used to build SDL2 for RISC OS using CMake: + + cmake -Bbuild-riscos -DCMAKE_TOOLCHAIN_FILE=$GCCSDK_INSTALL_ENV/toolchain-riscos.cmake -DRISCOS=ON -DCMAKE_INSTALL_PREFIX=$GCCSDK_INSTALL_ENV -DCMAKE_BUILD_TYPE=Release -DSDL_GCC_ATOMICS=OFF + cmake --build build-riscos + cmake --build build-riscos --target install + + +Current level of implementation +------------------------------- + +The video driver currently provides full screen video support with keyboard and mouse input. Windowed mode is not yet supported, but is planned in the future. Only software rendering is supported. + +The filesystem APIs return either Unix-style paths or RISC OS-style paths based on the value of the `__riscosify_control` symbol, as is standard for UnixLib functions. + +The audio, loadso, thread and timer APIs are currently provided by UnixLib. + +GCC atomics are currently broken on some platforms, meaning it's currently necessary to compile with `--disable-gcc-atomics` using autotools or `-DSDL_GCC_ATOMICS=OFF` using CMake. + +The joystick, locale and power APIs are not yet implemented. diff --git a/vs/sdl2/docs/README-versions.md b/vs/sdl2/docs/README-versions.md index 097dba1c7b..d54bf40c1c 100644 --- a/vs/sdl2/docs/README-versions.md +++ b/vs/sdl2/docs/README-versions.md @@ -1,60 +1,60 @@ -# Versioning - -## Since 2.23.0 - -SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak -and older versions of the Linux kernel: - -* The major version (first part) increases when backwards compatibility - is broken, which will happen infrequently. - -* If the minor version (second part) is divisible by 2 - (for example 2.24.x, 2.26.x), this indicates a version of SDL that - is believed to be stable and suitable for production use. - - * In stable releases, the patchlevel or micro version (third part) - indicates bugfix releases. Bugfix releases should not add or - remove ABI, so the ".0" release (for example 2.24.0) should be - forwards-compatible with all the bugfix releases from the - same cycle (for example 2.24.1). - - * The minor version increases when new API or ABI is added, or when - other significant changes are made. Newer minor versions are - backwards-compatible, but not fully forwards-compatible. - For example, programs built against SDL 2.24.x should work fine - with SDL 2.26.x, but programs built against SDL 2.26.x will not - necessarily work with 2.24.x. - -* If the minor version (second part) is not divisible by 2 - (for example 2.23.x, 2.25.x), this indicates a development prerelease - of SDL that is not suitable for stable software distributions. - Use with caution. - - * The patchlevel or micro version (third part) increases with - each prerelease. - - * Each prerelease might add new API and/or ABI. - - * Prereleases are backwards-compatible with older stable branches. - For example, 2.25.x will be backwards-compatible with 2.24.x. - - * Prereleases are not guaranteed to be backwards-compatible with - each other. For example, new API or ABI added in 2.25.1 - might be removed or changed in 2.25.2. - If this would be a problem for you, please do not use prereleases. - - * Only upgrade to a prerelease if you can guarantee that you will - promptly upgrade to the stable release that follows it. - For example, do not upgrade to 2.23.x unless you will be able to - upgrade to 2.24.0 when it becomes available. - - * Software distributions that have a freeze policy (in particular Linux - distributions with a release cycle, such as Debian and Fedora) - should usually only package stable releases, and not prereleases. - -## Before 2.23.0 - -Older versions of SDL followed a similar policy, but instead of the -odd/even rule applying to the minor version, it applied to the patchlevel -(micro version, third part). For example, 2.0.22 was a stable release -and 2.0.21 was a prerelease. +# Versioning + +## Since 2.23.0 + +SDL follows an "odd/even" versioning policy, similar to GLib, GTK, Flatpak +and older versions of the Linux kernel: + +* The major version (first part) increases when backwards compatibility + is broken, which will happen infrequently. + +* If the minor version (second part) is divisible by 2 + (for example 2.24.x, 2.26.x), this indicates a version of SDL that + is believed to be stable and suitable for production use. + + * In stable releases, the patchlevel or micro version (third part) + indicates bugfix releases. Bugfix releases should not add or + remove ABI, so the ".0" release (for example 2.24.0) should be + forwards-compatible with all the bugfix releases from the + same cycle (for example 2.24.1). + + * The minor version increases when new API or ABI is added, or when + other significant changes are made. Newer minor versions are + backwards-compatible, but not fully forwards-compatible. + For example, programs built against SDL 2.24.x should work fine + with SDL 2.26.x, but programs built against SDL 2.26.x will not + necessarily work with 2.24.x. + +* If the minor version (second part) is not divisible by 2 + (for example 2.23.x, 2.25.x), this indicates a development prerelease + of SDL that is not suitable for stable software distributions. + Use with caution. + + * The patchlevel or micro version (third part) increases with + each prerelease. + + * Each prerelease might add new API and/or ABI. + + * Prereleases are backwards-compatible with older stable branches. + For example, 2.25.x will be backwards-compatible with 2.24.x. + + * Prereleases are not guaranteed to be backwards-compatible with + each other. For example, new API or ABI added in 2.25.1 + might be removed or changed in 2.25.2. + If this would be a problem for you, please do not use prereleases. + + * Only upgrade to a prerelease if you can guarantee that you will + promptly upgrade to the stable release that follows it. + For example, do not upgrade to 2.23.x unless you will be able to + upgrade to 2.24.0 when it becomes available. + + * Software distributions that have a freeze policy (in particular Linux + distributions with a release cycle, such as Debian and Fedora) + should usually only package stable releases, and not prereleases. + +## Before 2.23.0 + +Older versions of SDL followed a similar policy, but instead of the +odd/even rule applying to the minor version, it applied to the patchlevel +(micro version, third part). For example, 2.0.22 was a stable release +and 2.0.21 was a prerelease. diff --git a/vs/sdl2/docs/README-visualc.md b/vs/sdl2/docs/README-visualc.md index fb0edb9ef3..fd34b35e1d 100644 --- a/vs/sdl2/docs/README-visualc.md +++ b/vs/sdl2/docs/README-visualc.md @@ -1,114 +1,114 @@ -Using SDL with Microsoft Visual C++ -=================================== - -### by Lion Kimbro with additions by James Turk - -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) +Using SDL with Microsoft Visual C++ +=================================== + +### by Lion Kimbro with additions by James Turk + +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/vs/sdl2/docs/README-vita.md b/vs/sdl2/docs/README-vita.md index 0a11cf806b..3dbaf1cd40 100644 --- a/vs/sdl2/docs/README-vita.md +++ b/vs/sdl2/docs/README-vita.md @@ -1,33 +1,33 @@ -PS Vita -======= -SDL port for the Sony Playstation Vita and Sony Playstation TV - -Credit to -* xerpi, cpasjuste and rsn8887 for initial (vita2d) port -* vitasdk/dolcesdk devs -* CBPS discord (Namely Graphene and SonicMastr) - -Building --------- -To build for the PSVita, 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 ------ -* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON` - These renderers support 720p and 1080i resolutions. These can be specified with: - `SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);` -* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK. - They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);` - anytime before video subsystem initialization. -* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON` -* 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. - Individual touchscreens can be disabled with: - `SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);` -* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita. +PS Vita +======= +SDL port for the Sony Playstation Vita and Sony Playstation TV + +Credit to +* xerpi, cpasjuste and rsn8887 for initial (vita2d) port +* vitasdk/dolcesdk devs +* CBPS discord (Namely Graphene and SonicMastr) + +Building +-------- +To build for the PSVita, 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 +----- +* gles1/gles2 support and renderers are disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PVR=ON` + These renderers support 720p and 1080i resolutions. These can be specified with: + `SDL_setenv("VITA_RESOLUTION", "720", 1);` and `SDL_setenv("VITA_RESOLUTION", "1080", 1);` +* Desktop GL 1.X and 2.X support and renderers are also disabled by default and also can be enabled with `-DVIDEO_VITA_PVR=ON` as long as gl4es4vita is present in your SDK. + They support the same resolutions as the gles1/gles2 backends and require specifying `SDL_setenv("VITA_PVR_OGL", "1", 1);` + anytime before video subsystem initialization. +* gles2 support via PIB is disabled by default and can be enabled by configuring with `-DVIDEO_VITA_PIB=ON` +* 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. + Individual touchscreens can be disabled with: + `SDL_setenv("VITA_DISABLE_TOUCH_FRONT", "1", 1);` and `SDL_setenv("VITA_DISABLE_TOUCH_BACK", "1", 1);` +* Support for L2/R2/R3/R3 buttons, haptic feedback and gamepad led only available on PSTV, or when using external ds4 gamepad on vita. diff --git a/vs/sdl2/docs/README-windows.md b/vs/sdl2/docs/README-windows.md index 66b5fb0638..cd29c1f920 100644 --- a/vs/sdl2/docs/README-windows.md +++ b/vs/sdl2/docs/README-windows.md @@ -1,58 +1,58 @@ -# Windows - -## LLVM and Intel C++ compiler support - -SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++ -compiler, but you'll have to manually add the "-msse3" command line option -to at least the SDL_audiocvt.c source file, and possibly others. This may -not be necessary if you build SDL with CMake instead of the included Visual -Studio solution. - -Details are here: https://github.com/libsdl-org/SDL/issues/5186 - - -## OpenGL ES 2.x support - -SDL has support for OpenGL ES 2.x under Windows via two alternative -implementations. - -The most straightforward method consists in running your app in a system with -a graphic card paired with a relatively recent (as of November of 2013) driver -which supports the WGL_EXT_create_context_es2_profile extension. Vendors known -to ship said extension on Windows currently include nVidia and Intel. - -The other method involves using the -[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x -context is requested and no WGL_EXT_create_context_es2_profile extension is -found, SDL will try to load the libEGL.dll library provided by ANGLE. - -To obtain the ANGLE binaries, you can either compile from source from -https://chromium.googlesource.com/angle/angle or copy the relevant binaries -from a recent Chrome/Chromium install for Windows. The files you need are: - -- libEGL.dll -- libGLESv2.dll -- d3dcompiler_46.dll (supports Windows Vista or later, better shader - compiler) *or* d3dcompiler_43.dll (supports Windows XP or later) - -If you compile ANGLE from source, you can configure it so it does not need the -d3dcompiler_* DLL at all (for details on this, see their documentation). -However, by default SDL will try to preload the d3dcompiler_46.dll to -comply with ANGLE's requirements. If you wish SDL to preload -d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you -can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more -details). - -Known Bugs: - -- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears - that there's a bug in the library which prevents the window contents from - refreshing if this is set to anything other than the default value. - -## Vulkan Surface Support - -Support for creating Vulkan surfaces is configured on by default. To disable -it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You -must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to -use Vulkan graphics in your application. - +# Windows + +## LLVM and Intel C++ compiler support + +SDL will build with the Visual Studio project files with LLVM-based compilers, such as the Intel oneAPI C++ +compiler, but you'll have to manually add the "-msse3" command line option +to at least the SDL_audiocvt.c source file, and possibly others. This may +not be necessary if you build SDL with CMake instead of the included Visual +Studio solution. + +Details are here: https://github.com/libsdl-org/SDL/issues/5186 + + +## OpenGL ES 2.x support + +SDL has support for OpenGL ES 2.x under Windows via two alternative +implementations. + +The most straightforward method consists in running your app in a system with +a graphic card paired with a relatively recent (as of November of 2013) driver +which supports the WGL_EXT_create_context_es2_profile extension. Vendors known +to ship said extension on Windows currently include nVidia and Intel. + +The other method involves using the +[ANGLE library](https://code.google.com/p/angleproject/). If an OpenGL ES 2.x +context is requested and no WGL_EXT_create_context_es2_profile extension is +found, SDL will try to load the libEGL.dll library provided by ANGLE. + +To obtain the ANGLE binaries, you can either compile from source from +https://chromium.googlesource.com/angle/angle or copy the relevant binaries +from a recent Chrome/Chromium install for Windows. The files you need are: + +- libEGL.dll +- libGLESv2.dll +- d3dcompiler_46.dll (supports Windows Vista or later, better shader + compiler) *or* d3dcompiler_43.dll (supports Windows XP or later) + +If you compile ANGLE from source, you can configure it so it does not need the +d3dcompiler_* DLL at all (for details on this, see their documentation). +However, by default SDL will try to preload the d3dcompiler_46.dll to +comply with ANGLE's requirements. If you wish SDL to preload +d3dcompiler_43.dll (to support Windows XP) or to skip this step at all, you +can use the SDL_HINT_VIDEO_WIN_D3DCOMPILER hint (see SDL_hints.h for more +details). + +Known Bugs: + +- SDL_GL_SetSwapInterval is currently a no op when using ANGLE. It appears + that there's a bug in the library which prevents the window contents from + refreshing if this is set to anything other than the default value. + +## Vulkan Surface Support + +Support for creating Vulkan surfaces is configured on by default. To disable +it change the value of `SDL_VIDEO_VULKAN` to 0 in `SDL_config_windows.h`. You +must install the [Vulkan SDK](https://www.lunarg.com/vulkan-sdk/) in order to +use Vulkan graphics in your application. + diff --git a/vs/sdl2/include/SDL.h b/vs/sdl2/include/SDL.h index 9ba8f68c6e..20c903b2fe 100644 --- a/vs/sdl2/include/SDL.h +++ b/vs/sdl2/include/SDL.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_assert.h b/vs/sdl2/include/SDL_assert.h index 87d5c1bdb6..a396d4e02e 100644 --- a/vs/sdl2/include/SDL_assert.h +++ b/vs/sdl2/include/SDL_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() __builtin_debugtrap() #elif ( (!defined(__NACL__)) && ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))) ) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) +#elif (defined(__GNUC__) || defined(__clang__)) && defined(__riscv) + #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "ebreak\n\t" ) #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__) diff --git a/vs/sdl2/include/SDL_atomic.h b/vs/sdl2/include/SDL_atomic.h index 1dd816a382..1fa18f49fe 100644 --- a/vs/sdl2/include/SDL_atomic.h +++ b/vs/sdl2/include/SDL_atomic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -209,7 +209,7 @@ typedef void (*SDL_KernelMemoryBarrierFunc)(); #if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__) || defined(__ARM_ARCH_8A__) #define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory") #define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory") -#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_5TE__) +#elif defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) #ifdef __thumb__ /* The mcr instruction isn't available in thumb mode, use real functions */ #define SDL_MEMORY_BARRIER_USES_FUNCTION diff --git a/vs/sdl2/include/SDL_audio.h b/vs/sdl2/include/SDL_audio.h index ccd35982df..bd8e7ab6fa 100644 --- a/vs/sdl2/include/SDL_audio.h +++ b/vs/sdl2/include/SDL_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_bits.h b/vs/sdl2/include/SDL_bits.h index 81161ae5f3..83e8a78c78 100644 --- a/vs/sdl2/include/SDL_bits.h +++ b/vs/sdl2/include/SDL_bits.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_blendmode.h b/vs/sdl2/include/SDL_blendmode.h index 4ecbe50785..09d01477d8 100644 --- a/vs/sdl2/include/SDL_blendmode.h +++ b/vs/sdl2/include/SDL_blendmode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +65,8 @@ typedef enum typedef enum { SDL_BLENDOPERATION_ADD = 0x1, /**< dst + src: supported by all renderers */ - SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ - SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ + SDL_BLENDOPERATION_SUBTRACT = 0x2, /**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES */ + SDL_BLENDOPERATION_REV_SUBTRACT = 0x3, /**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES */ SDL_BLENDOPERATION_MINIMUM = 0x4, /**< min(dst, src) : supported by D3D9, D3D11 */ SDL_BLENDOPERATION_MAXIMUM = 0x5 /**< max(dst, src) : supported by D3D9, D3D11 */ } SDL_BlendOperation; diff --git a/vs/sdl2/include/SDL_clipboard.h b/vs/sdl2/include/SDL_clipboard.h index 7c351fbb9c..bd4b044c6d 100644 --- a/vs/sdl2/include/SDL_clipboard.h +++ b/vs/sdl2/include/SDL_clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config.h b/vs/sdl2/include/SDL_config.h index fd2fe88762..49605b1e8a 100644 --- a/vs/sdl2/include/SDL_config.h +++ b/vs/sdl2/include/SDL_config.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config.h.cmake b/vs/sdl2/include/SDL_config.h.cmake index 7512bb1cc5..ffcafd895c 100644 --- a/vs/sdl2/include/SDL_config.h.cmake +++ b/vs/sdl2/include/SDL_config.h.cmake @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ /* Comment this if you want to build without any C library requirements */ #cmakedefine HAVE_LIBC 1 -#if HAVE_LIBC +#ifdef HAVE_LIBC /* Useful headers */ #cmakedefine STDC_HEADERS 1 @@ -190,6 +190,8 @@ #cmakedefine HAVE_FOPEN64 1 #cmakedefine HAVE_FSEEKO 1 #cmakedefine HAVE_FSEEKO64 1 +#cmakedefine HAVE_MEMFD_CREATE 1 +#cmakedefine HAVE_POSIX_FALLOCATE 1 #cmakedefine HAVE_SIGACTION 1 #cmakedefine HAVE_SA_SIGACTION 1 #cmakedefine HAVE_SETJMP 1 @@ -200,6 +202,7 @@ #cmakedefine HAVE_GETPAGESIZE 1 #cmakedefine HAVE_MPROTECT 1 #cmakedefine HAVE_ICONV 1 +#cmakedefine SDL_USE_LIBICONV 1 #cmakedefine HAVE_PTHREAD_SETNAME_NP 1 #cmakedefine HAVE_PTHREAD_SET_NAME_NP 1 #cmakedefine HAVE_SEM_TIMEDWAIT 1 @@ -240,7 +243,7 @@ #cmakedefine HAVE_LIBUDEV_H 1 #cmakedefine HAVE_LIBSAMPLERATE_H 1 -#cmakedefine HAVE_LIBDECOR_H 1 +#cmakedefine HAVE_LIBDECOR_H 1 #cmakedefine HAVE_D3D_H @HAVE_D3D_H@ #cmakedefine HAVE_D3D11_H @HAVE_D3D11_H@ @@ -259,8 +262,7 @@ #cmakedefine HAVE_ROAPI_H @HAVE_ROAPI_H@ #cmakedefine HAVE_SHELLSCALINGAPI_H @HAVE_SHELLSCALINGAPI_H@ -#cmakedefine HAVE_XINPUT_GAMEPAD_EX @HAVE_XINPUT_GAMEPAD_EX@ -#cmakedefine HAVE_XINPUT_STATE_EX @HAVE_XINPUT_STATE_EX@ +#cmakedefine USE_POSIX_SPAWN @USE_POSIX_SPAWN@ /* SDL internal assertion support */ #if @SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED@ @@ -525,7 +527,7 @@ #cmakedefine SDL_ARM_NEON_BLITTERS @SDL_ARM_NEON_BLITTERS@ /* Whether SDL_DYNAMIC_API needs dlopen */ -#cmakedefine DYNAPI_NEEDS_DLOPEN @DYNAPI_NEEDS_DLOPEN@ +#cmakedefine DYNAPI_NEEDS_DLOPEN @DYNAPI_NEEDS_DLOPEN@ /* Enable dynamic libsamplerate support */ #cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@ diff --git a/vs/sdl2/include/SDL_config.h.in b/vs/sdl2/include/SDL_config.h.in index d6460b783e..f5dd166ff5 100644 --- a/vs/sdl2/include/SDL_config.h.in +++ b/vs/sdl2/include/SDL_config.h.in @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ /* Comment this if you want to build without any C library requirements */ #undef HAVE_LIBC -#if HAVE_LIBC +#ifdef HAVE_LIBC /* Useful headers */ #undef STDC_HEADERS @@ -204,12 +204,15 @@ #undef HAVE_GETPAGESIZE #undef HAVE_MPROTECT #undef HAVE_ICONV +#undef SDL_USE_LIBICONV #undef HAVE_PTHREAD_SETNAME_NP #undef HAVE_PTHREAD_SET_NAME_NP #undef HAVE_SEM_TIMEDWAIT #undef HAVE_GETAUXVAL #undef HAVE_ELF_AUX_INFO #undef HAVE_POLL +#undef HAVE_MEMFD_CREATE +#undef HAVE_POSIX_FALLOCATE #undef HAVE__EXIT #else @@ -241,8 +244,6 @@ #undef HAVE_DXGI_H #undef HAVE_WINDOWS_GAMING_INPUT_H #undef HAVE_XINPUT_H -#undef HAVE_XINPUT_GAMEPAD_EX -#undef HAVE_XINPUT_STATE_EX #undef HAVE_MMDEVICEAPI_H #undef HAVE_AUDIOCLIENT_H diff --git a/vs/sdl2/include/SDL_config_android.h b/vs/sdl2/include/SDL_config_android.h index d88c026be4..00ffef8527 100644 --- a/vs/sdl2/include/SDL_config_android.h +++ b/vs/sdl2/include/SDL_config_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_emscripten.h b/vs/sdl2/include/SDL_config_emscripten.h index 68660a14a7..637cdae503 100644 --- a/vs/sdl2/include/SDL_config_emscripten.h +++ b/vs/sdl2/include/SDL_config_emscripten.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_iphoneos.h b/vs/sdl2/include/SDL_config_iphoneos.h index 02011c4c89..2743901fe5 100644 --- a/vs/sdl2/include/SDL_config_iphoneos.h +++ b/vs/sdl2/include/SDL_config_iphoneos.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_macosx.h b/vs/sdl2/include/SDL_config_macosx.h index d7ad6cc712..2db760a9fd 100644 --- a/vs/sdl2/include/SDL_config_macosx.h +++ b/vs/sdl2/include/SDL_config_macosx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_minimal.h b/vs/sdl2/include/SDL_config_minimal.h index d6dee64d66..ceedda2d64 100644 --- a/vs/sdl2/include/SDL_config_minimal.h +++ b/vs/sdl2/include/SDL_config_minimal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_ngage.h b/vs/sdl2/include/SDL_config_ngage.h index 25453b3a24..61c26c2cf7 100644 --- a/vs/sdl2/include/SDL_config_ngage.h +++ b/vs/sdl2/include/SDL_config_ngage.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_os2.h b/vs/sdl2/include/SDL_config_os2.h index 2effe1a880..b2b061d716 100644 --- a/vs/sdl2/include/SDL_config_os2.h +++ b/vs/sdl2/include/SDL_config_os2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ /* dynamically loaded libusb-1.0 dll: */ #define SDL_LIBUSB_DYNAMIC "usb100.dll" #endif -/*#undef SDL_JOYSTICK_VIRTUAL */ +#define SDL_JOYSTICK_VIRTUAL 1 /* Enable OpenGL support */ /* #undef SDL_VIDEO_OPENGL */ @@ -114,9 +114,6 @@ #define HAVE_MEMCPY 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMCMP 1 -#define HAVE_WCSLEN 1 -#define HAVE_WCSLCPY 1 -#define HAVE_WCSLCAT 1 #define HAVE_WCSCMP 1 #define HAVE__WCSICMP 1 #define HAVE__WCSNICMP 1 diff --git a/vs/sdl2/include/SDL_config_pandora.h b/vs/sdl2/include/SDL_config_pandora.h index c74fa0c2fd..27b858df1d 100644 --- a/vs/sdl2/include/SDL_config_pandora.h +++ b/vs/sdl2/include/SDL_config_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_windows.h b/vs/sdl2/include/SDL_config_windows.h index 6dc6dc52d9..aae52ebc63 100644 --- a/vs/sdl2/include/SDL_config_windows.h +++ b/vs/sdl2/include/SDL_config_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -99,9 +99,11 @@ typedef unsigned int uintptr_t; #define HAVE_D3D11_H 1 #define HAVE_ROAPI_H 1 #endif -#if defined(WDK_NTDDI_VERSION) && WDK_NTDDI_VERSION > 0x0A000008 /* 10.0.19041.0 */ +#if defined(__has_include) +#if __has_include() && __has_include() #define HAVE_D3D12_H 1 #endif +#endif #if defined(_WIN32_MAXVER) && _WIN32_MAXVER >= 0x0603 /* Windows 8.1 SDK */ #define HAVE_SHELLSCALINGAPI_H 1 #endif @@ -297,9 +299,6 @@ typedef unsigned int uintptr_t; #define SDL_VIDEO_RENDER_D3D12 1 #endif -#if defined(__WIN32__) && (defined(__arm__) || defined(__arm64__) || defined(_M_ARM) || defined(_M_ARM64)) -#define NO_OPENGL /* Don't enable for DOSBox-X on Windows ARM */ -#else /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL #define SDL_VIDEO_OPENGL 1 @@ -319,7 +318,6 @@ typedef unsigned int uintptr_t; #ifndef SDL_VIDEO_OPENGL_EGL #define SDL_VIDEO_OPENGL_EGL 1 #endif -#endif /* Enable Vulkan support */ #define SDL_VIDEO_VULKAN 1 diff --git a/vs/sdl2/include/SDL_config_wingdk.h b/vs/sdl2/include/SDL_config_wingdk.h index f9d3ff46d3..c2a63b5ba8 100644 --- a/vs/sdl2/include/SDL_config_wingdk.h +++ b/vs/sdl2/include/SDL_config_wingdk.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_config_winrt.h b/vs/sdl2/include/SDL_config_winrt.h index 8efde90991..3a11456431 100644 --- a/vs/sdl2/include/SDL_config_winrt.h +++ b/vs/sdl2/include/SDL_config_winrt.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +54,7 @@ /* Useful headers */ #define HAVE_DXGI_H 1 -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#if !SDL_WINAPI_FAMILY_PHONE #define HAVE_XINPUT_H 1 #endif @@ -161,7 +161,7 @@ #define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various input drivers */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE #define SDL_JOYSTICK_DISABLED 1 #define SDL_HAPTIC_DISABLED 1 #else @@ -208,9 +208,9 @@ #define SDL_VIDEO_RENDER_D3D11 1 /* Disable D3D12 as it's not implemented for WinRT */ -#define SDL_VIDEO_RENDER_D3D12 0 +/* #undef SDL_VIDEO_RENDER_D3D12 */ -#if SDL_VIDEO_OPENGL_ES2 +#ifdef SDL_VIDEO_OPENGL_ES2 #define SDL_VIDEO_RENDER_OGL_ES2 1 #endif diff --git a/vs/sdl2/include/SDL_config_xbox.h b/vs/sdl2/include/SDL_config_xbox.h index 8baf78ed7a..a2ea8cbac9 100644 --- a/vs/sdl2/include/SDL_config_xbox.h +++ b/vs/sdl2/include/SDL_config_xbox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_copying.h b/vs/sdl2/include/SDL_copying.h index b6028bab2e..da9089312c 100644 --- a/vs/sdl2/include/SDL_copying.h +++ b/vs/sdl2/include/SDL_copying.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_cpuinfo.h b/vs/sdl2/include/SDL_cpuinfo.h index ed5e97915e..2a9dd380c2 100644 --- a/vs/sdl2/include/SDL_cpuinfo.h +++ b/vs/sdl2/include/SDL_cpuinfo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_egl.h b/vs/sdl2/include/SDL_egl.h index 6f51c0831a..a4276e6810 100644 --- a/vs/sdl2/include/SDL_egl.h +++ b/vs/sdl2/include/SDL_egl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_endian.h b/vs/sdl2/include/SDL_endian.h index 71bc06729b..591ccac425 100644 --- a/vs/sdl2/include/SDL_endian.h +++ b/vs/sdl2/include/SDL_endian.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_error.h b/vs/sdl2/include/SDL_error.h index 31c22616cc..2df6463ad9 100644 --- a/vs/sdl2/include/SDL_error.h +++ b/vs/sdl2/include/SDL_error.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_events.h b/vs/sdl2/include/SDL_events.h index 9d09703180..eccbba2553 100644 --- a/vs/sdl2/include/SDL_events.h +++ b/vs/sdl2/include/SDL_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +131,8 @@ typedef enum SDL_CONTROLLERTOUCHPADMOTION, /**< Game controller touchpad finger was moved */ SDL_CONTROLLERTOUCHPADUP, /**< Game controller touchpad finger was lifted */ SDL_CONTROLLERSENSORUPDATE, /**< Game controller sensor was updated */ + SDL_CONTROLLERUPDATECOMPLETE_RESERVED_FOR_SDL3, + SDL_CONTROLLERSTEAMHANDLEUPDATED, /**< Game controller Steam handle has changed */ /* Touch events */ SDL_FINGERDOWN = 0x700, @@ -446,7 +448,7 @@ typedef struct SDL_ControllerButtonEvent */ typedef struct SDL_ControllerDeviceEvent { - Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, or ::SDL_CONTROLLERDEVICEREMAPPED */ + Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED, ::SDL_CONTROLLERDEVICEREMOVED, ::SDL_CONTROLLERDEVICEREMAPPED, or ::SDL_CONTROLLERSTEAMHANDLEUPDATED */ Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ Sint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED or REMAPPED event */ } SDL_ControllerDeviceEvent; @@ -580,15 +582,6 @@ typedef struct SDL_QuitEvent Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ } SDL_QuitEvent; -/** - * \brief OS Specific event - */ -typedef struct SDL_OSEvent -{ - Uint32 type; /**< ::SDL_QUIT */ - Uint32 timestamp; /**< In milliseconds, populated using SDL_GetTicks() */ -} SDL_OSEvent; - /** * \brief A user-defined event type (event.user.*) */ diff --git a/vs/sdl2/include/SDL_filesystem.h b/vs/sdl2/include/SDL_filesystem.h index 4cad657ec8..07498898d3 100644 --- a/vs/sdl2/include/SDL_filesystem.h +++ b/vs/sdl2/include/SDL_filesystem.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ extern "C" { * directory of the application as it is uncommon to store resources outside * the executable. As such it is not a writable directory. * - * The returned path is guaranteed to end with a path separator ('\' on + * 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 @@ -120,7 +120,7 @@ extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. * - * The returned path is guaranteed to end with a path separator ('\' on + * 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 diff --git a/vs/sdl2/include/SDL_gamecontroller.h b/vs/sdl2/include/SDL_gamecontroller.h index 140054d36e..281fa356c6 100644 --- a/vs/sdl2/include/SDL_gamecontroller.h +++ b/vs/sdl2/include/SDL_gamecontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 @@ typedef enum SDL_CONTROLLER_TYPE_NVIDIA_SHIELD, SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT, SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT, - SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR, + SDL_CONTROLLER_TYPE_MAX } SDL_GameControllerType; typedef enum @@ -523,6 +524,20 @@ extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameCont */ extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller); +/** + * Get the Steam Input handle of an opened controller, if available. + * + * Returns an InputHandle_t for the controller that can be used with Steam Input API: + * https://partner.steamgames.com/doc/api/ISteamInput + * + * \param gamecontroller the game controller object to query. + * \returns the gamepad handle, or 0 if unavailable. + * + * \since This function is available since SDL 2.30.0. + */ +extern DECLSPEC Uint64 SDLCALL SDL_GameControllerGetSteamHandle(SDL_GameController *gamecontroller); + + /** * Check if a controller has been opened and is currently connected. * @@ -598,7 +613,9 @@ extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); * and are centered within ~8000 of zero, though advanced UI will allow users to set * or autodetect the dead zone, which varies between controllers. * - * Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX. + * Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX + * (fully pressed) when reported by SDL_GameControllerGetAxis(). Note that this is not the + * same range that will be reported by the lower-level SDL_GetJoystickAxis(). */ typedef enum { @@ -687,8 +704,13 @@ SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameController * * 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). + * For thumbsticks, the state is a value ranging from -32768 (up/left) + * to 32767 (down/right). + * + * Triggers range from 0 when released to 32767 when fully pressed, and + * never return a negative value. Note that this differs from the value + * reported by the lower-level SDL_GetJoystickAxis(), which normally uses + * the full range. * * \param gamecontroller a game controller * \param axis an axis index (one of the SDL_GameControllerAxis values) diff --git a/vs/sdl2/include/SDL_gesture.h b/vs/sdl2/include/SDL_gesture.h index db70b4dd84..4fffa5f3e8 100644 --- a/vs/sdl2/include/SDL_gesture.h +++ b/vs/sdl2/include/SDL_gesture.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_guid.h b/vs/sdl2/include/SDL_guid.h index d964223c62..7daa5f1f58 100644 --- a/vs/sdl2/include/SDL_guid.h +++ b/vs/sdl2/include/SDL_guid.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_haptic.h b/vs/sdl2/include/SDL_haptic.h index 2462a1e47b..c9ed847df0 100644 --- a/vs/sdl2/include/SDL_haptic.h +++ b/vs/sdl2/include/SDL_haptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_hidapi.h b/vs/sdl2/include/SDL_hidapi.h index 0575100357..b9d8ffac38 100644 --- a/vs/sdl2/include/SDL_hidapi.h +++ b/vs/sdl2/include/SDL_hidapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_hints.h b/vs/sdl2/include/SDL_hints.h index c808a60db5..e775a6509b 100644 --- a/vs/sdl2/include/SDL_hints.h +++ b/vs/sdl2/include/SDL_hints.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -631,6 +631,110 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS "SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS" +/** + * A variable containing a list of arcade stick style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES "SDL_JOYSTICK_ARCADESTICK_DEVICES" + +/** + * A variable containing a list of devices that are not arcade stick style controllers. This will override SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED" + +/** + * A variable containing a list of devices that should not be considerd joysticks. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES "SDL_JOYSTICK_BLACKLIST_DEVICES" + +/** + * A variable containing a list of devices that should be considered joysticks. This will override SDL_HINT_JOYSTICK_BLACKLIST_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED "SDL_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED" + +/** + * A variable containing a list of flightstick style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES "SDL_JOYSTICK_FLIGHTSTICK_DEVICES" + +/** + * A variable containing a list of devices that are not flightstick style controllers. This will override SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED "SDL_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED" + +/** + * A variable containing a list of devices known to have a GameCube form factor. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES "SDL_JOYSTICK_GAMECUBE_DEVICES" + +/** + * A variable containing a list of devices known not to have a GameCube form factor. This will override SDL_HINT_JOYSTICK_GAMECUBE_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED "SDL_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED" + /** * \brief A variable controlling whether the HIDAPI joystick drivers should be used. * @@ -839,6 +943,17 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_STEAM "SDL_JOYSTICK_HIDAPI_STEAM" +/** + * \brief A variable controlling whether the HIDAPI driver for the Steam Deck builtin controller 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_STEAMDECK "SDL_JOYSTICK_HIDAPI_STEAMDECK" + /** * \brief A variable controlling whether the HIDAPI driver for Nintendo Switch controllers should be used. * @@ -965,6 +1080,24 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED "SDL_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED" +/** + * A variable controlling whether IOKit should be used for controller handling. + * + * This variable can be set to the following values: + * "0" - IOKit is not used + * "1" - IOKit is used (the default) + */ +#define SDL_HINT_JOYSTICK_IOKIT "SDL_JOYSTICK_IOKIT" + +/** + * A variable controlling whether GCController should be used for controller handling. + * + * This variable can be set to the following values: + * "0" - GCController is not used + * "1" - GCController is used (the default) + */ +#define SDL_HINT_JOYSTICK_MFI "SDL_JOYSTICK_MFI" + /** * \brief A variable controlling whether the RAWINPUT joystick drivers should be used for better handling XInput-capable devices. * @@ -1007,6 +1140,32 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_THREAD "SDL_JOYSTICK_THREAD" +/** + * A variable containing a list of throttle style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_THROTTLE_DEVICES "SDL_JOYSTICK_THROTTLE_DEVICES" + +/** + * A variable containing a list of devices that are not throttle style controllers. This will override SDL_HINT_JOYSTICK_THROTTLE_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED "SDL_JOYSTICK_THROTTLE_DEVICES_EXCLUDED" + /** * \brief A variable controlling whether Windows.Gaming.Input should be used for controller handling. * @@ -1016,6 +1175,45 @@ extern "C" { */ #define SDL_HINT_JOYSTICK_WGI "SDL_JOYSTICK_WGI" +/** + * A variable containing a list of wheel style controllers. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_WHEEL_DEVICES "SDL_JOYSTICK_WHEEL_DEVICES" + +/** + * A variable containing a list of devices that are not wheel style controllers. This will override SDL_HINT_JOYSTICK_WHEEL_DEVICES and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED "SDL_JOYSTICK_WHEEL_DEVICES_EXCLUDED" + +/** + * A variable containing a list of devices known to have all axes centered at zero. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES "SDL_JOYSTICK_ZERO_CENTERED_DEVICES" + /** * \brief Determines whether SDL enforces that DRM master is required in order * to initialize the KMSDRM video backend. @@ -1084,6 +1282,22 @@ extern "C" { */ #define SDL_HINT_LINUX_JOYSTICK_DEADZONES "SDL_LINUX_JOYSTICK_DEADZONES" +/** + * \brief A variable controlling the default SDL log levels. + * + * This variable is a comma separated set of category=level tokens that define the default logging levels for SDL applications. + * + * The category can be a numeric category, one of "app", "error", "assert", "system", "audio", "video", "render", "input", "test", or `*` for any unspecified category. + * + * The level can be a numeric level, one of "verbose", "debug", "info", "warn", "error", "critical", or "quiet" to disable that category. + * + * You can omit the category if you want to set the logging level for all categories. + * + * If this hint isn't set, the default log levels are equivalent to: + * "app=info,assert=warn,test=verbose,*=error" + */ +#define SDL_HINT_LOGGING "SDL_LOGGING" + /** * \brief When set don't force the SDL app to become a foreground process * @@ -1474,6 +1688,43 @@ extern "C" { */ #define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" +/** + * \brief A variable controlling whether the Metal render driver select low power device over default one + * + * This variable can be set to the following values: + * "0" - Use the prefered OS device + * "1" - Select a low power one + * + * By default the prefered OS device is used. + */ +#define SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE "SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE" + +/** + * A variable containing a list of ROG gamepad capable mice. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_ROG_GAMEPAD_MICE "SDL_ROG_GAMEPAD_MICE" + +/** + * A variable containing a list of devices that are not ROG gamepad capable mice. This will override SDL_HINT_ROG_GAMEPAD_MICE and the built in device list. + * + * The format of the string is a comma separated list of USB VID/PID pairs + * in hexadecimal form, e.g. + * + * 0xAAAA/0xBBBB,0xCCCC/0xDDDD + * + * The variable can also take the form of @file, in which case the named + * file will be loaded and interpreted as the value of the variable. + */ +#define SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED "SDL_ROG_GAMEPAD_MICE_EXCLUDED" + /** * \brief A variable controlling if VSYNC is automatically disable if doesn't reach the enough FPS * @@ -2431,6 +2682,22 @@ extern "C" { */ #define SDL_HINT_TRACKPAD_IS_TOUCH_ONLY "SDL_TRACKPAD_IS_TOUCH_ONLY" +/** + * Cause SDL to call dbus_shutdown() on quit. + * + * This is useful as a debug tool to validate memory leaks, but shouldn't ever + * be set in production applications, as other libraries used by the application + * might use dbus under the hood and this cause cause crashes if they continue + * after SDL_Quit(). + * + * This variable can be set to the following values: + * "0" - SDL will not call dbus_shutdown() on quit (default) + * "1" - SDL will call dbus_shutdown() on quit + * + * This hint is available since SDL 2.30.0. + */ +#define SDL_HINT_SHUTDOWN_DBUS_ON_QUIT "SDL_SHUTDOWN_DBUS_ON_QUIT" + /** * \brief An enumeration of hint priorities diff --git a/vs/sdl2/include/SDL_joystick.h b/vs/sdl2/include/SDL_joystick.h index b9b4f62280..561e01099c 100644 --- a/vs/sdl2/include/SDL_joystick.h +++ b/vs/sdl2/include/SDL_joystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_keyboard.h b/vs/sdl2/include/SDL_keyboard.h index 435efc24a9..03c7b5a370 100644 --- a/vs/sdl2/include/SDL_keyboard.h +++ b/vs/sdl2/include/SDL_keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -208,7 +208,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); * \sa SDL_GetScancodeName */ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); -extern DECLSPEC SDL_bool SDLCALL SDL_IM_Composition(int more); // Added for DOSBox-X /** * Get a human-readable name for a key. @@ -299,8 +298,10 @@ extern DECLSPEC void SDLCALL SDL_ClearComposition(void); extern DECLSPEC SDL_bool SDLCALL SDL_IsTextInputShown(void); /** - * Set the rectangle used to type Unicode text inputs. - * + * Set the rectangle used to type Unicode text inputs. Native input methods + * will place a window with word suggestions near it, without covering the + * text being inputted. + * * To start text input in a given location, this function is intended to be * called before SDL_StartTextInput, although some platforms support moving * the rectangle even while text input (and a composition) is active. diff --git a/vs/sdl2/include/SDL_keycode.h b/vs/sdl2/include/SDL_keycode.h index 7106223027..57a71bd796 100644 --- a/vs/sdl2/include/SDL_keycode.h +++ b/vs/sdl2/include/SDL_keycode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_loadso.h b/vs/sdl2/include/SDL_loadso.h index ca59b681cb..4edc22e9e7 100644 --- a/vs/sdl2/include/SDL_loadso.h +++ b/vs/sdl2/include/SDL_loadso.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_locale.h b/vs/sdl2/include/SDL_locale.h index 482dbefe76..0b6118f0ef 100644 --- a/vs/sdl2/include/SDL_locale.h +++ b/vs/sdl2/include/SDL_locale.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_log.h b/vs/sdl2/include/SDL_log.h index da733c4023..bd030c6d2d 100644 --- a/vs/sdl2/include/SDL_log.h +++ b/vs/sdl2/include/SDL_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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" { * By default the application category is enabled at the INFO level, * the assert category is enabled at the WARN level, test is enabled * at the VERBOSE level and all other categories are enabled at the - * CRITICAL level. + * ERROR level. */ typedef enum { @@ -352,7 +352,7 @@ extern DECLSPEC void SDLCALL SDL_LogMessage(int category, */ extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, SDL_LogPriority priority, - const char *fmt, va_list ap); + SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); /** * The prototype for the log output callback function. diff --git a/vs/sdl2/include/SDL_main.h b/vs/sdl2/include/SDL_main.h index b4e78db932..a66c84b4e5 100644 --- a/vs/sdl2/include/SDL_main.h +++ b/vs/sdl2/include/SDL_main.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -143,12 +143,6 @@ #define main SDL_main #endif -#ifdef __cplusplus -#define SDL_MAIN_NOEXCEPT noexcept(false) // Added for DOSBox-X -#else -#define SDL_MAIN_NOEXCEPT // Added for DOSBox-X -#endif - #include "begin_code.h" #ifdef __cplusplus extern "C" { @@ -158,8 +152,8 @@ extern "C" { * The prototype for the application's main() function */ typedef int (*SDL_main_func)(int argc, char *argv[]); -//extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); -extern SDLMAIN_DECLSPEC int SDL_main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT; // Changed for DOSBox-X +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); + /** * Circumvent failure of SDL_Init() when not using SDL_main() as an entry diff --git a/vs/sdl2/include/SDL_messagebox.h b/vs/sdl2/include/SDL_messagebox.h index 7896fd1291..5ace6f2dde 100644 --- a/vs/sdl2/include/SDL_messagebox.h +++ b/vs/sdl2/include/SDL_messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_metal.h b/vs/sdl2/include/SDL_metal.h index f36e34878c..50f7b2aeb4 100644 --- a/vs/sdl2/include/SDL_metal.h +++ b/vs/sdl2/include/SDL_metal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_misc.h b/vs/sdl2/include/SDL_misc.h index 13ed9c7718..113ba7a156 100644 --- a/vs/sdl2/include/SDL_misc.h +++ b/vs/sdl2/include/SDL_misc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_mouse.h b/vs/sdl2/include/SDL_mouse.h index aa07575738..687ff122d2 100644 --- a/vs/sdl2/include/SDL_mouse.h +++ b/vs/sdl2/include/SDL_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_mutex.h b/vs/sdl2/include/SDL_mutex.h index e679d38089..eaa21f293f 100644 --- a/vs/sdl2/include/SDL_mutex.h +++ b/vs/sdl2/include/SDL_mutex.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_name.h b/vs/sdl2/include/SDL_name.h index 5c3e07ab7d..71e9354550 100644 --- a/vs/sdl2/include/SDL_name.h +++ b/vs/sdl2/include/SDL_name.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_opengl.h b/vs/sdl2/include/SDL_opengl.h index 0ba89127ac..2bb38c5c0e 100644 --- a/vs/sdl2/include/SDL_opengl.h +++ b/vs/sdl2/include/SDL_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_opengles.h b/vs/sdl2/include/SDL_opengles.h index f4465eaa9d..7e9a1ab8d4 100644 --- a/vs/sdl2/include/SDL_opengles.h +++ b/vs/sdl2/include/SDL_opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_opengles2.h b/vs/sdl2/include/SDL_opengles2.h index 5e3b717def..96971344d1 100644 --- a/vs/sdl2/include/SDL_opengles2.h +++ b/vs/sdl2/include/SDL_opengles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_pixels.h b/vs/sdl2/include/SDL_pixels.h index 9abd57b420..44757cdcf4 100644 --- a/vs/sdl2/include/SDL_pixels.h +++ b/vs/sdl2/include/SDL_pixels.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -61,7 +61,10 @@ typedef enum SDL_PIXELTYPE_ARRAYU16, SDL_PIXELTYPE_ARRAYU32, SDL_PIXELTYPE_ARRAYF16, - SDL_PIXELTYPE_ARRAYF32 + SDL_PIXELTYPE_ARRAYF32, + + /* This must be at the end of the list to avoid breaking the existing ABI */ + SDL_PIXELTYPE_INDEX2 } SDL_PixelType; /** Bitmap pixel order, high bit -> low bit. */ @@ -134,6 +137,7 @@ typedef enum #define SDL_ISPIXELFORMAT_INDEXED(format) \ (!SDL_ISPIXELFORMAT_FOURCC(format) && \ ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX2) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) @@ -177,6 +181,12 @@ typedef enum SDL_PIXELFORMAT_INDEX1MSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, 1, 0), + SDL_PIXELFORMAT_INDEX2LSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_4321, 0, + 2, 0), + SDL_PIXELFORMAT_INDEX2MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX2, SDL_BITMAPORDER_1234, 0, + 2, 0), SDL_PIXELFORMAT_INDEX4LSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), @@ -276,11 +286,19 @@ typedef enum SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_RGBX8888, + SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_XRGB8888, + SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_BGRX8888, + SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_XBGR8888, #else SDL_PIXELFORMAT_RGBA32 = SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB32 = SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGRA32 = SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR32 = SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_RGBX32 = SDL_PIXELFORMAT_XBGR8888, + SDL_PIXELFORMAT_XRGB32 = SDL_PIXELFORMAT_BGRX8888, + SDL_PIXELFORMAT_BGRX32 = SDL_PIXELFORMAT_XRGB8888, + SDL_PIXELFORMAT_XBGR32 = SDL_PIXELFORMAT_RGBX8888, #endif SDL_PIXELFORMAT_YV12 = /**< Planar mode: Y + V + U (3 planes) */ diff --git a/vs/sdl2/include/SDL_platform.h b/vs/sdl2/include/SDL_platform.h index d2a7e052d7..2b11bf2016 100644 --- a/vs/sdl2/include/SDL_platform.h +++ b/vs/sdl2/include/SDL_platform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 @@ #if defined(__APPLE__) /* lets us know what version of Mac OS X we're compiling on */ #include +#ifndef __has_extension /* Older compilers don't support this */ +#define __has_extension(x) 0 #include +#undef __has_extension +#else +#include +#endif /* Fix building with older SDKs that don't define these See this for more information: @@ -166,6 +172,12 @@ #define WINAPI_FAMILY_WINRT 0 #endif /* HAVE_WINAPIFAMILY_H */ +#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 WINAPI_FAMILY_WINRT #undef __WINRT__ #define __WINRT__ 1 @@ -193,8 +205,10 @@ #undef __GDK__ #define __GDK__ 1 #endif -#if defined(__PSP__) +#if defined(__PSP__) || defined(__psp__) +#ifdef __PSP__ #undef __PSP__ +#endif #define __PSP__ 1 #endif #if defined(PS2) diff --git a/vs/sdl2/include/SDL_power.h b/vs/sdl2/include/SDL_power.h index 1d75704c42..0520065ceb 100644 --- a/vs/sdl2/include/SDL_power.h +++ b/vs/sdl2/include/SDL_power.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_quit.h b/vs/sdl2/include/SDL_quit.h index d8ceb89436..3f69dc9f26 100644 --- a/vs/sdl2/include/SDL_quit.h +++ b/vs/sdl2/include/SDL_quit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_rect.h b/vs/sdl2/include/SDL_rect.h index 9611a311ce..5ce1f0b451 100644 --- a/vs/sdl2/include/SDL_rect.h +++ b/vs/sdl2/include/SDL_rect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_render.h b/vs/sdl2/include/SDL_render.h index d62715a324..b7135bb9dd 100644 --- a/vs/sdl2/include/SDL_render.h +++ b/vs/sdl2/include/SDL_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,7 @@ * of the many good 3D engines. * * These functions must be called from the main thread. - * See this bug for details: http://bugzilla.libsdl.org/show_bug.cgi?id=1995 + * See this bug for details: https://github.com/libsdl-org/SDL/issues/986 */ #ifndef SDL_render_h_ @@ -1890,7 +1890,7 @@ extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give * SDL a drawable to render to, which might happen if the window is * hidden/minimized/offscreen. This doesn't apply to command encoders for - * render targets, just the window's backbacker. Check your return values! + * render targets, just the window's backbuffer. Check your return values! * * \param renderer The renderer to query * \returns an `id` on success, or NULL if the diff --git a/vs/sdl2/include/SDL_revision.h b/vs/sdl2/include/SDL_revision.h index 84d600346b..36691f5531 100644 --- a/vs/sdl2/include/SDL_revision.h +++ b/vs/sdl2/include/SDL_revision.h @@ -1,7 +1,6 @@ -/* Generated by updaterev.sh, do not edit */ #ifdef SDL_VENDOR_INFO -#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b (" SDL_VENDOR_INFO ")" +#define SDL_REVISION SDL_VENDOR_INFO #else -#define SDL_REVISION "SDL-release-2.28.2-0-g031912c4b" +#define SDL_REVISION "" #endif #define SDL_REVISION_NUMBER 0 diff --git a/vs/sdl2/include/SDL_rwops.h b/vs/sdl2/include/SDL_rwops.h index 8615cb5429..9dd99f92b1 100644 --- a/vs/sdl2/include/SDL_rwops.h +++ b/vs/sdl2/include/SDL_rwops.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_scancode.h b/vs/sdl2/include/SDL_scancode.h index a960a7991c..fe13d5b7aa 100644 --- a/vs/sdl2/include/SDL_scancode.h +++ b/vs/sdl2/include/SDL_scancode.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_sensor.h b/vs/sdl2/include/SDL_sensor.h index 9ecce44b17..8b89ef6a52 100644 --- a/vs/sdl2/include/SDL_sensor.h +++ b/vs/sdl2/include/SDL_sensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_shape.h b/vs/sdl2/include/SDL_shape.h index f66babc011..4783cf290e 100644 --- a/vs/sdl2/include/SDL_shape.h +++ b/vs/sdl2/include/SDL_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_stdinc.h b/vs/sdl2/include/SDL_stdinc.h index 182ed86ee3..45e2a7830a 100644 --- a/vs/sdl2/include/SDL_stdinc.h +++ b/vs/sdl2/include/SDL_stdinc.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +107,7 @@ # elif defined(__MRC__) void *alloca(unsigned); # else -char *alloca(); +void *alloca(size_t); # endif #endif @@ -253,44 +253,44 @@ typedef uint64_t Uint64; * should define these but this is not true all platforms. * (for example win32) */ #ifndef SDL_PRIs64 -#ifdef PRIs64 -#define SDL_PRIs64 PRIs64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIs64 "I64d" -#elif defined(__LINUX__) && defined(__LP64__) +#elif defined(PRIs64) +#define SDL_PRIs64 PRIs64 +#elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIs64 "ld" #else #define SDL_PRIs64 "lld" #endif #endif #ifndef SDL_PRIu64 -#ifdef PRIu64 -#define SDL_PRIu64 PRIu64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIu64 "I64u" -#elif defined(__LINUX__) && defined(__LP64__) +#elif defined(PRIu64) +#define SDL_PRIu64 PRIu64 +#elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIu64 "lu" #else #define SDL_PRIu64 "llu" #endif #endif #ifndef SDL_PRIx64 -#ifdef PRIx64 -#define SDL_PRIx64 PRIx64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIx64 "I64x" -#elif defined(__LINUX__) && defined(__LP64__) +#elif defined(PRIx64) +#define SDL_PRIx64 PRIx64 +#elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIx64 "lx" #else #define SDL_PRIx64 "llx" #endif #endif #ifndef SDL_PRIX64 -#ifdef PRIX64 -#define SDL_PRIX64 PRIX64 -#elif defined(__WIN32__) || defined(__GDK__) +#if defined(__WIN32__) || defined(__GDK__) #define SDL_PRIX64 "I64X" -#elif defined(__LINUX__) && defined(__LP64__) +#elif defined(PRIX64) +#define SDL_PRIX64 PRIX64 +#elif defined(__LP64__) && !defined(__APPLE__) #define SDL_PRIX64 "lX" #else #define SDL_PRIX64 "llX" @@ -336,7 +336,9 @@ typedef uint64_t Uint64; #define SDL_PRINTF_FORMAT_STRING #define SDL_SCANF_FORMAT_STRING #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) #else #if defined(_MSC_VER) && (_MSC_VER >= 1600) /* VS 2010 and above */ #include @@ -362,10 +364,14 @@ typedef uint64_t Uint64; #endif #if defined(__GNUC__) #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __printf__, fmtargnumber, 0 ))) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 ))) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) __attribute__(( format( __scanf__, fmtargnumber, 0 ))) #else #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) +#define SDL_PRINTF_VARARG_FUNCV( fmtargnumber ) #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) +#define SDL_SCANF_VARARG_FUNCV( fmtargnumber ) #endif #endif /* SDL_DISABLE_ANALYZE_MACROS */ @@ -603,11 +609,11 @@ extern DECLSPEC int SDLCALL SDL_strcasecmp(const char *str1, const char *str2); extern DECLSPEC int SDLCALL SDL_strncasecmp(const char *str1, const char *str2, size_t len); extern DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2); -extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_vsscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap) SDL_SCANF_VARARG_FUNCV(2); extern DECLSPEC int SDLCALL SDL_snprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, ... ) SDL_PRINTF_VARARG_FUNC(3); -extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(3); extern DECLSPEC int SDLCALL SDL_asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(2); -extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, const char *fmt, va_list ap); +extern DECLSPEC int SDLCALL SDL_vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap) SDL_PRINTF_VARARG_FUNCV(2); #ifndef HAVE_M_PI #ifndef M_PI @@ -688,8 +694,8 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf, size_t * outbytesleft); /** - * This function converts a buffer or string between encodings in one pass, returning a - * string that must be freed with SDL_free() or NULL on error. + * This function converts a buffer or string between encodings in one pass, + * returning a string that must be freed with SDL_free() or NULL on error. * * \since This function is available since SDL 2.0.0. */ @@ -698,8 +704,8 @@ extern DECLSPEC char *SDLCALL SDL_iconv_string(const char *tocode, const char *inbuf, size_t inbytesleft); #define SDL_iconv_utf8_locale(S) SDL_iconv_string("", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) -#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4-INTERNAL", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs2(S) (Uint16 *)SDL_iconv_string("UCS-2", "UTF-8", S, SDL_strlen(S)+1) +#define SDL_iconv_utf8_ucs4(S) (Uint32 *)SDL_iconv_string("UCS-4", "UTF-8", S, SDL_strlen(S)+1) #define SDL_iconv_wchar_utf8(S) SDL_iconv_string("UTF-8", "WCHAR_T", (char *)S, (SDL_wcslen(S)+1)*sizeof(wchar_t)) /* force builds using Clang's static analysis tools to use literal C runtime diff --git a/vs/sdl2/include/SDL_surface.h b/vs/sdl2/include/SDL_surface.h index d6ee615c59..ceeb86bd86 100644 --- a/vs/sdl2/include/SDL_surface.h +++ b/vs/sdl2/include/SDL_surface.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_system.h b/vs/sdl2/include/SDL_system.h index 4b7eaddcc0..ddae4f8cc1 100644 --- a/vs/sdl2/include/SDL_system.h +++ b/vs/sdl2/include/SDL_system.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -593,7 +593,8 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void /* Functions used only by GDK */ #if defined(__GDK__) -typedef struct XTaskQueueObject * XTaskQueueHandle; +typedef struct XTaskQueueObject *XTaskQueueHandle; +typedef struct XUser *XUserHandle; /** * Gets a reference to the global async task queue handle for GDK, @@ -610,6 +611,20 @@ typedef struct XTaskQueueObject * XTaskQueueHandle; */ extern DECLSPEC int SDLCALL SDL_GDKGetTaskQueue(XTaskQueueHandle * outTaskQueue); +/** + * Gets a reference to the default user handle for GDK. + * + * This is effectively a synchronous version of XUserAddAsync, which always + * prefers the default user and allows a sign-in UI. + * + * \param outUserHandle a pointer to be filled in with the default user + * handle. + * \returns 0 if success, -1 if any error occurs. + * + * \since This function is available since SDL 2.28.0. + */ +extern DECLSPEC int SDLCALL SDL_GDKGetDefaultUser(XUserHandle * outUserHandle); + #endif /* Ends C function definitions when using C++ */ diff --git a/vs/sdl2/include/SDL_syswm.h b/vs/sdl2/include/SDL_syswm.h index b35734deb3..7b8bd6ef99 100644 --- a/vs/sdl2/include/SDL_syswm.h +++ b/vs/sdl2/include/SDL_syswm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test.h b/vs/sdl2/include/SDL_test.h index 80daaafbd9..e5acbee4e3 100644 --- a/vs/sdl2/include/SDL_test.h +++ b/vs/sdl2/include/SDL_test.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_assert.h b/vs/sdl2/include/SDL_test_assert.h index 341e490fac..4f983350a3 100644 --- a/vs/sdl2/include/SDL_test_assert.h +++ b/vs/sdl2/include/SDL_test_assert.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_common.h b/vs/sdl2/include/SDL_test_common.h index 6de63cad6f..d977e463f1 100644 --- a/vs/sdl2/include/SDL_test_common.h +++ b/vs/sdl2/include/SDL_test_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_compare.h b/vs/sdl2/include/SDL_test_compare.h index 5fce25ca18..61a38d0905 100644 --- a/vs/sdl2/include/SDL_test_compare.h +++ b/vs/sdl2/include/SDL_test_compare.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_crc32.h b/vs/sdl2/include/SDL_test_crc32.h index bf34782103..e3478318dc 100644 --- a/vs/sdl2/include/SDL_test_crc32.h +++ b/vs/sdl2/include/SDL_test_crc32.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_font.h b/vs/sdl2/include/SDL_test_font.h index 18a82ffc80..620c82116b 100644 --- a/vs/sdl2/include/SDL_test_font.h +++ b/vs/sdl2/include/SDL_test_font.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_fuzzer.h b/vs/sdl2/include/SDL_test_fuzzer.h index cfe6a14f2a..a847ccb01c 100644 --- a/vs/sdl2/include/SDL_test_fuzzer.h +++ b/vs/sdl2/include/SDL_test_fuzzer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_harness.h b/vs/sdl2/include/SDL_test_harness.h index 26231dcd6b..bd9e4f8de0 100644 --- a/vs/sdl2/include/SDL_test_harness.h +++ b/vs/sdl2/include/SDL_test_harness.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_images.h b/vs/sdl2/include/SDL_test_images.h index 1211371755..b5bcb0a000 100644 --- a/vs/sdl2/include/SDL_test_images.h +++ b/vs/sdl2/include/SDL_test_images.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_log.h b/vs/sdl2/include/SDL_test_log.h index a27ffc209a..ea9ae5e1ca 100644 --- a/vs/sdl2/include/SDL_test_log.h +++ b/vs/sdl2/include/SDL_test_log.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_md5.h b/vs/sdl2/include/SDL_test_md5.h index 538c7ae3e0..3764b04256 100644 --- a/vs/sdl2/include/SDL_test_md5.h +++ b/vs/sdl2/include/SDL_test_md5.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_memory.h b/vs/sdl2/include/SDL_test_memory.h index f959177d23..9bd143252c 100644 --- a/vs/sdl2/include/SDL_test_memory.h +++ b/vs/sdl2/include/SDL_test_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_test_random.h b/vs/sdl2/include/SDL_test_random.h index 0035a8030a..344646aa8b 100644 --- a/vs/sdl2/include/SDL_test_random.h +++ b/vs/sdl2/include/SDL_test_random.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_thread.h b/vs/sdl2/include/SDL_thread.h index b829bbad5d..dc7f5363aa 100644 --- a/vs/sdl2/include/SDL_thread.h +++ b/vs/sdl2/include/SDL_thread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_timer.h b/vs/sdl2/include/SDL_timer.h index 98f9ad16c6..8123e432f1 100644 --- a/vs/sdl2/include/SDL_timer.h +++ b/vs/sdl2/include/SDL_timer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_touch.h b/vs/sdl2/include/SDL_touch.h index c12d4a1c81..f6a5db413d 100644 --- a/vs/sdl2/include/SDL_touch.h +++ b/vs/sdl2/include/SDL_touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_types.h b/vs/sdl2/include/SDL_types.h index b5d7192ff2..e8d33c6513 100644 --- a/vs/sdl2/include/SDL_types.h +++ b/vs/sdl2/include/SDL_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/include/SDL_version.h b/vs/sdl2/include/SDL_version.h index a3cf40b262..d05fed77c2 100644 --- a/vs/sdl2/include/SDL_version.h +++ b/vs/sdl2/include/SDL_version.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +36,6 @@ extern "C" { #endif -/* This is the DOSBox-X's modified SDL 2.x with IME support, not the general library */ -#define SDL_DOSBOX_X_IME 1 - /** * Information about the version of SDL in use. * @@ -61,8 +58,8 @@ typedef struct SDL_version /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL */ #define SDL_MAJOR_VERSION 2 -#define SDL_MINOR_VERSION 28 -#define SDL_PATCHLEVEL 2 +#define SDL_MINOR_VERSION 30 +#define SDL_PATCHLEVEL 4 /** * Macro to determine SDL version program was compiled against. diff --git a/vs/sdl2/include/SDL_video.h b/vs/sdl2/include/SDL_video.h index c8b2d7a0d8..fa47d30991 100644 --- a/vs/sdl2/include/SDL_video.h +++ b/vs/sdl2/include/SDL_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1278,7 +1278,8 @@ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, /** * Return whether the window has a surface associated with it. * - * \returns SDL_TRUE if there is a surface associated with the window, or SDL_FALSE otherwise. + * \returns SDL_TRUE if there is a surface associated with the window, or + * SDL_FALSE otherwise. * * \since This function is available since SDL 2.28.0. * @@ -1340,6 +1341,11 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); * * This function is equivalent to the SDL 1.2 API SDL_UpdateRects(). * + * Note that this function will update _at least_ the rectangles specified, + * but this is only intended as an optimization; in practice, this might + * update more of the screen (or all of the screen!), depending on what + * method SDL uses to send pixels to the system. + * * \param window the window to update * \param rects an array of SDL_Rect structures representing areas of the * surface to copy, in pixels diff --git a/vs/sdl2/include/begin_code.h b/vs/sdl2/include/begin_code.h index 4142ffeba9..a47a7d2b64 100644 --- a/vs/sdl2/include/begin_code.h +++ b/vs/sdl2/include/begin_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 @@ #ifndef SDL_DEPRECATED # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ # define SDL_DEPRECATED __attribute__((deprecated)) +# elif defined(_MSC_VER) +# define SDL_DEPRECATED __declspec(deprecated) # else # define SDL_DEPRECATED # endif diff --git a/vs/sdl2/include/close_code.h b/vs/sdl2/include/close_code.h index b5ff3e2049..50a0e6f3b4 100644 --- a/vs/sdl2/include/close_code.h +++ b/vs/sdl2/include/close_code.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/sdl2.m4 b/vs/sdl2/sdl2.m4 index 75b60f6ea9..274753b118 100644 --- a/vs/sdl2/sdl2.m4 +++ b/vs/sdl2/sdl2.m4 @@ -9,8 +9,9 @@ # * also look for SDL2.framework under Mac OS X # * removed HP/UX 9 support. # * updated for newer autoconf. +# * (v3) use $PKG_CONFIG for pkg-config cross-compiling support -# serial 2 +# serial 3 dnl AM_PATH_SDL2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS @@ -54,7 +55,7 @@ AC_ARG_VAR(SDL2_FRAMEWORK, [Path to SDL2.framework]) if test "x$sdl_pc" = xyes ; then no_sdl="" - SDL2_CONFIG="pkg-config sdl2" + SDL2_CONFIG="$PKG_CONFIG sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then diff --git a/vs/sdl2/src/SDL.c b/vs/sdl2/src/SDL.c index 56049adf0b..7065fe7116 100644 --- a/vs/sdl2/src/SDL.c +++ b/vs/sdl2/src/SDL.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #endif #if defined(__OS2__) #include "core/os2/SDL_os2.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 #include "thread/os2/SDL_systls_c.h" #endif #endif @@ -54,10 +54,10 @@ #include "sensor/SDL_sensor_c.h" /* Initialization/Cleanup routines */ -#if !SDL_TIMERS_DISABLED +#ifndef SDL_TIMERS_DISABLED #include "timer/SDL_timer_c.h" #endif -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS extern int SDL_HelperWindowCreate(void); extern int SDL_HelperWindowDestroy(void); #endif @@ -160,6 +160,22 @@ static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE; } +/* Private helper to either increment's existing ref counter, + * or fully init a new subsystem. */ +static SDL_bool SDL_PrivateInitOrIncrSubsystem(Uint32 subsystem) +{ + int subsystem_index = SDL_MostSignificantBitIndex32(subsystem); + SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255)); + if (subsystem_index < 0) { + return SDL_FALSE; + } + if (SDL_SubsystemRefCount[subsystem_index] > 0) { + ++SDL_SubsystemRefCount[subsystem_index]; + return SDL_TRUE; + } + return SDL_InitSubSystem(subsystem) == 0; +} + void SDL_SetMainReady(void) { SDL_MainIsReady = SDL_TRUE; @@ -178,25 +194,15 @@ int SDL_InitSubSystem(Uint32 flags) /* Clear the error message */ SDL_ClearError(); -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS SDL_DBus_Init(); #endif - if (flags & SDL_INIT_GAMECONTROLLER) { - /* game controller implies joystick */ - flags |= SDL_INIT_JOYSTICK; - } - - if (flags & (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO)) { - /* video or joystick or audio implies events */ - flags |= SDL_INIT_EVENTS; - } - -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 SDL_OS2TLSAlloc(); /* thread/os2/SDL_systls.c */ #endif -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) { if (SDL_HelperWindowCreate() < 0) { goto quit_and_error; @@ -204,13 +210,13 @@ int SDL_InitSubSystem(Uint32 flags) } #endif -#if !SDL_TIMERS_DISABLED +#ifndef SDL_TIMERS_DISABLED SDL_TicksInit(); #endif /* Initialize the event subsystem */ if (flags & SDL_INIT_EVENTS) { -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) { if (SDL_EventsInit() < 0) { goto quit_and_error; @@ -226,7 +232,7 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the timer subsystem */ if (flags & SDL_INIT_TIMER) { -#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY +#if !defined(SDL_TIMERS_DISABLED) && !defined(SDL_TIMER_DUMMY) if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) { if (SDL_TimerInit() < 0) { goto quit_and_error; @@ -242,8 +248,13 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the video subsystem */ if (flags & SDL_INIT_VIDEO) { -#if !SDL_VIDEO_DISABLED +#ifndef SDL_VIDEO_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) { + /* video implies events */ + if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) { + goto quit_and_error; + } + if (SDL_VideoInit(NULL) < 0) { goto quit_and_error; } @@ -258,8 +269,13 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the audio subsystem */ if (flags & SDL_INIT_AUDIO) { -#if !SDL_AUDIO_DISABLED +#ifndef SDL_AUDIO_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) { + /* audio implies events */ + if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) { + goto quit_and_error; + } + if (SDL_AudioInit(NULL) < 0) { goto quit_and_error; } @@ -274,8 +290,13 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the joystick subsystem */ if (flags & SDL_INIT_JOYSTICK) { -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) { + /* joystick implies events */ + if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_EVENTS)) { + goto quit_and_error; + } + if (SDL_JoystickInit() < 0) { goto quit_and_error; } @@ -289,8 +310,13 @@ int SDL_InitSubSystem(Uint32 flags) } if (flags & SDL_INIT_GAMECONTROLLER) { -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) { + /* game controller implies joystick */ + if (!SDL_PrivateInitOrIncrSubsystem(SDL_INIT_JOYSTICK)) { + goto quit_and_error; + } + if (SDL_GameControllerInit() < 0) { goto quit_and_error; } @@ -305,7 +331,7 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the haptic subsystem */ if (flags & SDL_INIT_HAPTIC) { -#if !SDL_HAPTIC_DISABLED +#ifndef SDL_HAPTIC_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) { if (SDL_HapticInit() < 0) { goto quit_and_error; @@ -321,7 +347,7 @@ int SDL_InitSubSystem(Uint32 flags) /* Initialize the sensor subsystem */ if (flags & SDL_INIT_SENSOR) { -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) { if (SDL_SensorInit() < 0) { goto quit_and_error; @@ -352,14 +378,14 @@ int SDL_Init(Uint32 flags) void SDL_QuitSubSystem(Uint32 flags) { #if defined(__OS2__) -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 SDL_OS2TLSFree(); /* thread/os2/SDL_systls.c */ #endif SDL_OS2Quit(); #endif /* Shut down requested initialized subsystems */ -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED if (flags & SDL_INIT_SENSOR) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) { SDL_SensorQuit(); @@ -368,29 +394,27 @@ void SDL_QuitSubSystem(Uint32 flags) } #endif -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED if (flags & SDL_INIT_GAMECONTROLLER) { - /* game controller implies joystick */ - flags |= SDL_INIT_JOYSTICK; - if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_GAMECONTROLLER)) { SDL_GameControllerQuit(); + /* game controller implies joystick */ + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER); } if (flags & SDL_INIT_JOYSTICK) { - /* joystick implies events */ - flags |= SDL_INIT_EVENTS; - if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_JOYSTICK)) { SDL_JoystickQuit(); + /* joystick implies events */ + SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_JOYSTICK); } #endif -#if !SDL_HAPTIC_DISABLED +#ifndef SDL_HAPTIC_DISABLED if (flags & SDL_INIT_HAPTIC) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) { SDL_HapticQuit(); @@ -399,31 +423,29 @@ void SDL_QuitSubSystem(Uint32 flags) } #endif -#if !SDL_AUDIO_DISABLED +#ifndef SDL_AUDIO_DISABLED if (flags & SDL_INIT_AUDIO) { - /* audio implies events */ - flags |= SDL_INIT_EVENTS; - if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_AUDIO)) { SDL_AudioQuit(); + /* audio implies events */ + SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_AUDIO); } #endif -#if !SDL_VIDEO_DISABLED +#ifndef SDL_VIDEO_DISABLED if (flags & SDL_INIT_VIDEO) { - /* video implies events */ - flags |= SDL_INIT_EVENTS; - if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_VIDEO)) { SDL_VideoQuit(); + /* video implies events */ + SDL_QuitSubSystem(SDL_INIT_EVENTS); } SDL_PrivateSubsystemRefCountDecr(SDL_INIT_VIDEO); } #endif -#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY +#if !defined(SDL_TIMERS_DISABLED) && !defined(SDL_TIMER_DUMMY) if (flags & SDL_INIT_TIMER) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) { SDL_TimerQuit(); @@ -432,7 +454,7 @@ void SDL_QuitSubSystem(Uint32 flags) } #endif -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (flags & SDL_INIT_EVENTS) { if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) { SDL_EventsQuit(); @@ -477,22 +499,22 @@ void SDL_Quit(void) SDL_bInMainQuit = SDL_TRUE; /* Quit all subsystems */ -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS SDL_HelperWindowDestroy(); #endif SDL_QuitSubSystem(SDL_INIT_EVERYTHING); -#if !SDL_TIMERS_DISABLED +#ifndef SDL_TIMERS_DISABLED SDL_TicksQuit(); #endif - SDL_ClearHints(); - SDL_AssertionsQuit(); - -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS SDL_DBus_Quit(); #endif + SDL_ClearHints(); + SDL_AssertionsQuit(); + SDL_LogQuit(); /* Now that every subsystem has been quit, we reset the subsystem refcount @@ -511,7 +533,7 @@ void SDL_GetVersion(SDL_version *ver) static SDL_bool check_hint = SDL_TRUE; static SDL_bool legacy_version = SDL_FALSE; - if (ver == NULL) { + if (!ver) { return; } @@ -544,71 +566,71 @@ int SDL_GetRevisionNumber(void) /* Get the name of the platform */ const char *SDL_GetPlatform(void) { -#if __AIX__ +#if defined(__AIX__) return "AIX"; -#elif __ANDROID__ +#elif defined(__ANDROID__) return "Android"; -#elif __BSDI__ +#elif defined(__BSDI__) return "BSDI"; -#elif __DREAMCAST__ +#elif defined(__DREAMCAST__) return "Dreamcast"; -#elif __EMSCRIPTEN__ +#elif defined(__EMSCRIPTEN__) return "Emscripten"; -#elif __FREEBSD__ +#elif defined(__FREEBSD__) return "FreeBSD"; -#elif __HAIKU__ +#elif defined(__HAIKU__) return "Haiku"; -#elif __HPUX__ +#elif defined(__HPUX__) return "HP-UX"; -#elif __IRIX__ +#elif defined(__IRIX__) return "Irix"; -#elif __LINUX__ +#elif defined(__LINUX__) return "Linux"; -#elif __MINT__ +#elif defined(__MINT__) return "Atari MiNT"; -#elif __MACOS__ +#elif defined(__MACOS__) return "MacOS Classic"; -#elif __MACOSX__ +#elif defined(__MACOSX__) return "Mac OS X"; -#elif __NACL__ +#elif defined(__NACL__) return "NaCl"; -#elif __NETBSD__ +#elif defined(__NETBSD__) return "NetBSD"; -#elif __OPENBSD__ +#elif defined(__OPENBSD__) return "OpenBSD"; -#elif __OS2__ +#elif defined(__OS2__) return "OS/2"; -#elif __OSF__ +#elif defined(__OSF__) return "OSF/1"; -#elif __QNXNTO__ +#elif defined(__QNXNTO__) return "QNX Neutrino"; -#elif __RISCOS__ +#elif defined(__RISCOS__) return "RISC OS"; -#elif __SOLARIS__ +#elif defined(__SOLARIS__) return "Solaris"; -#elif __WIN32__ +#elif defined(__WIN32__) return "Windows"; -#elif __WINRT__ +#elif defined(__WINRT__) return "WinRT"; -#elif __WINGDK__ +#elif defined(__WINGDK__) return "WinGDK"; -#elif __XBOXONE__ +#elif defined(__XBOXONE__) return "Xbox One"; -#elif __XBOXSERIES__ +#elif defined(__XBOXSERIES__) return "Xbox Series X|S"; -#elif __TVOS__ +#elif defined(__TVOS__) return "tvOS"; -#elif __IPHONEOS__ +#elif defined(__IPHONEOS__) return "iOS"; -#elif __PS2__ +#elif defined(__PS2__) return "PlayStation 2"; -#elif __PSP__ +#elif defined(__PSP__) return "PlayStation Portable"; -#elif __VITA__ +#elif defined(__VITA__) return "PlayStation Vita"; -#elif __NGAGE__ +#elif defined(__NGAGE__) return "Nokia N-Gage"; -#elif __3DS__ +#elif defined(__3DS__) return "Nintendo 3DS"; #else return "Unknown (see SDL_platform.h)"; @@ -617,10 +639,10 @@ const char *SDL_GetPlatform(void) SDL_bool SDL_IsTablet(void) { -#if __ANDROID__ +#if defined(__ANDROID__) extern SDL_bool SDL_IsAndroidTablet(void); return SDL_IsAndroidTablet(); -#elif __IPHONEOS__ +#elif defined(__IPHONEOS__) extern SDL_bool SDL_IsIPad(void); return SDL_IsIPad(); #else diff --git a/vs/sdl2/src/SDL_assert.c b/vs/sdl2/src/SDL_assert.c index dc5a220ab1..1ca41e76f3 100644 --- a/vs/sdl2/src/SDL_assert.c +++ b/vs/sdl2/src/SDL_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,15 @@ #endif #if defined(__EMSCRIPTEN__) -#include + #include + /* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ + #ifndef MAIN_THREAD_EM_ASM_PTR + #ifdef __wasm64__ + #error You need to upgrade your Emscripten compiler to support wasm64 + #else + #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT + #endif + #endif #endif /* The size of the stack buffer to use for rendering assert messages. */ @@ -106,11 +114,11 @@ static void SDL_GenerateAssertionReport(void) const SDL_assert_data *item = triggered_assertions; /* only do this if the app hasn't assigned an assertion handler. */ - if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) { + if ((item) && (assertion_handler != SDL_PromptAssertion)) { debug_print("\n\nSDL assertion report.\n"); debug_print("All SDL assertions between last init/quit:\n\n"); - while (item != NULL) { + while (item) { debug_print( "'%s'\n" " * %s (%s:%d)\n" @@ -198,7 +206,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, /* let env. variable override, so unit tests won't block in a GUI. */ envr = SDL_getenv("SDL_ASSERT"); - if (envr != NULL) { + if (envr) { if (message != stack_buf) { SDL_free(message); } @@ -251,7 +259,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, for (;;) { SDL_bool okay = SDL_TRUE; /* *INDENT-OFF* */ /* clang-format off */ - char *buf = (char *) EM_ASM_INT({ + char *buf = (char *) MAIN_THREAD_EM_ASM_PTR({ var str = UTF8ToString($0) + '\n\n' + 'Abort/Retry/Ignore/AlwaysIgnore? [ariA] :'; @@ -334,9 +342,9 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co #ifndef SDL_THREADS_DISABLED static SDL_SpinLock spinlock = 0; SDL_AtomicLock(&spinlock); - if (assertion_mutex == NULL) { /* never called SDL_Init()? */ + if (!assertion_mutex) { /* never called SDL_Init()? */ assertion_mutex = SDL_CreateMutex(); - if (assertion_mutex == NULL) { + if (!assertion_mutex) { SDL_AtomicUnlock(&spinlock); return SDL_ASSERTION_IGNORE; /* oh well, I guess. */ } @@ -401,7 +409,7 @@ void SDL_AssertionsQuit(void) #if SDL_ASSERT_LEVEL > 0 SDL_GenerateAssertionReport(); #ifndef SDL_THREADS_DISABLED - if (assertion_mutex != NULL) { + if (assertion_mutex) { SDL_DestroyMutex(assertion_mutex); assertion_mutex = NULL; } @@ -429,7 +437,7 @@ void SDL_ResetAssertionReport(void) { SDL_assert_data *next = NULL; SDL_assert_data *item; - for (item = triggered_assertions; item != NULL; item = next) { + for (item = triggered_assertions; item; item = next) { next = (SDL_assert_data *)item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; @@ -446,7 +454,7 @@ SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void) SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata) { - if (userdata != NULL) { + if (userdata) { *userdata = assertion_userdata; } return assertion_handler; diff --git a/vs/sdl2/src/SDL_assert_c.h b/vs/sdl2/src/SDL_assert_c.h index 246a946e5a..330acb87c9 100644 --- a/vs/sdl2/src/SDL_assert_c.h +++ b/vs/sdl2/src/SDL_assert_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_dataqueue.c b/vs/sdl2/src/SDL_dataqueue.c index 2019c3083c..e32ba3199b 100644 --- a/vs/sdl2/src/SDL_dataqueue.c +++ b/vs/sdl2/src/SDL_dataqueue.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +54,7 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla { SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue)); - if (queue == NULL) { + if (!queue) { SDL_OutOfMemory(); } else { const size_t packetlen = _packetlen ? _packetlen : 1024; @@ -101,7 +101,7 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) SDL_DataQueuePacket *prev = NULL; size_t i; - if (queue == NULL) { + if (!queue) { return; } @@ -147,13 +147,13 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) SDL_assert(queue != NULL); packet = queue->pool; - if (packet != NULL) { + if (packet) { /* we have one available in the pool. */ queue->pool = packet->next; } else { /* Have to allocate a new one! */ packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size); - if (packet == NULL) { + if (!packet) { return NULL; } } @@ -163,7 +163,7 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) packet->next = NULL; SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); - if (queue->tail == NULL) { + if (!queue->tail) { queue->head = packet; } else { queue->tail->next = packet; @@ -182,7 +182,7 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ size_t origlen; size_t datalen; - if (queue == NULL) { + if (!queue) { return SDL_InvalidParamError("queue"); } @@ -195,12 +195,12 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ while (len > 0) { SDL_DataQueuePacket *packet = queue->tail; SDL_assert(packet == NULL || (packet->datalen <= packet_size)); - if (packet == NULL || (packet->datalen >= packet_size)) { + if (!packet || (packet->datalen >= packet_size)) { /* tail packet missing or completely full; we need a new packet. */ packet = AllocateDataQueuePacket(queue); - if (packet == NULL) { + if (!packet) { /* uhoh, reset so we've queued nothing new, free what we can. */ - if (origtail == NULL) { + if (!origtail) { packet = queue->head; /* whole queue. */ } else { packet = origtail->next; /* what we added to existing queue. */ @@ -238,7 +238,7 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -267,7 +267,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -294,7 +294,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); - if (queue->head == NULL) { + if (!queue->head) { queue->tail = NULL; /* in case we drained the queue entirely. */ } diff --git a/vs/sdl2/src/SDL_dataqueue.h b/vs/sdl2/src/SDL_dataqueue.h index aee2cda622..972a521382 100644 --- a/vs/sdl2/src/SDL_dataqueue.h +++ b/vs/sdl2/src/SDL_dataqueue.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_error.c b/vs/sdl2/src/SDL_error.c index 501d395845..d5c45fb6c4 100644 --- a/vs/sdl2/src/SDL_error.c +++ b/vs/sdl2/src/SDL_error.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) { /* Ignore call if invalid format pointer was passed */ - if (fmt != NULL) { + if (fmt) { va_list ap; int result; SDL_error *error = SDL_GetErrBuf(); diff --git a/vs/sdl2/src/SDL_error_c.h b/vs/sdl2/src/SDL_error_c.h index be6f8ac8ee..1aae3be718 100644 --- a/vs/sdl2/src/SDL_error_c.h +++ b/vs/sdl2/src/SDL_error_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_guid.c b/vs/sdl2/src/SDL_guid.c index f8c4c60080..2f91edb185 100644 --- a/vs/sdl2/src/SDL_guid.c +++ b/vs/sdl2/src/SDL_guid.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) static const char k_rgchHexToASCII[] = "0123456789abcdef"; int i; - if ((pszGUID == NULL) || (cbGUID <= 0)) { + if ((!pszGUID) || (cbGUID <= 0)) { return; } diff --git a/vs/sdl2/src/SDL_hints.c b/vs/sdl2/src/SDL_hints.c index ceec0d5fb2..2455cc13a1 100644 --- a/vs/sdl2/src/SDL_hints.c +++ b/vs/sdl2/src/SDL_hints.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +51,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr SDL_Hint *hint; SDL_HintWatch *entry; - if (name == NULL) { + if (!name) { return SDL_FALSE; } @@ -66,7 +66,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr return SDL_FALSE; } if (hint->value != value && - (value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) { + (!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -83,7 +83,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr /* Couldn't find the hint, add a new one */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); - if (hint == NULL) { + if (!hint) { return SDL_FALSE; } hint->name = SDL_strdup(name); @@ -101,16 +101,16 @@ SDL_bool SDL_ResetHint(const char *name) SDL_Hint *hint; SDL_HintWatch *entry; - if (name == NULL) { + if (!name) { return SDL_FALSE; } env = SDL_getenv(name); for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { - if ((env == NULL && hint->value != NULL) || - (env != NULL && hint->value == NULL) || - (env != NULL && SDL_strcmp(env, hint->value) != 0)) { + if ((!env && hint->value) || + (env && !hint->value) || + (env && SDL_strcmp(env, hint->value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -135,9 +135,9 @@ void SDL_ResetHints(void) for (hint = SDL_hints; hint; hint = hint->next) { env = SDL_getenv(hint->name); - if ((env == NULL && hint->value != NULL) || - (env != NULL && hint->value == NULL) || - (env != NULL && SDL_strcmp(env, hint->value) != 0)) { + if ((!env && hint->value) || + (env && !hint->value) || + (env && SDL_strcmp(env, hint->value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -161,10 +161,14 @@ const char *SDL_GetHint(const char *name) const char *env; SDL_Hint *hint; + if (!name) { + return NULL; + } + env = SDL_getenv(name); for (hint = SDL_hints; hint; hint = hint->next) { if (SDL_strcmp(name, hint->name) == 0) { - if (env == NULL || hint->priority == SDL_HINT_OVERRIDE) { + if (!env || hint->priority == SDL_HINT_OVERRIDE) { return hint->value; } break; @@ -175,7 +179,7 @@ const char *SDL_GetHint(const char *name) SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value) { - if (value == NULL || !*value) { + if (!value || !*value) { return default_value; } if (*value == '0' || SDL_strcasecmp(value, "false") == 0) { @@ -196,7 +200,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_HintWatch *entry; const char *value; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return; } @@ -208,7 +212,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_DelHintCallback(name, callback, userdata); entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return; } @@ -220,10 +224,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user break; } } - if (hint == NULL) { + if (!hint) { /* Need to add a hint entry for this watcher */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); - if (hint == NULL) { + if (!hint) { SDL_OutOfMemory(); SDL_free(entry); return; diff --git a/vs/sdl2/src/SDL_hints_c.h b/vs/sdl2/src/SDL_hints_c.h index a17968123d..8af9fc5388 100644 --- a/vs/sdl2/src/SDL_hints_c.h +++ b/vs/sdl2/src/SDL_hints_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_internal.h b/vs/sdl2/src/SDL_internal.h index 2514eeda8a..b193edef62 100644 --- a/vs/sdl2/src/SDL_internal.h +++ b/vs/sdl2/src/SDL_internal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -125,6 +125,86 @@ #define SDL_HAVE_YUV !SDL_LEAN_AND_MEAN #endif +#ifndef SDL_RENDER_DISABLED +/* define the not defined ones as 0 */ +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 0 +#endif +#ifndef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#endif +#ifndef SDL_VIDEO_RENDER_D3D12 +#define SDL_VIDEO_RENDER_D3D12 0 +#endif +#ifndef SDL_VIDEO_RENDER_METAL +#define SDL_VIDEO_RENDER_METAL 0 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 0 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES +#define SDL_VIDEO_RENDER_OGL_ES 0 +#endif +#ifndef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 0 +#endif +#ifndef SDL_VIDEO_RENDER_DIRECTFB +#define SDL_VIDEO_RENDER_DIRECTFB 0 +#endif +#ifndef SDL_VIDEO_RENDER_PS2 +#define SDL_VIDEO_RENDER_PS2 0 +#endif +#ifndef SDL_VIDEO_RENDER_PSP +#define SDL_VIDEO_RENDER_PSP 0 +#endif +#ifndef SDL_VIDEO_RENDER_VITA_GXM +#define SDL_VIDEO_RENDER_VITA_GXM 0 +#endif +#else /* define all as 0 */ +#undef SDL_VIDEO_RENDER_SW +#define SDL_VIDEO_RENDER_SW 0 +#undef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 0 +#undef SDL_VIDEO_RENDER_D3D11 +#define SDL_VIDEO_RENDER_D3D11 0 +#undef SDL_VIDEO_RENDER_D3D12 +#define SDL_VIDEO_RENDER_D3D12 0 +#undef SDL_VIDEO_RENDER_METAL +#define SDL_VIDEO_RENDER_METAL 0 +#undef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 0 +#undef SDL_VIDEO_RENDER_OGL_ES +#define SDL_VIDEO_RENDER_OGL_ES 0 +#undef SDL_VIDEO_RENDER_OGL_ES2 +#define SDL_VIDEO_RENDER_OGL_ES2 0 +#undef SDL_VIDEO_RENDER_DIRECTFB +#define SDL_VIDEO_RENDER_DIRECTFB 0 +#undef SDL_VIDEO_RENDER_PS2 +#define SDL_VIDEO_RENDER_PS2 0 +#undef SDL_VIDEO_RENDER_PSP +#define SDL_VIDEO_RENDER_PSP 0 +#undef SDL_VIDEO_RENDER_VITA_GXM +#define SDL_VIDEO_RENDER_VITA_GXM 0 +#endif /* SDL_RENDER_DISABLED */ + +#define SDL_HAS_RENDER_DRIVER \ + (SDL_VIDEO_RENDER_SW | \ + SDL_VIDEO_RENDER_D3D | \ + SDL_VIDEO_RENDER_D3D11 | \ + SDL_VIDEO_RENDER_D3D12 | \ + SDL_VIDEO_RENDER_METAL | \ + SDL_VIDEO_RENDER_OGL | \ + SDL_VIDEO_RENDER_OGL_ES | \ + SDL_VIDEO_RENDER_OGL_ES2 | \ + SDL_VIDEO_RENDER_DIRECTFB | \ + SDL_VIDEO_RENDER_PS2 | \ + SDL_VIDEO_RENDER_PSP | \ + SDL_VIDEO_RENDER_VITA_GXM) + +#if !defined(SDL_RENDER_DISABLED) && !SDL_HAS_RENDER_DRIVER +#error SDL_RENDER enabled without any backend drivers. +#endif + #include "SDL_assert.h" #include "SDL_log.h" diff --git a/vs/sdl2/src/SDL_list.c b/vs/sdl2/src/SDL_list.c index b08919642f..b7f45de44e 100644 --- a/vs/sdl2/src/SDL_list.c +++ b/vs/sdl2/src/SDL_list.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent) { SDL_ListNode *node = SDL_malloc(sizeof(*node)); - if (node == NULL) { + if (!node) { return SDL_OutOfMemory(); } @@ -44,7 +44,7 @@ void SDL_ListPop(SDL_ListNode **head, void **ent) SDL_ListNode **ptr = head; /* Invalid or empty */ - if (head == NULL || *head == NULL) { + if (!head || !*head) { return; } diff --git a/vs/sdl2/src/SDL_list.h b/vs/sdl2/src/SDL_list.h index f1ee7ffa64..f855e9bd71 100644 --- a/vs/sdl2/src/SDL_list.h +++ b/vs/sdl2/src/SDL_list.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_log.c b/vs/sdl2/src/SDL_log.c index ab6e7c2cbc..9e324e3ddb 100644 --- a/vs/sdl2/src/SDL_log.c +++ b/vs/sdl2/src/SDL_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 @@ #include "SDL_error.h" #include "SDL_log.h" +#include "SDL_hints.h" #include "SDL_mutex.h" #include "SDL_log_c.h" -#if HAVE_STDIO_H +#ifdef HAVE_STDIO_H #include #endif @@ -44,10 +45,7 @@ /* The size of the stack buffer to use for rendering log messages. */ #define SDL_MAX_LOG_MESSAGE_STACK 256 -#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_CRITICAL -#define DEFAULT_ASSERT_PRIORITY SDL_LOG_PRIORITY_WARN -#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO -#define DEFAULT_TEST_PRIORITY SDL_LOG_PRIORITY_VERBOSE +#define DEFAULT_CATEGORY -1 typedef struct SDL_LogLevel { @@ -60,15 +58,14 @@ typedef struct SDL_LogLevel static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message); static SDL_LogLevel *SDL_loglevels; -static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; -static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; -static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; -static SDL_LogPriority SDL_test_priority = DEFAULT_TEST_PRIORITY; +static SDL_bool SDL_forced_priority = SDL_FALSE; +static SDL_LogPriority SDL_forced_priority_level; static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; static void *SDL_log_userdata = NULL; static SDL_mutex *log_function_mutex = NULL; -static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { +/* If this list changes, update the documentation for SDL_HINT_LOGGING */ +static const char *SDL_priority_prefixes[] = { NULL, "VERBOSE", "DEBUG", @@ -77,8 +74,9 @@ static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { "ERROR", "CRITICAL" }; +SDL_COMPILE_TIME_ASSERT(priority_prefixes, SDL_arraysize(SDL_priority_prefixes) == SDL_NUM_LOG_PRIORITIES); -#ifdef __ANDROID__ +/* If this list changes, update the documentation for SDL_HINT_LOGGING */ static const char *SDL_category_prefixes[] = { "APP", "ERROR", @@ -90,9 +88,9 @@ static const char *SDL_category_prefixes[] = { "INPUT", "TEST" }; +SDL_COMPILE_TIME_ASSERT(category_prefixes, SDL_arraysize(SDL_category_prefixes) == SDL_LOG_CATEGORY_RESERVED1); -SDL_COMPILE_TIME_ASSERT(category_prefixes_enum, SDL_TABLESIZE(SDL_category_prefixes) == SDL_LOG_CATEGORY_RESERVED1); - +#ifdef __ANDROID__ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { ANDROID_LOG_UNKNOWN, ANDROID_LOG_VERBOSE, @@ -106,7 +104,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { void SDL_LogInit(void) { - if (log_function_mutex == NULL) { + if (!log_function_mutex) { /* if this fails we'll try to continue without it. */ log_function_mutex = SDL_CreateMutex(); } @@ -128,9 +126,9 @@ void SDL_LogSetAllPriority(SDL_LogPriority priority) for (entry = SDL_loglevels; entry; entry = entry->next) { entry->priority = priority; } - SDL_default_priority = priority; - SDL_assert_priority = priority; - SDL_application_priority = priority; + + SDL_forced_priority = SDL_TRUE; + SDL_forced_priority_level = priority; } void SDL_LogSetPriority(int category, SDL_LogPriority priority) @@ -154,6 +152,122 @@ void SDL_LogSetPriority(int category, SDL_LogPriority priority) } } +static SDL_bool SDL_ParseLogCategory(const char *string, size_t length, int *category) +{ + int i; + + if (SDL_isdigit(*string)) { + *category = SDL_atoi(string); + return SDL_TRUE; + } + + if (*string == '*') { + *category = DEFAULT_CATEGORY; + return SDL_TRUE; + } + + for (i = 0; i < SDL_arraysize(SDL_category_prefixes); ++i) { + if (SDL_strncasecmp(string, SDL_category_prefixes[i], length) == 0) { + *category = i; + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +static SDL_bool SDL_ParseLogPriority(const char *string, size_t length, SDL_LogPriority *priority) +{ + int i; + + if (SDL_isdigit(*string)) { + i = SDL_atoi(string); + if (i == 0) { + /* 0 has a special meaning of "disable this category" */ + *priority = SDL_NUM_LOG_PRIORITIES; + return SDL_TRUE; + } + if (i >= SDL_LOG_PRIORITY_VERBOSE && i < SDL_NUM_LOG_PRIORITIES) { + *priority = (SDL_LogPriority)i; + return SDL_TRUE; + } + return SDL_FALSE; + } + + if (SDL_strncasecmp(string, "quiet", length) == 0) { + *priority = SDL_NUM_LOG_PRIORITIES; + return SDL_TRUE; + } + + for (i = SDL_LOG_PRIORITY_VERBOSE; i < SDL_NUM_LOG_PRIORITIES; ++i) { + if (SDL_strncasecmp(string, SDL_priority_prefixes[i], length) == 0) { + *priority = (SDL_LogPriority)i; + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +static SDL_bool SDL_ParseLogCategoryPriority(const char *hint, int category, SDL_LogPriority *priority) +{ + const char *name, *next; + int current_category; + + if (category == DEFAULT_CATEGORY && SDL_strchr(hint, '=') == NULL) { + return SDL_ParseLogPriority(hint, SDL_strlen(hint), priority); + } + + for (name = hint; name; name = next) { + const char *sep = SDL_strchr(name, '='); + if (!sep) { + break; + } + next = SDL_strchr(sep, ','); + if (next) { + ++next; + } + + if (SDL_ParseLogCategory(name, (sep - name), ¤t_category)) { + if (current_category == category) { + const char *value = sep + 1; + size_t len; + if (next) { + len = (next - value - 1); + } else { + len = SDL_strlen(value); + } + return SDL_ParseLogPriority(value, len, priority); + } + } + } + return SDL_FALSE; +} + +static SDL_LogPriority SDL_GetDefaultLogPriority(int category) +{ + const char *hint = SDL_GetHint(SDL_HINT_LOGGING); + if (hint) { + SDL_LogPriority priority; + + if (SDL_ParseLogCategoryPriority(hint, category, &priority)) { + return priority; + } + if (SDL_ParseLogCategoryPriority(hint, DEFAULT_CATEGORY, &priority)) { + return priority; + } + } + + switch (category) { + case SDL_LOG_CATEGORY_APPLICATION: + return SDL_LOG_PRIORITY_INFO; + case SDL_LOG_CATEGORY_ASSERT: + return SDL_LOG_PRIORITY_WARN; + case SDL_LOG_CATEGORY_TEST: + return SDL_LOG_PRIORITY_VERBOSE; + default: + return SDL_LOG_PRIORITY_ERROR; + } +} + SDL_LogPriority SDL_LogGetPriority(int category) { SDL_LogLevel *entry; @@ -164,15 +278,11 @@ SDL_LogPriority SDL_LogGetPriority(int category) } } - if (category == SDL_LOG_CATEGORY_TEST) { - return SDL_test_priority; - } else if (category == SDL_LOG_CATEGORY_APPLICATION) { - return SDL_application_priority; - } else if (category == SDL_LOG_CATEGORY_ASSERT) { - return SDL_assert_priority; - } else { - return SDL_default_priority; + if (SDL_forced_priority) { + return SDL_forced_priority_level; } + + return SDL_GetDefaultLogPriority(category); } void SDL_LogResetPriorities(void) @@ -184,11 +294,7 @@ void SDL_LogResetPriorities(void) SDL_loglevels = entry->next; SDL_free(entry); } - - SDL_default_priority = DEFAULT_PRIORITY; - SDL_assert_priority = DEFAULT_ASSERT_PRIORITY; - SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; - SDL_test_priority = DEFAULT_TEST_PRIORITY; + SDL_forced_priority = SDL_FALSE; } void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...) @@ -299,7 +405,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va return; } - if (log_function_mutex == NULL) { + if (!log_function_mutex) { /* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */ log_function_mutex = SDL_CreateMutex(); } @@ -317,7 +423,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) { /* Allocate exactly what we need, including the zero-terminator */ message = (char *)SDL_malloc(len_plus_term); - if (message == NULL) { + if (!message) { return; } va_copy(aq, ap); @@ -453,7 +559,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } @@ -462,7 +568,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("ux0:/data/SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } @@ -471,16 +577,16 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority { FILE *pFile; pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a"); - if (pFile != NULL) { + if (pFile) { (void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message); (void)fclose(pFile); } } #endif -#if HAVE_STDIO_H && \ +#if defined(HAVE_STDIO_H) && \ !(defined(__APPLE__) && (defined(SDL_VIDEO_DRIVER_COCOA) || defined(SDL_VIDEO_DRIVER_UIKIT))) fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); -#if __NACL__ +#ifdef __NACL__ fflush(stderr); #endif #endif diff --git a/vs/sdl2/src/SDL_log_c.h b/vs/sdl2/src/SDL_log_c.h index 4aae691e83..4d6676d30f 100644 --- a/vs/sdl2/src/SDL_log_c.h +++ b/vs/sdl2/src/SDL_log_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_utils.c b/vs/sdl2/src/SDL_utils.c index 36e9e03683..10a30836b3 100644 --- a/vs/sdl2/src/SDL_utils.c +++ b/vs/sdl2/src/SDL_utils.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/SDL_utils_c.h b/vs/sdl2/src/SDL_utils_c.h index 08b90e64ac..4c00d8b3ad 100644 --- a/vs/sdl2/src/SDL_utils_c.h +++ b/vs/sdl2/src/SDL_utils_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/atomic/SDL_atomic.c b/vs/sdl2/src/atomic/SDL_atomic.c index 4e10d52db0..e843c8d2c5 100644 --- a/vs/sdl2/src/atomic/SDL_atomic.c +++ b/vs/sdl2/src/atomic/SDL_atomic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +103,10 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v); */ #if !defined(HAVE_MSC_ATOMICS) && !defined(HAVE_GCC_ATOMICS) && !defined(__MACOSX__) && !defined(__SOLARIS__) && !defined(HAVE_WATCOM_ATOMICS) -#define EMULATE_CAS 1 +#define EMULATE_CAS #endif -#if EMULATE_CAS +#ifdef EMULATE_CAS static SDL_SpinLock locks[32]; static SDL_INLINE void enterLock(void *a) @@ -137,7 +137,7 @@ SDL_bool SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval) return (SDL_bool) OSAtomicCompareAndSwap32Barrier(oldval, newval, &a->value); #elif defined(__SOLARIS__) return (SDL_bool)((int)atomic_cas_uint((volatile uint_t *)&a->value, (uint_t)oldval, (uint_t)newval) == oldval); -#elif EMULATE_CAS +#elif defined(EMULATE_CAS) SDL_bool retval = SDL_FALSE; enterLock(a); @@ -167,7 +167,7 @@ SDL_bool SDL_AtomicCASPtr(void **a, void *oldval, void *newval) return (SDL_bool) OSAtomicCompareAndSwap32Barrier((int32_t)oldval, (int32_t)newval, (int32_t*) a); #elif defined(__SOLARIS__) return (SDL_bool)(atomic_cas_ptr(a, oldval, newval) == oldval); -#elif EMULATE_CAS +#elif defined(EMULATE_CAS) SDL_bool retval = SDL_FALSE; enterLock(a); diff --git a/vs/sdl2/src/atomic/SDL_spinlock.c b/vs/sdl2/src/atomic/SDL_spinlock.c index 9fd3e61676..a2d1d3f9da 100644 --- a/vs/sdl2/src/atomic/SDL_spinlock.c +++ b/vs/sdl2/src/atomic/SDL_spinlock.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +63,11 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v); /* This function is where all the magic happens... */ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock) { -#if SDL_ATOMIC_DISABLED +#ifdef SDL_ATOMIC_DISABLED /* Terrible terrible damage */ static SDL_mutex *_spinlock_mutex; - if (_spinlock_mutex == NULL) { + if (!_spinlock_mutex) { /* Race condition on first lock... */ _spinlock_mutex = SDL_CreateMutex(); } @@ -81,7 +81,7 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock) return SDL_FALSE; } -#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET +#elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET) return __sync_lock_test_and_set(lock, 1) == 0; #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) @@ -186,7 +186,7 @@ void SDL_AtomicLock(SDL_SpinLock *lock) void SDL_AtomicUnlock(SDL_SpinLock *lock) { -#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET +#if defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET) __sync_lock_release(lock); #elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64)) diff --git a/vs/sdl2/src/audio/SDL_audio.c b/vs/sdl2/src/audio/SDL_audio.c index 60242e60a0..96586fe773 100644 --- a/vs/sdl2/src/audio/SDL_audio.c +++ b/vs/sdl2/src/audio/SDL_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,102 +31,108 @@ #define _THIS SDL_AudioDevice *_this +typedef struct AudioThreadStartupData +{ + SDL_AudioDevice *device; + SDL_sem *startup_semaphore; +} AudioThreadStartupData; + static SDL_AudioDriver current_audio; static SDL_AudioDevice *open_devices[16]; /* Available audio drivers */ static const AudioBootStrap *const bootstrap[] = { -#if SDL_AUDIO_DRIVER_PULSEAUDIO +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO &PULSEAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_ALSA +#ifdef SDL_AUDIO_DRIVER_ALSA &ALSA_bootstrap, #endif -#if SDL_AUDIO_DRIVER_SNDIO +#ifdef SDL_AUDIO_DRIVER_SNDIO &SNDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_NETBSD +#ifdef SDL_AUDIO_DRIVER_NETBSD &NETBSDAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_QSA +#ifdef SDL_AUDIO_DRIVER_QSA &QSAAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_SUNAUDIO +#ifdef SDL_AUDIO_DRIVER_SUNAUDIO &SUNAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_ARTS +#ifdef SDL_AUDIO_DRIVER_ARTS &ARTS_bootstrap, #endif -#if SDL_AUDIO_DRIVER_ESD +#ifdef SDL_AUDIO_DRIVER_ESD &ESD_bootstrap, #endif -#if SDL_AUDIO_DRIVER_NACL +#ifdef SDL_AUDIO_DRIVER_NACL &NACLAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_NAS +#ifdef SDL_AUDIO_DRIVER_NAS &NAS_bootstrap, #endif -#if SDL_AUDIO_DRIVER_WASAPI +#ifdef SDL_AUDIO_DRIVER_WASAPI &WASAPI_bootstrap, #endif -#if SDL_AUDIO_DRIVER_DSOUND +#ifdef SDL_AUDIO_DRIVER_DSOUND &DSOUND_bootstrap, #endif -#if SDL_AUDIO_DRIVER_WINMM +#ifdef SDL_AUDIO_DRIVER_WINMM &WINMM_bootstrap, #endif -#if SDL_AUDIO_DRIVER_PAUDIO +#ifdef SDL_AUDIO_DRIVER_PAUDIO &PAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_HAIKU +#ifdef SDL_AUDIO_DRIVER_HAIKU &HAIKUAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_COREAUDIO +#ifdef SDL_AUDIO_DRIVER_COREAUDIO &COREAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_FUSIONSOUND +#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND &FUSIONSOUND_bootstrap, #endif -#if SDL_AUDIO_DRIVER_AAUDIO +#ifdef SDL_AUDIO_DRIVER_AAUDIO &aaudio_bootstrap, #endif -#if SDL_AUDIO_DRIVER_OPENSLES +#ifdef SDL_AUDIO_DRIVER_OPENSLES &openslES_bootstrap, #endif -#if SDL_AUDIO_DRIVER_ANDROID +#ifdef SDL_AUDIO_DRIVER_ANDROID &ANDROIDAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_PS2 +#ifdef SDL_AUDIO_DRIVER_PS2 &PS2AUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_PSP +#ifdef SDL_AUDIO_DRIVER_PSP &PSPAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_VITA +#ifdef SDL_AUDIO_DRIVER_VITA &VITAAUD_bootstrap, #endif -#if SDL_AUDIO_DRIVER_N3DS +#ifdef SDL_AUDIO_DRIVER_N3DS &N3DSAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_EMSCRIPTEN +#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN &EMSCRIPTENAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_JACK +#ifdef SDL_AUDIO_DRIVER_JACK &JACK_bootstrap, #endif -#if SDL_AUDIO_DRIVER_PIPEWIRE +#ifdef SDL_AUDIO_DRIVER_PIPEWIRE &PIPEWIRE_bootstrap, #endif -#if SDL_AUDIO_DRIVER_OSS +#ifdef SDL_AUDIO_DRIVER_OSS &DSP_bootstrap, #endif -#if SDL_AUDIO_DRIVER_OS2 +#ifdef SDL_AUDIO_DRIVER_OS2 &OS2AUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_DISK +#ifdef SDL_AUDIO_DRIVER_DISK &DISKAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_DUMMY +#ifdef SDL_AUDIO_DRIVER_DUMMY &DUMMYAUDIO_bootstrap, #endif NULL @@ -658,22 +664,24 @@ void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid) current_audio.impl.UnlockDevice(device); } -#if SDL_AUDIO_DRIVER_ANDROID +#ifdef SDL_AUDIO_DRIVER_ANDROID extern void Android_JNI_AudioSetThreadPriority(int, int); #endif /* The general mixing thread function */ -static int SDLCALL SDL_RunAudio(void *devicep) +static int SDLCALL SDL_RunAudio(void *userdata) { - SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; + const AudioThreadStartupData *startup_data = (const AudioThreadStartupData *) userdata; + SDL_AudioDevice *device = startup_data->device; void *udata = device->callbackspec.userdata; SDL_AudioCallback callback = device->callbackspec.callback; int data_len = 0; Uint8 *data; + Uint8 *device_buf_keepsafe = NULL; SDL_assert(!device->iscapture); -#if SDL_AUDIO_DRIVER_ANDROID +#ifdef SDL_AUDIO_DRIVER_ANDROID { /* Set thread priority to THREAD_PRIORITY_AUDIO */ Android_JNI_AudioSetThreadPriority(device->iscapture, device->id); @@ -685,6 +693,9 @@ static int SDLCALL SDL_RunAudio(void *devicep) /* Perform any thread setup */ device->threadid = SDL_ThreadID(); + + SDL_SemPost(startup_data->startup_semaphore); /* SDL_OpenAudioDevice may now continue. */ + current_audio.impl.ThreadInit(device); /* Loop, filling the audio buffers */ @@ -693,8 +704,16 @@ static int SDLCALL SDL_RunAudio(void *devicep) /* Fill the current buffer with sound */ if (!device->stream && SDL_AtomicGet(&device->enabled)) { - SDL_assert(data_len == device->spec.size); data = current_audio.impl.GetDeviceBuf(device); + + if (device->stream && SDL_AtomicGet(&device->enabled)) { + /* Oops. Audio device reset and now we suddenly use a stream, */ + /* so save this devicebuf for later, to prevent de-sync */ + if (data != NULL) { + device_buf_keepsafe = data; + } + data = NULL; + } } else { /* if the device isn't enabled, we still write to the work_buffer, so the app's callback will fire with @@ -725,7 +744,19 @@ static int SDLCALL SDL_RunAudio(void *devicep) while (SDL_AudioStreamAvailable(device->stream) >= ((int)device->spec.size)) { int got; - data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL; + if (SDL_AtomicGet(&device->enabled)) { + /* if device reset occured - a switch from direct output to streaming */ + /* use the already aquired device buffer */ + if (device_buf_keepsafe) { + data = device_buf_keepsafe; + device_buf_keepsafe = NULL; + } else { + /* else - normal flow, just acquire the device buffer here */ + data = current_audio.impl.GetDeviceBuf(device); + } + } else { + data = NULL; + } got = SDL_AudioStreamGet(device->stream, data ? data : device->work_buffer, device->spec.size); SDL_assert((got <= 0) || (got == device->spec.size)); @@ -740,6 +771,14 @@ static int SDLCALL SDL_RunAudio(void *devicep) current_audio.impl.WaitDevice(device); } } + + /* it seems resampling was not fast enough, device_buf_keepsafe was not released yet, so play silence here */ + if (device_buf_keepsafe) { + SDL_memset(device_buf_keepsafe, device->spec.silence, device->spec.size); + current_audio.impl.PlayDevice(device); + current_audio.impl.WaitDevice(device); + device_buf_keepsafe = NULL; + } } else if (data == device->work_buffer) { /* nothing to do; pause like we queued a buffer to play. */ const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); @@ -761,9 +800,10 @@ static int SDLCALL SDL_RunAudio(void *devicep) /* !!! FIXME: this needs to deal with device spec changes. */ /* The general capture thread function */ -static int SDLCALL SDL_CaptureAudio(void *devicep) +static int SDLCALL SDL_CaptureAudio(void *userdata) { - SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; + const AudioThreadStartupData *startup_data = (const AudioThreadStartupData *) userdata; + SDL_AudioDevice *device = startup_data->device; const int silence = (int)device->spec.silence; const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq); const int data_len = device->spec.size; @@ -773,7 +813,7 @@ static int SDLCALL SDL_CaptureAudio(void *devicep) SDL_assert(device->iscapture); -#if SDL_AUDIO_DRIVER_ANDROID +#ifdef SDL_AUDIO_DRIVER_ANDROID { /* Set thread priority to THREAD_PRIORITY_AUDIO */ Android_JNI_AudioSetThreadPriority(device->iscapture, device->id); @@ -785,6 +825,9 @@ static int SDLCALL SDL_CaptureAudio(void *devicep) /* Perform any thread setup */ device->threadid = SDL_ThreadID(); + + SDL_SemPost(startup_data->startup_semaphore); /* SDL_OpenAudioDevice may now continue. */ + current_audio.impl.ThreadInit(device); /* Loop, filling the audio buffers */ @@ -932,7 +975,7 @@ int SDL_AudioInit(const char *driver_name) const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt) : SDL_strlen(driver_attempt); -#if SDL_AUDIO_DRIVER_DSOUND +#ifdef SDL_AUDIO_DRIVER_DSOUND /* SDL 1.2 uses the name "dsound", so we'll support both. */ if (driver_attempt_len == SDL_strlen("dsound") && (SDL_strncasecmp(driver_attempt, "dsound", driver_attempt_len) == 0)) { @@ -941,7 +984,7 @@ int SDL_AudioInit(const char *driver_name) } #endif -#if SDL_AUDIO_DRIVER_PULSEAUDIO +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO /* SDL 1.2 uses the name "pulse", so we'll support both. */ if (driver_attempt_len == SDL_strlen("pulse") && (SDL_strncasecmp(driver_attempt, "pulse", driver_attempt_len) == 0)) { @@ -962,7 +1005,7 @@ int SDL_AudioInit(const char *driver_name) } } - driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL; + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; } } else { for (i = 0; (!initialized) && (bootstrap[i]); ++i) { @@ -1009,7 +1052,7 @@ int SDL_AudioInit(const char *driver_name) /* * Get the current audio driver name */ -const char *SDL_GetCurrentAudioDriver() +const char *SDL_GetCurrentAudioDriver(void) { return current_audio.name; } @@ -1261,7 +1304,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained, int allowed_changes, int min_id) { - const SDL_bool is_internal_thread = (desired->callback == NULL); SDL_AudioDeviceID id = 0; SDL_AudioSpec _obtained; SDL_AudioDevice *device; @@ -1279,25 +1321,10 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, return 0; } - SDL_LockMutex(current_audio.detectionLock); - /* Find an available device ID... */ - for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) { - if (open_devices[id] == NULL) { - break; - } - } - - if (id == SDL_arraysize(open_devices)) { - SDL_SetError("Too many open audio devices"); - SDL_UnlockMutex(current_audio.detectionLock); - return 0; - } - if (!obtained) { obtained = &_obtained; } if (!prepare_audiospec(desired, obtained)) { - SDL_UnlockMutex(current_audio.detectionLock); return 0; } @@ -1319,11 +1346,11 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, if ((iscapture) && (current_audio.impl.OnlyHasDefaultCaptureDevice)) { if ((devname) && (SDL_strcmp(devname, DEFAULT_INPUT_DEVNAME) != 0)) { SDL_SetError("No such device"); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } devname = NULL; + SDL_LockMutex(current_audio.detectionLock); for (i = 0; i < SDL_arraysize(open_devices); i++) { if ((open_devices[i]) && (open_devices[i]->iscapture)) { SDL_SetError("Audio device already open"); @@ -1331,14 +1358,15 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, return 0; } } + SDL_UnlockMutex(current_audio.detectionLock); } else if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) { if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) { - SDL_UnlockMutex(current_audio.detectionLock); SDL_SetError("No such device"); return 0; } devname = NULL; + SDL_LockMutex(current_audio.detectionLock); for (i = 0; i < SDL_arraysize(open_devices); i++) { if ((open_devices[i]) && (!open_devices[i]->iscapture)) { SDL_UnlockMutex(current_audio.detectionLock); @@ -1346,6 +1374,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, return 0; } } + SDL_UnlockMutex(current_audio.detectionLock); } else if (devname != NULL) { /* if the app specifies an exact string, we can pass the backend an actual device handle thingey, which saves them the effort of @@ -1354,19 +1383,20 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, It might still need to open a device based on the string for, say, a network audio server, but this optimizes some cases. */ SDL_AudioDeviceItem *item; + SDL_LockMutex(current_audio.detectionLock); for (item = iscapture ? current_audio.inputDevices : current_audio.outputDevices; item; item = item->next) { if ((item->handle != NULL) && (SDL_strcmp(item->name, devname) == 0)) { handle = item->handle; break; } } + SDL_UnlockMutex(current_audio.detectionLock); } if (!current_audio.impl.AllowsArbitraryDeviceNames) { /* has to be in our device list, or the default device. */ if ((handle == NULL) && (devname != NULL)) { SDL_SetError("No such device."); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } } @@ -1374,10 +1404,8 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, device = (SDL_AudioDevice *)SDL_calloc(1, sizeof(SDL_AudioDevice)); if (device == NULL) { SDL_OutOfMemory(); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } - device->id = id + 1; device->spec = *obtained; device->iscapture = iscapture ? SDL_TRUE : SDL_FALSE; device->handle = handle; @@ -1391,7 +1419,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, device->mixer_lock = SDL_CreateMutex(); if (device->mixer_lock == NULL) { close_audio_device(device); - SDL_UnlockMutex(current_audio.detectionLock); SDL_SetError("Couldn't create mixer lock"); return 0; } @@ -1406,7 +1433,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, if (current_audio.impl.OpenDevice(device, devname) < 0) { close_audio_device(device); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } @@ -1462,7 +1488,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, if (!device->stream) { close_audio_device(device); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } } @@ -1472,7 +1497,6 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, device->buffer_queue = SDL_NewDataQueue(SDL_AUDIOBUFFERQUEUE_PACKETLEN, obtained->size * 2); if (!device->buffer_queue) { close_audio_device(device); - SDL_UnlockMutex(current_audio.detectionLock); SDL_SetError("Couldn't create audio buffer queue"); return 0; } @@ -1490,32 +1514,56 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture, device->work_buffer = (Uint8 *)SDL_malloc(device->work_buffer_len); if (device->work_buffer == NULL) { close_audio_device(device); - SDL_UnlockMutex(current_audio.detectionLock); SDL_OutOfMemory(); return 0; } + /* Find an available device ID... */ + SDL_LockMutex(current_audio.detectionLock); + for (id = min_id - 1; id < SDL_arraysize(open_devices); id++) { + if (open_devices[id] == NULL) { + break; + } + } + + if (id == SDL_arraysize(open_devices)) { + close_audio_device(device); + SDL_SetError("Too many open audio devices"); + SDL_UnlockMutex(current_audio.detectionLock); + return 0; + } + + device->id = id + 1; open_devices[id] = device; /* add it to our list of open devices. */ + SDL_UnlockMutex(current_audio.detectionLock); /* Start the audio thread if necessary */ if (!current_audio.impl.ProvidesOwnCallbackThread) { /* Start the audio thread */ - /* !!! FIXME: we don't force the audio thread stack size here if it calls into user code, but maybe we should? */ - /* buffer queueing callback only needs a few bytes, so make the stack tiny. */ - const size_t stacksize = is_internal_thread ? 64 * 1024 : 0; char threadname[64]; + AudioThreadStartupData startup_data; + + startup_data.device = device; + startup_data.startup_semaphore = SDL_CreateSemaphore(0); + if (!startup_data.startup_semaphore) { + close_audio_device(device); + SDL_SetError("Couldn't create audio thread startup semaphore"); + return 0; + } (void)SDL_snprintf(threadname, sizeof(threadname), "SDLAudio%c%" SDL_PRIu32, (iscapture) ? 'C' : 'P', device->id); - device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device); + device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, 0, &startup_data); if (device->thread == NULL) { + SDL_DestroySemaphore(startup_data.startup_semaphore); close_audio_device(device); SDL_SetError("Couldn't create audio thread"); - SDL_UnlockMutex(current_audio.detectionLock); return 0; } + + SDL_SemWait(startup_data.startup_semaphore); + SDL_DestroySemaphore(startup_data.startup_semaphore); } - SDL_UnlockMutex(current_audio.detectionLock); return device->id; } diff --git a/vs/sdl2/src/audio/SDL_audio_c.h b/vs/sdl2/src/audio/SDL_audio_c.h index 9ec79edc42..5bc2b41daa 100644 --- a/vs/sdl2/src/audio/SDL_audio_c.h +++ b/vs/sdl2/src/audio/SDL_audio_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_audio_channel_converters.h b/vs/sdl2/src/audio/SDL_audio_channel_converters.h index 72cb511d04..95e22b1c35 100644 --- a/vs/sdl2/src/audio/SDL_audio_channel_converters.h +++ b/vs/sdl2/src/audio/SDL_audio_channel_converters.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_audio_resampler_filter.h b/vs/sdl2/src/audio/SDL_audio_resampler_filter.h index 83cde7cb53..a6dff392d3 100644 --- a/vs/sdl2/src/audio/SDL_audio_resampler_filter.h +++ b/vs/sdl2/src/audio/SDL_audio_resampler_filter.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_audiocvt.c b/vs/sdl2/src/audio/SDL_audiocvt.c index ed4333eca1..9087317bcb 100644 --- a/vs/sdl2/src/audio/SDL_audiocvt.c +++ b/vs/sdl2/src/audio/SDL_audiocvt.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +93,7 @@ * 8 channels (7.1) layout: FL+FR+FC+LFE+BL+BR+SL+SR */ -#if HAVE_SSE3_INTRINSICS +#ifdef HAVE_SSE3_INTRINSICS /* Convert from stereo to mono. Average left and right. */ static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format) { @@ -130,7 +130,7 @@ static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFor } #endif -#if HAVE_SSE_INTRINSICS +#ifdef HAVE_SSE_INTRINSICS /* Convert from mono to stereo. Duplicate to stereo left and right. */ static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format) { @@ -266,7 +266,7 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt) /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ /* Make sure there's data to convert */ - if (cvt->buf == NULL) { + if (!cvt->buf) { return SDL_SetError("No buffer allocated for conversion"); } @@ -473,10 +473,12 @@ static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_Au result = SRC_src_simple(&data, SRC_converter, chans); /* Simple API converts the whole buffer at once. No need for initialization. */ /* !!! FIXME: Handle library failures? */ -#ifdef DEBUG_CONVERT +#if DEBUG_CONVERT if (result != 0) { SDL_Log("src_simple() failed: %s", SRC_src_strerror(result)); } +#else + (void)result; #endif cvt->len_cvt = data.output_frames_gen * framelen; @@ -517,7 +519,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF /* we keep no streaming state here, so pad with silence on both ends. */ padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float)); - if (padding == NULL) { + if (!padding) { SDL_OutOfMemory(); return; } @@ -614,7 +616,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, } filter = ChooseCVTResampler(dst_channels); - if (filter == NULL) { + if (!filter) { return SDL_SetError("No conversion available for these rates"); } @@ -687,7 +689,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFilter channel_converter = NULL; /* Sanity check target pointer */ - if (cvt == NULL) { + if (!cvt) { return SDL_InvalidParamError("cvt"); } @@ -782,14 +784,14 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0])); channel_converter = channel_converters[src_channels - 1][dst_channels - 1]; - if ((channel_converter == NULL) != (src_channels == dst_channels)) { + if ((!channel_converter) != (src_channels == dst_channels)) { /* All combinations of supported channel counts should have been handled by now, but let's be defensive */ return SDL_SetError("Invalid channel combination"); } else if (channel_converter != NULL) { /* swap in some SIMD versions for a few of these. */ if (channel_converter == SDL_ConvertStereoToMono) { SDL_AudioFilter filter = NULL; -#if HAVE_SSE3_INTRINSICS +#ifdef HAVE_SSE3_INTRINSICS if (!filter && SDL_HasSSE3()) { filter = SDL_ConvertStereoToMono_SSE3; } @@ -799,7 +801,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, } } else if (channel_converter == SDL_ConvertMonoToStereo) { SDL_AudioFilter filter = NULL; -#if HAVE_SSE_INTRINSICS +#ifdef HAVE_SSE_INTRINSICS if (!filter && SDL_HasSSE()) { filter = SDL_ConvertMonoToStereo_SSE; } @@ -878,7 +880,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen) ptr = stream->work_buffer_base; } else { ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -950,12 +952,12 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream) if (SRC_available) { state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result); - if (state == NULL) { + if (!state) { SDL_SetError("src_new() failed: %s", SRC_src_strerror(result)); } } - if (state == NULL) { + if (!state) { SDL_CleanupAudioStreamResampler_SRC(stream); return SDL_FALSE; } @@ -1027,7 +1029,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, } retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -1053,7 +1055,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels; retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float)); - if (retval->resampler_padding == NULL) { + if (!retval->resampler_padding) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1062,7 +1064,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size); if (retval->staging_buffer_size > 0) { retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size); - if (retval->staging_buffer == NULL) { + if (!retval->staging_buffer) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1169,7 +1171,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, #endif workbuf = EnsureStreamBufferSize(stream, workbuflen); - if (workbuf == NULL) { + if (!workbuf) { return -1; /* probably out of memory. */ } @@ -1260,10 +1262,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len == 0) { @@ -1315,7 +1317,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) int SDL_AudioStreamFlush(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } @@ -1373,10 +1375,10 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len <= 0) { @@ -1397,7 +1399,7 @@ int SDL_AudioStreamAvailable(SDL_AudioStream *stream) void SDL_AudioStreamClear(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { SDL_InvalidParamError("stream"); } else { SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2); diff --git a/vs/sdl2/src/audio/SDL_audiodev.c b/vs/sdl2/src/audio/SDL_audiodev.c index ac35cb2658..903ba9e761 100644 --- a/vs/sdl2/src/audio/SDL_audiodev.c +++ b/vs/sdl2/src/audio/SDL_audiodev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ /* Get the name of the audio device we use for output */ -#if SDL_AUDIO_DRIVER_NETBSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO +#if defined(SDL_AUDIO_DRIVER_NETBSD) || defined(SDL_AUDIO_DRIVER_OSS) || defined(SDL_AUDIO_DRIVER_SUNAUDIO) #include #include @@ -81,16 +81,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla const char *audiodev; char audiopath[1024]; - if (test == NULL) { + if (!test) { test = test_stub; } /* Figure out what our audio device is */ audiodev = SDL_getenv("SDL_PATH_DSP"); - if (audiodev == NULL) { + if (!audiodev) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { diff --git a/vs/sdl2/src/audio/SDL_audiodev_c.h b/vs/sdl2/src/audio/SDL_audiodev_c.h index 9e890c3958..1235ea4450 100644 --- a/vs/sdl2/src/audio/SDL_audiodev_c.h +++ b/vs/sdl2/src/audio/SDL_audiodev_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_audiotypecvt.c b/vs/sdl2/src/audio/SDL_audiotypecvt.c index 7ffa4dd19e..221bfbb8d4 100644 --- a/vs/sdl2/src/audio/SDL_audiotypecvt.c +++ b/vs/sdl2/src/audio/SDL_audiotypecvt.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,16 +29,16 @@ #endif #ifdef __SSE2__ -#define HAVE_SSE2_INTRINSICS 1 +#define HAVE_SSE2_INTRINSICS #endif -#if defined(__x86_64__) && HAVE_SSE2_INTRINSICS +#if defined(__x86_64__) && defined(HAVE_SSE2_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* x86_64 guarantees SSE2. */ -#elif __MACOSX__ && HAVE_SSE2_INTRINSICS +#elif defined(__MACOSX__) && defined(HAVE_SSE2_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* Mac OS X/Intel guarantees SSE2. */ -#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && HAVE_NEON_INTRINSICS +#elif defined(__ARM_ARCH) && (__ARM_ARCH >= 8) && defined(HAVE_NEON_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* ARMv8+ promise NEON. */ -#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && HAVE_NEON_INTRINSICS +#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && defined(HAVE_NEON_INTRINSICS) #define NEED_SCALAR_CONVERTER_FALLBACKS 0 /* All Apple ARMv7 chips promise NEON support. */ #endif @@ -62,18 +62,36 @@ SDL_AudioFilter SDL_Convert_F32_to_S32 = NULL; #define DIVBY128 0.0078125f #define DIVBY32768 0.000030517578125f #define DIVBY8388607 0.00000011920930376163766f +#define DIVBY2147483648 0.0000000004656612873077392578125f /* 0x1p-31f */ #if NEED_SCALAR_CONVERTER_FALLBACKS + +/* This code requires that floats are in the IEEE-754 binary32 format */ +SDL_COMPILE_TIME_ASSERT(float_bits, sizeof(float) == sizeof(Uint32)); + +union float_bits { + Uint32 u32; + float f32; +}; + +/* Create a bit-mask based on the sign-bit. Should optimize to a single arithmetic-shift-right */ +#define SIGNMASK(x) (Uint32)(0u - ((Uint32)(x) >> 31)) + static void SDLCALL SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; + const int num_samples = cvt->len_cvt; + const Sint8 *src = (const Sint8 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32"); - for (i = cvt->len_cvt; i; --i, --src, --dst) { - *dst = ((float)*src) * DIVBY128; + for (i = num_samples - 1; i >= 0; --i) { + /* 1) Construct a float in the range [65536.0, 65538.0) + * 2) Shift the float range to [-1.0, 1.0) */ + union float_bits x; + x.u32 = (Uint8)src[i] ^ 0x47800080u; + dst[i] = x.f32 - 65537.0f; } cvt->len_cvt *= 4; @@ -84,14 +102,19 @@ static void SDLCALL SDL_Convert_S8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFor static void SDLCALL SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; + const int num_samples = cvt->len_cvt; + const Uint8 *src = (const Uint8 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32"); - for (i = cvt->len_cvt; i; --i, --src, --dst) { - *dst = (((float)*src) * DIVBY128) - 1.0f; + for (i = num_samples - 1; i >= 0; --i) { + /* 1) Construct a float in the range [65536.0, 65538.0) + * 2) Shift the float range to [-1.0, 1.0) */ + union float_bits x; + x.u32 = src[i] ^ 0x47800000u; + dst[i] = x.f32 - 65537.0f; } cvt->len_cvt *= 4; @@ -102,14 +125,19 @@ static void SDLCALL SDL_Convert_U8_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFor static void SDLCALL SDL_Convert_S16_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; + const int num_samples = cvt->len_cvt / sizeof(Sint16); + const Sint16 *src = (const Sint16 *)cvt->buf; + float *dst = (float *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32"); - for (i = cvt->len_cvt / sizeof(Sint16); i; --i, --src, --dst) { - *dst = ((float)*src) * DIVBY32768; + for (i = num_samples - 1; i >= 0; --i) { + /* 1) Construct a float in the range [256.0, 258.0) + * 2) Shift the float range to [-1.0, 1.0) */ + union float_bits x; + x.u32 = (Uint16)src[i] ^ 0x43808000u; + dst[i] = x.f32 - 257.0f; } cvt->len_cvt *= 2; @@ -155,21 +183,26 @@ static void SDLCALL SDL_Convert_S32_to_F32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFo static void SDLCALL SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { + const int num_samples = cvt->len_cvt / sizeof (float); const float *src = (const float *)cvt->buf; Sint8 *dst = (Sint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8"); - for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 127; - } else if (sample <= -1.0f) { - *dst = -128; - } else { - *dst = (Sint8)(sample * 127.0f); - } + for (i = 0; i < num_samples; ++i) { + /* 1) Shift the float range from [-1.0, 1.0] to [98303.0, 98305.0] + * 2) Shift the integer range from [0x47BFFF80, 0x47C00080] to [-128, 128] + * 3) Clamp the value to [-128, 127] */ + union float_bits x; + Uint32 y, z; + x.f32 = src[i] + 98304.0f; + + y = x.u32 - 0x47C00000u; + z = 0x7Fu - (y ^ SIGNMASK(y)); + y = y ^ (z & SIGNMASK(z)); + + dst[i] = (Sint8)(y & 0xFF); } cvt->len_cvt /= 4; @@ -180,21 +213,27 @@ static void SDLCALL SDL_Convert_F32_to_S8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFor static void SDLCALL SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { + const int num_samples = cvt->len_cvt / sizeof (float); const float *src = (const float *)cvt->buf; Uint8 *dst = (Uint8 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8"); - for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 255; - } else if (sample <= -1.0f) { - *dst = 0; - } else { - *dst = (Uint8)((sample + 1.0f) * 127.0f); - } + for (i = 0; i < num_samples; ++i) { + /* 1) Shift the float range from [-1.0, 1.0] to [98303.0, 98305.0] + * 2) Shift the integer range from [0x47BFFF80, 0x47C00080] to [-128, 128] + * 3) Clamp the value to [-128, 127] + * 4) Shift the integer range from [-128, 127] to [0, 255] */ + union float_bits x; + Uint32 y, z; + x.f32 = src[i] + 98304.0f; + + y = x.u32 - 0x47C00000u; + z = 0x7Fu - (y ^ SIGNMASK(y)); + y = (y ^ 0x80u) ^ (z & SIGNMASK(z)); + + dst[i] = (Uint8)(y & 0xFF); } cvt->len_cvt /= 4; @@ -205,21 +244,26 @@ static void SDLCALL SDL_Convert_F32_to_U8_Scalar(SDL_AudioCVT *cvt, SDL_AudioFor static void SDLCALL SDL_Convert_F32_to_S16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { + const int num_samples = cvt->len_cvt / sizeof (float); const float *src = (const float *)cvt->buf; Sint16 *dst = (Sint16 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16"); - for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 32767; - } else if (sample <= -1.0f) { - *dst = -32768; - } else { - *dst = (Sint16)(sample * 32767.0f); - } + for (i = 0; i < num_samples; ++i) { + /* 1) Shift the float range from [-1.0, 1.0] to [383.0, 385.0] + * 2) Shift the integer range from [0x43BF8000, 0x43C08000] to [-32768, 32768] + * 3) Clamp values outside the [-32768, 32767] range */ + union float_bits x; + Uint32 y, z; + x.f32 = src[i] + 384.0f; + + y = x.u32 - 0x43C00000u; + z = 0x7FFFu - (y ^ SIGNMASK(y)); + y = y ^ (z & SIGNMASK(z)); + + dst[i] = (Sint16)(y & 0xFFFF); } cvt->len_cvt /= 2; @@ -255,21 +299,27 @@ static void SDLCALL SDL_Convert_F32_to_U16_Scalar(SDL_AudioCVT *cvt, SDL_AudioFo static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFormat format) { + const int num_samples = cvt->len_cvt / sizeof (float); const float *src = (const float *)cvt->buf; Sint32 *dst = (Sint32 *)cvt->buf; int i; LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32"); - for (i = cvt->len_cvt / sizeof(float); i; --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 2147483647; - } else if (sample <= -1.0f) { - *dst = (Sint32)-2147483648LL; - } else { - *dst = ((Sint32)(sample * 8388607.0f)) << 8; - } + for (i = 0; i < num_samples; ++i) { + /* 1) Shift the float range from [-1.0, 1.0] to [-2147483648.0, 2147483648.0] + * 2) Set values outside the [-2147483648.0, 2147483647.0] range to -2147483648.0 + * 3) Convert the float to an integer, and fixup values outside the valid range */ + union float_bits x; + Uint32 y, z; + x.f32 = src[i]; + + y = x.u32 + 0x0F800000u; + z = y - 0xCF000000u; + z &= SIGNMASK(y ^ z); + x.u32 = y - z; + + dst[i] = (Sint32)x.f32 ^ (Sint32)SIGNMASK(z); } if (cvt->filters[++cvt->filter_index]) { @@ -278,63 +328,48 @@ static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFo } #endif -#if HAVE_SSE2_INTRINSICS +#ifdef HAVE_SSE2_INTRINSICS static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; - int i; + const Sint8 *src = (const Sint8 *)cvt->buf; + float *dst = (float *)cvt->buf; + int i = cvt->len_cvt; + + /* 1) Flip the sign bit to convert from S8 to U8 format + * 2) Construct a float in the range [65536.0, 65538.0) + * 3) Shift the float range to [-1.0, 1.0) + * dst[i] = i2f((src[i] ^ 0x80) | 0x47800000) - 65537.0 */ + const __m128i zero = _mm_setzero_si128(); + const __m128i flipper = _mm_set1_epi8(-0x80); + const __m128i caster = _mm_set1_epi16(0x4780 /* 0x47800000 = f2i(65536.0) */); + const __m128 offset = _mm_set1_ps(-65537.0); LOG_DEBUG_CONVERT("AUDIO_S8", "AUDIO_F32 (using SSE2)"); - /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { - *dst = ((float)*src) * DIVBY128; - } + while (i >= 16) { + i -= 16; - src -= 15; - dst -= 15; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || !(((size_t)dst) & 15)); + { + const __m128i bytes = _mm_xor_si128(_mm_loadu_si128((const __m128i *)&src[i]), flipper); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128i *mmsrc = (const __m128i *)src; - const __m128i zero = _mm_setzero_si128(); - const __m128 divby128 = _mm_set1_ps(DIVBY128); - while (i >= 16) { /* 16 * 8-bit */ - const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 sint8 into an XMM register. */ - /* treat as int16, shift left to clear every other sint16, then back right with sign-extend. Now sint16. */ - const __m128i shorts1 = _mm_srai_epi16(_mm_slli_epi16(bytes, 8), 8); - /* right-shift-sign-extend gets us sint16 with the other set of values. */ - const __m128i shorts2 = _mm_srai_epi16(bytes, 8); - /* unpack against zero to make these int32, shift to make them sign-extend, convert to float, multiply. Whew! */ - const __m128 floats1 = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(_mm_unpacklo_epi16(shorts1, zero), 16), 16)), divby128); - const __m128 floats2 = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(_mm_unpacklo_epi16(shorts2, zero), 16), 16)), divby128); - const __m128 floats3 = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(_mm_unpackhi_epi16(shorts1, zero), 16), 16)), divby128); - const __m128 floats4 = _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_slli_epi32(_mm_unpackhi_epi16(shorts2, zero), 16), 16)), divby128); - /* Interleave back into correct order, store. */ - _mm_store_ps(dst, _mm_unpacklo_ps(floats1, floats2)); - _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); - _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); - _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); - i -= 16; - mmsrc--; - dst -= 16; - } + const __m128i shorts1 = _mm_unpacklo_epi8(bytes, zero); + const __m128i shorts2 = _mm_unpackhi_epi8(bytes, zero); - src = (const Sint8 *)mmsrc; - } + const __m128 floats1 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts1, caster)), offset); + const __m128 floats2 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts1, caster)), offset); + const __m128 floats3 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts2, caster)), offset); + const __m128 floats4 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts2, caster)), offset); - src += 15; - dst += 15; /* adjust for any scalar finishing. */ + _mm_storeu_ps(&dst[i], floats1); + _mm_storeu_ps(&dst[i + 4], floats2); + _mm_storeu_ps(&dst[i + 8], floats3); + _mm_storeu_ps(&dst[i + 12], floats4); + } + } - /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float)*src) * DIVBY128; - i--; - src--; - dst--; + --i; + _mm_store_ss(&dst[i], _mm_add_ss(_mm_castsi128_ps(_mm_cvtsi32_si128((Uint8)src[i] ^ 0x47800080u)), offset)); } cvt->len_cvt *= 4; @@ -345,62 +380,43 @@ static void SDLCALL SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Uint8 *src = ((const Uint8 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 4)) - 1; - int i; + const Sint8 *src = (const Sint8 *)cvt->buf; + float *dst = (float *)cvt->buf; + int i = cvt->len_cvt; + + /* 1) Construct a float in the range [65536.0, 65538.0) + * 2) Shift the float range to [-1.0, 1.0) + * dst[i] = i2f(src[i] | 0x47800000) - 65537.0 */ + const __m128i zero = _mm_setzero_si128(); + const __m128i caster = _mm_set1_epi16(0x4780 /* 0x47800000 = f2i(65536.0) */); + const __m128 offset = _mm_set1_ps(-65537.0); LOG_DEBUG_CONVERT("AUDIO_U8", "AUDIO_F32 (using SSE2)"); - /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt; i && (((size_t)(dst - 15)) & 15); --i, --src, --dst) { - *dst = (((float)*src) * DIVBY128) - 1.0f; - } + while (i >= 16) { + i -= 16; - src -= 15; - dst -= 15; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || !(((size_t)dst) & 15)); + { + const __m128i bytes = _mm_loadu_si128((const __m128i *)&src[i]); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128i *mmsrc = (const __m128i *)src; - const __m128i zero = _mm_setzero_si128(); - const __m128 divby128 = _mm_set1_ps(DIVBY128); - const __m128 minus1 = _mm_set1_ps(-1.0f); - while (i >= 16) { /* 16 * 8-bit */ - const __m128i bytes = _mm_load_si128(mmsrc); /* get 16 uint8 into an XMM register. */ - /* treat as int16, shift left to clear every other sint16, then back right with zero-extend. Now uint16. */ - const __m128i shorts1 = _mm_srli_epi16(_mm_slli_epi16(bytes, 8), 8); - /* right-shift-zero-extend gets us uint16 with the other set of values. */ - const __m128i shorts2 = _mm_srli_epi16(bytes, 8); - /* unpack against zero to make these int32, convert to float, multiply, add. Whew! */ - /* Note that AVX2 can do floating point multiply+add in one instruction, fwiw. SSE2 cannot. */ - const __m128 floats1 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi16(shorts1, zero)), divby128), minus1); - const __m128 floats2 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi16(shorts2, zero)), divby128), minus1); - const __m128 floats3 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi16(shorts1, zero)), divby128), minus1); - const __m128 floats4 = _mm_add_ps(_mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi16(shorts2, zero)), divby128), minus1); - /* Interleave back into correct order, store. */ - _mm_store_ps(dst, _mm_unpacklo_ps(floats1, floats2)); - _mm_store_ps(dst + 4, _mm_unpackhi_ps(floats1, floats2)); - _mm_store_ps(dst + 8, _mm_unpacklo_ps(floats3, floats4)); - _mm_store_ps(dst + 12, _mm_unpackhi_ps(floats3, floats4)); - i -= 16; - mmsrc--; - dst -= 16; - } + const __m128i shorts1 = _mm_unpacklo_epi8(bytes, zero); + const __m128i shorts2 = _mm_unpackhi_epi8(bytes, zero); - src = (const Uint8 *)mmsrc; - } + const __m128 floats1 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts1, caster)), offset); + const __m128 floats2 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts1, caster)), offset); + const __m128 floats3 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts2, caster)), offset); + const __m128 floats4 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts2, caster)), offset); - src += 15; - dst += 15; /* adjust for any scalar finishing. */ + _mm_storeu_ps(&dst[i], floats1); + _mm_storeu_ps(&dst[i + 4], floats2); + _mm_storeu_ps(&dst[i + 8], floats3); + _mm_storeu_ps(&dst[i + 12], floats4); + } + } - /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = (((float)*src) * DIVBY128) - 1.0f; - i--; - src--; - dst--; + --i; + _mm_store_ss(&dst[i], _mm_add_ss(_mm_castsi128_ps(_mm_cvtsi32_si128((Uint8)src[i] ^ 0x47800000u)), offset)); } cvt->len_cvt *= 4; @@ -411,49 +427,42 @@ static void SDLCALL SDL_Convert_U8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma static void SDLCALL SDL_Convert_S16_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format) { - const Sint16 *src = ((const Sint16 *)(cvt->buf + cvt->len_cvt)) - 1; - float *dst = ((float *)(cvt->buf + cvt->len_cvt * 2)) - 1; - int i; + const Sint16 *src = (const Sint16 *)cvt->buf; + float *dst = (float *)cvt->buf; + int i = cvt->len_cvt / 2; + + /* 1) Flip the sign bit to convert from S16 to U16 format + * 2) Construct a float in the range [256.0, 258.0) + * 3) Shift the float range to [-1.0, 1.0) + * dst[i] = i2f((src[i] ^ 0x8000) | 0x43800000) - 257.0 */ + const __m128i flipper = _mm_set1_epi16(-0x8000); + const __m128i caster = _mm_set1_epi16(0x4380 /* 0x43800000 = f2i(256.0) */); + const __m128 offset = _mm_set1_ps(-257.0f); LOG_DEBUG_CONVERT("AUDIO_S16", "AUDIO_F32 (using SSE2)"); - /* Get dst aligned to 16 bytes (since buffer is growing, we don't have to worry about overreading from src) */ - for (i = cvt->len_cvt / sizeof(Sint16); i && (((size_t)(dst - 7)) & 15); --i, --src, --dst) { - *dst = ((float)*src) * DIVBY32768; - } + while (i >= 16) { + i -= 16; - src -= 7; - dst -= 7; /* adjust to read SSE blocks from the start. */ - SDL_assert(!i || !(((size_t)dst) & 15)); + { + const __m128i shorts1 = _mm_xor_si128(_mm_loadu_si128((const __m128i *)&src[i]), flipper); + const __m128i shorts2 = _mm_xor_si128(_mm_loadu_si128((const __m128i *)&src[i + 8]), flipper); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 divby32768 = _mm_set1_ps(DIVBY32768); - while (i >= 8) { /* 8 * 16-bit */ - const __m128i ints = _mm_load_si128((__m128i const *)src); /* get 8 sint16 into an XMM register. */ - /* treat as int32, shift left to clear every other sint16, then back right with sign-extend. Now sint32. */ - const __m128i a = _mm_srai_epi32(_mm_slli_epi32(ints, 16), 16); - /* right-shift-sign-extend gets us sint32 with the other set of values. */ - const __m128i b = _mm_srai_epi32(ints, 16); - /* Interleave these back into the right order, convert to float, multiply, store. */ - _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpacklo_epi32(a, b)), divby32768)); - _mm_store_ps(dst + 4, _mm_mul_ps(_mm_cvtepi32_ps(_mm_unpackhi_epi32(a, b)), divby32768)); - i -= 8; - src -= 8; - dst -= 8; + const __m128 floats1 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts1, caster)), offset); + const __m128 floats2 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts1, caster)), offset); + const __m128 floats3 = _mm_add_ps(_mm_castsi128_ps(_mm_unpacklo_epi16(shorts2, caster)), offset); + const __m128 floats4 = _mm_add_ps(_mm_castsi128_ps(_mm_unpackhi_epi16(shorts2, caster)), offset); + + _mm_storeu_ps(&dst[i], floats1); + _mm_storeu_ps(&dst[i + 4], floats2); + _mm_storeu_ps(&dst[i + 8], floats3); + _mm_storeu_ps(&dst[i + 12], floats4); } } - src += 7; - dst += 7; /* adjust for any scalar finishing. */ - - /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float)*src) * DIVBY32768; - i--; - src--; - dst--; + --i; + _mm_store_ss(&dst[i], _mm_add_ss(_mm_castsi128_ps(_mm_cvtsi32_si128((Uint16)src[i] ^ 0x43808000u)), offset)); } cvt->len_cvt *= 2; @@ -520,38 +529,37 @@ static void SDLCALL SDL_Convert_S32_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm { const Sint32 *src = (const Sint32 *)cvt->buf; float *dst = (float *)cvt->buf; - int i; + int i = cvt->len_cvt / 4; + + /* dst[i] = f32(src[i]) / f32(0x80000000) */ + const __m128 scaler = _mm_set1_ps(DIVBY2147483648); LOG_DEBUG_CONVERT("AUDIO_S32", "AUDIO_F32 (using SSE2)"); - /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof(Sint32); i && (((size_t)dst) & 15); --i, ++src, ++dst) { - *dst = ((float)(*src >> 8)) * DIVBY8388607; - } + while (i >= 16) { + i -= 16; - SDL_assert(!i || !(((size_t)dst) & 15)); + { + const __m128i ints1 = _mm_loadu_si128((const __m128i *)&src[i]); + const __m128i ints2 = _mm_loadu_si128((const __m128i *)&src[i + 4]); + const __m128i ints3 = _mm_loadu_si128((const __m128i *)&src[i + 8]); + const __m128i ints4 = _mm_loadu_si128((const __m128i *)&src[i + 12]); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 divby8388607 = _mm_set1_ps(DIVBY8388607); - const __m128i *mmsrc = (const __m128i *)src; - while (i >= 4) { /* 4 * sint32 */ - /* shift out lowest bits so int fits in a float32. Small precision loss, but much faster. */ - _mm_store_ps(dst, _mm_mul_ps(_mm_cvtepi32_ps(_mm_srai_epi32(_mm_load_si128(mmsrc), 8)), divby8388607)); - i -= 4; - mmsrc++; - dst += 4; + const __m128 floats1 = _mm_mul_ps(_mm_cvtepi32_ps(ints1), scaler); + const __m128 floats2 = _mm_mul_ps(_mm_cvtepi32_ps(ints2), scaler); + const __m128 floats3 = _mm_mul_ps(_mm_cvtepi32_ps(ints3), scaler); + const __m128 floats4 = _mm_mul_ps(_mm_cvtepi32_ps(ints4), scaler); + + _mm_storeu_ps(&dst[i], floats1); + _mm_storeu_ps(&dst[i + 4], floats2); + _mm_storeu_ps(&dst[i + 8], floats3); + _mm_storeu_ps(&dst[i + 12], floats4); } - src = (const Sint32 *)mmsrc; } - /* Finish off any leftovers with scalar operations. */ while (i) { - *dst = ((float)(*src >> 8)) * DIVBY8388607; - i--; - src++; - dst++; + --i; + _mm_store_ss(&dst[i], _mm_mul_ss(_mm_cvt_si2ss(_mm_setzero_ps(), src[i]), scaler)); } if (cvt->filters[++cvt->filter_index]) { @@ -563,57 +571,47 @@ static void SDLCALL SDL_Convert_F32_to_S8_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma { const float *src = (const float *)cvt->buf; Sint8 *dst = (Sint8 *)cvt->buf; - int i; + int i = cvt->len_cvt / 4; + + /* 1) Shift the float range from [-1.0, 1.0] to [98303.0, 98305.0] + * 2) Extract the lowest 16 bits and clamp to [-128, 127] + * Overflow is correctly handled for inputs between roughly [-255.0, 255.0] + * dst[i] = clamp(i16(f2i(src[i] + 98304.0) & 0xFFFF), -128, 127) */ + const __m128 offset = _mm_set1_ps(98304.0f); + const __m128i mask = _mm_set1_epi16(0xFF); LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S8 (using SSE2)"); - /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 127; - } else if (sample <= -1.0f) { - *dst = -128; - } else { - *dst = (Sint8)(sample * 127.0f); - } - } + while (i >= 16) { + const __m128 floats1 = _mm_loadu_ps(&src[0]); + const __m128 floats2 = _mm_loadu_ps(&src[4]); + const __m128 floats3 = _mm_loadu_ps(&src[8]); + const __m128 floats4 = _mm_loadu_ps(&src[12]); - SDL_assert(!i || !(((size_t)dst) & 15)); + const __m128i ints1 = _mm_castps_si128(_mm_add_ps(floats1, offset)); + const __m128i ints2 = _mm_castps_si128(_mm_add_ps(floats2, offset)); + const __m128i ints3 = _mm_castps_si128(_mm_add_ps(floats3, offset)); + const __m128i ints4 = _mm_castps_si128(_mm_add_ps(floats4, offset)); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 one = _mm_set1_ps(1.0f); - const __m128 negone = _mm_set1_ps(-1.0f); - const __m128 mulby127 = _mm_set1_ps(127.0f); - __m128i *mmdst = (__m128i *)dst; - while (i >= 16) { /* 16 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packs_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ - i -= 16; - src += 16; - mmdst++; - } - dst = (Sint8 *)mmdst; + const __m128i shorts1 = _mm_and_si128(_mm_packs_epi16(ints1, ints2), mask); + const __m128i shorts2 = _mm_and_si128(_mm_packs_epi16(ints3, ints4), mask); + + const __m128i bytes = _mm_packus_epi16(shorts1, shorts2); + + _mm_storeu_si128((__m128i*)dst, bytes); + + i -= 16; + src += 16; + dst += 16; } - /* Finish off any leftovers with scalar operations. */ while (i) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 127; - } else if (sample <= -1.0f) { - *dst = -128; - } else { - *dst = (Sint8)(sample * 127.0f); - } - i--; - src++; - dst++; + const __m128i ints = _mm_castps_si128(_mm_add_ss(_mm_load_ss(src), offset)); + *dst = (Sint8)(_mm_cvtsi128_si32(_mm_packs_epi16(ints, ints)) & 0xFF); + + --i; + ++src; + ++dst; } cvt->len_cvt /= 4; @@ -626,57 +624,47 @@ static void SDLCALL SDL_Convert_F32_to_U8_SSE2(SDL_AudioCVT *cvt, SDL_AudioForma { const float *src = (const float *)cvt->buf; Uint8 *dst = cvt->buf; - int i; + int i = cvt->len_cvt / 4; + + /* 1) Shift the float range from [-1.0, 1.0] to [98304.0, 98306.0] + * 2) Extract the lowest 16 bits and clamp to [0, 255] + * Overflow is correctly handled for inputs between roughly [-254.0, 254.0] + * dst[i] = clamp(i16(f2i(src[i] + 98305.0) & 0xFFFF), 0, 255) */ + const __m128 offset = _mm_set1_ps(98305.0f); + const __m128i mask = _mm_set1_epi16(0xFF); LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_U8 (using SSE2)"); - /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 255; - } else if (sample <= -1.0f) { - *dst = 0; - } else { - *dst = (Uint8)((sample + 1.0f) * 127.0f); - } - } + while (i >= 16) { + const __m128 floats1 = _mm_loadu_ps(&src[0]); + const __m128 floats2 = _mm_loadu_ps(&src[4]); + const __m128 floats3 = _mm_loadu_ps(&src[8]); + const __m128 floats4 = _mm_loadu_ps(&src[12]); - SDL_assert(!i || !(((size_t)dst) & 15)); + const __m128i ints1 = _mm_castps_si128(_mm_add_ps(floats1, offset)); + const __m128i ints2 = _mm_castps_si128(_mm_add_ps(floats2, offset)); + const __m128i ints3 = _mm_castps_si128(_mm_add_ps(floats3, offset)); + const __m128i ints4 = _mm_castps_si128(_mm_add_ps(floats4, offset)); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 one = _mm_set1_ps(1.0f); - const __m128 negone = _mm_set1_ps(-1.0f); - const __m128 mulby127 = _mm_set1_ps(127.0f); - __m128i *mmdst = (__m128i *)dst; - while (i >= 16) { /* 16 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints3 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 8)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints4 = _mm_cvtps_epi32(_mm_mul_ps(_mm_add_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 12)), one), one), mulby127)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packus_epi16(_mm_packs_epi32(ints1, ints2), _mm_packs_epi32(ints3, ints4))); /* pack down, store out. */ - i -= 16; - src += 16; - mmdst++; - } - dst = (Uint8 *)mmdst; + const __m128i shorts1 = _mm_and_si128(_mm_packus_epi16(ints1, ints2), mask); + const __m128i shorts2 = _mm_and_si128(_mm_packus_epi16(ints3, ints4), mask); + + const __m128i bytes = _mm_packus_epi16(shorts1, shorts2); + + _mm_storeu_si128((__m128i*)dst, bytes); + + i -= 16; + src += 16; + dst += 16; } - /* Finish off any leftovers with scalar operations. */ while (i) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 255; - } else if (sample <= -1.0f) { - *dst = 0; - } else { - *dst = (Uint8)((sample + 1.0f) * 127.0f); - } - i--; - src++; - dst++; + const __m128i ints = _mm_castps_si128(_mm_add_ss(_mm_load_ss(src), offset)); + *dst = (Uint8)(_mm_cvtsi128_si32(_mm_packus_epi16(ints, ints)) & 0xFF); + + --i; + ++src; + ++dst; } cvt->len_cvt /= 4; @@ -689,55 +677,46 @@ static void SDLCALL SDL_Convert_F32_to_S16_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm { const float *src = (const float *)cvt->buf; Sint16 *dst = (Sint16 *)cvt->buf; - int i; + int i = cvt->len_cvt / 4; + + /* 1) Shift the float range from [-1.0, 1.0] to [256.0, 258.0] + * 2) Shift the int range from [0x43800000, 0x43810000] to [-32768,32768] + * 3) Clamp to range [-32768,32767] + * Overflow is correctly handled for inputs between roughly [-257.0, +inf) + * dst[i] = clamp(f2i(src[i] + 257.0) - 0x43808000, -32768, 32767) */ + const __m128 offset = _mm_set1_ps(257.0f); LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S16 (using SSE2)"); - /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 32767; - } else if (sample <= -1.0f) { - *dst = -32768; - } else { - *dst = (Sint16)(sample * 32767.0f); - } - } + while (i >= 16) { + const __m128 floats1 = _mm_loadu_ps(&src[0]); + const __m128 floats2 = _mm_loadu_ps(&src[4]); + const __m128 floats3 = _mm_loadu_ps(&src[8]); + const __m128 floats4 = _mm_loadu_ps(&src[12]); - SDL_assert(!i || !(((size_t)dst) & 15)); + const __m128i ints1 = _mm_sub_epi32(_mm_castps_si128(_mm_add_ps(floats1, offset)), _mm_castps_si128(offset)); + const __m128i ints2 = _mm_sub_epi32(_mm_castps_si128(_mm_add_ps(floats2, offset)), _mm_castps_si128(offset)); + const __m128i ints3 = _mm_sub_epi32(_mm_castps_si128(_mm_add_ps(floats3, offset)), _mm_castps_si128(offset)); + const __m128i ints4 = _mm_sub_epi32(_mm_castps_si128(_mm_add_ps(floats4, offset)), _mm_castps_si128(offset)); - /* Make sure src is aligned too. */ - if (!(((size_t)src) & 15)) { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 one = _mm_set1_ps(1.0f); - const __m128 negone = _mm_set1_ps(-1.0f); - const __m128 mulby32767 = _mm_set1_ps(32767.0f); - __m128i *mmdst = (__m128i *)dst; - while (i >= 8) { /* 8 * float32 */ - const __m128i ints1 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - const __m128i ints2 = _mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src + 4)), one), mulby32767)); /* load 4 floats, clamp, convert to sint32 */ - _mm_store_si128(mmdst, _mm_packs_epi32(ints1, ints2)); /* pack to sint16, store out. */ - i -= 8; - src += 8; - mmdst++; - } - dst = (Sint16 *)mmdst; + const __m128i shorts1 = _mm_packs_epi32(ints1, ints2); + const __m128i shorts2 = _mm_packs_epi32(ints3, ints4); + + _mm_storeu_si128((__m128i*)&dst[0], shorts1); + _mm_storeu_si128((__m128i*)&dst[8], shorts2); + + i -= 16; + src += 16; + dst += 16; } - /* Finish off any leftovers with scalar operations. */ while (i) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 32767; - } else if (sample <= -1.0f) { - *dst = -32768; - } else { - *dst = (Sint16)(sample * 32767.0f); - } - i--; - src++; - dst++; + const __m128i ints = _mm_sub_epi32(_mm_castps_si128(_mm_add_ss(_mm_load_ss(src), offset)), _mm_castps_si128(offset)); + *dst = (Sint16)(_mm_cvtsi128_si32(_mm_packs_epi32(ints, ints)) & 0xFFFF); + + --i; + ++src; + ++dst; } cvt->len_cvt /= 2; @@ -819,53 +798,51 @@ static void SDLCALL SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm { const float *src = (const float *)cvt->buf; Sint32 *dst = (Sint32 *)cvt->buf; - int i; + int i = cvt->len_cvt / 4; + + /* 1) Scale the float range from [-1.0, 1.0] to [-2147483648.0, 2147483648.0] + * 2) Convert to integer (values too small/large become 0x80000000 = -2147483648) + * 3) Fixup values which were too large (0x80000000 ^ 0xFFFFFFFF = 2147483647) + * dst[i] = i32(src[i] * 2147483648.0) ^ ((src[i] >= 2147483648.0) ? 0xFFFFFFFF : 0x00000000) */ + const __m128 limit = _mm_set1_ps(2147483648.0f); LOG_DEBUG_CONVERT("AUDIO_F32", "AUDIO_S32 (using SSE2)"); - /* Get dst aligned to 16 bytes */ - for (i = cvt->len_cvt / sizeof(float); i && (((size_t)dst) & 15); --i, ++src, ++dst) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 2147483647; - } else if (sample <= -1.0f) { - *dst = (Sint32)-2147483648LL; - } else { - *dst = ((Sint32)(sample * 8388607.0f)) << 8; - } - } + while (i >= 16) { + const __m128 floats1 = _mm_loadu_ps(&src[0]); + const __m128 floats2 = _mm_loadu_ps(&src[4]); + const __m128 floats3 = _mm_loadu_ps(&src[8]); + const __m128 floats4 = _mm_loadu_ps(&src[12]); - SDL_assert(!i || !(((size_t)dst) & 15)); - SDL_assert(!i || !(((size_t)src) & 15)); + const __m128 values1 = _mm_mul_ps(floats1, limit); + const __m128 values2 = _mm_mul_ps(floats2, limit); + const __m128 values3 = _mm_mul_ps(floats3, limit); + const __m128 values4 = _mm_mul_ps(floats4, limit); - { - /* Aligned! Do SSE blocks as long as we have 16 bytes available. */ - const __m128 one = _mm_set1_ps(1.0f); - const __m128 negone = _mm_set1_ps(-1.0f); - const __m128 mulby8388607 = _mm_set1_ps(8388607.0f); - __m128i *mmdst = (__m128i *)dst; - while (i >= 4) { /* 4 * float32 */ - _mm_store_si128(mmdst, _mm_slli_epi32(_mm_cvtps_epi32(_mm_mul_ps(_mm_min_ps(_mm_max_ps(negone, _mm_load_ps(src)), one), mulby8388607)), 8)); /* load 4 floats, clamp, convert to sint32 */ - i -= 4; - src += 4; - mmdst++; - } - dst = (Sint32 *)mmdst; + const __m128i ints1 = _mm_xor_si128(_mm_cvttps_epi32(values1), _mm_castps_si128(_mm_cmpge_ps(values1, limit))); + const __m128i ints2 = _mm_xor_si128(_mm_cvttps_epi32(values2), _mm_castps_si128(_mm_cmpge_ps(values2, limit))); + const __m128i ints3 = _mm_xor_si128(_mm_cvttps_epi32(values3), _mm_castps_si128(_mm_cmpge_ps(values3, limit))); + const __m128i ints4 = _mm_xor_si128(_mm_cvttps_epi32(values4), _mm_castps_si128(_mm_cmpge_ps(values4, limit))); + + _mm_storeu_si128((__m128i*)&dst[0], ints1); + _mm_storeu_si128((__m128i*)&dst[4], ints2); + _mm_storeu_si128((__m128i*)&dst[8], ints3); + _mm_storeu_si128((__m128i*)&dst[12], ints4); + + i -= 16; + src += 16; + dst += 16; } - /* Finish off any leftovers with scalar operations. */ while (i) { - const float sample = *src; - if (sample >= 1.0f) { - *dst = 2147483647; - } else if (sample <= -1.0f) { - *dst = (Sint32)-2147483648LL; - } else { - *dst = ((Sint32)(sample * 8388607.0f)) << 8; - } - i--; - src++; - dst++; + const __m128 floats = _mm_load_ss(src); + const __m128 values = _mm_mul_ss(floats, limit); + const __m128i ints = _mm_xor_si128(_mm_cvttps_epi32(values), _mm_castps_si128(_mm_cmpge_ss(values, limit))); + *dst = (Sint32)_mm_cvtsi128_si32(ints); + + --i; + ++src; + ++dst; } if (cvt->filters[++cvt->filter_index]) { @@ -874,7 +851,7 @@ static void SDLCALL SDL_Convert_F32_to_S32_SSE2(SDL_AudioCVT *cvt, SDL_AudioForm } #endif -#if HAVE_NEON_INTRINSICS +#ifdef HAVE_NEON_INTRINSICS static void SDLCALL SDL_Convert_S8_to_F32_NEON(SDL_AudioCVT *cvt, SDL_AudioFormat format) { const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1; @@ -1463,14 +1440,14 @@ void SDL_ChooseAudioConverters(void) SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \ converters_chosen = SDL_TRUE -#if HAVE_SSE2_INTRINSICS +#ifdef HAVE_SSE2_INTRINSICS if (SDL_HasSSE2()) { SET_CONVERTER_FUNCS(SSE2); return; } #endif -#if HAVE_NEON_INTRINSICS +#ifdef HAVE_NEON_INTRINSICS if (SDL_HasNEON()) { SET_CONVERTER_FUNCS(NEON); return; diff --git a/vs/sdl2/src/audio/SDL_mixer.c b/vs/sdl2/src/audio/SDL_mixer.c index 9a6a75ee1a..9cf96a6b3d 100644 --- a/vs/sdl2/src/audio/SDL_mixer.c +++ b/vs/sdl2/src/audio/SDL_mixer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_sysaudio.h b/vs/sdl2/src/audio/SDL_sysaudio.h index c755d43415..d569ba76a8 100644 --- a/vs/sdl2/src/audio/SDL_sysaudio.h +++ b/vs/sdl2/src/audio/SDL_sysaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/SDL_wave.c b/vs/sdl2/src/audio/SDL_wave.c index 209a577c07..1ecce9b917 100644 --- a/vs/sdl2/src/audio/SDL_wave.c +++ b/vs/sdl2/src/audio/SDL_wave.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -264,7 +264,7 @@ static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, U int res; dumpstr = SDL_malloc(bufsize); - if (dumpstr == NULL) { + if (!dumpstr) { return; } dumpstr[0] = 0; @@ -441,7 +441,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength) coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4); file->decoderdata = coeffdata; /* Freed in cleanup. */ - if (coeffdata == NULL) { + if (!coeffdata) { return SDL_OutOfMemory(); } coeffdata->coeff = &coeffdata->aligndummy; @@ -684,7 +684,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) state.output.pos = 0; state.output.size = outputsize / sizeof(Sint16); state.output.data = (Sint16 *)SDL_calloc(1, outputsize); - if (state.output.data == NULL) { + if (!state.output.data) { return SDL_OutOfMemory(); } @@ -1075,12 +1075,12 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len state.output.pos = 0; state.output.size = outputsize / sizeof(Sint16); state.output.data = (Sint16 *)SDL_malloc(outputsize); - if (state.output.data == NULL) { + if (!state.output.data) { return SDL_OutOfMemory(); } cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8)); - if (cstate == NULL) { + if (!cstate) { SDL_free(state.output.data); return SDL_OutOfMemory(); } @@ -1235,7 +1235,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); - if (src == NULL) { + if (!src) { return SDL_OutOfMemory(); } chunk->data = NULL; @@ -1366,7 +1366,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 * /* 1 to avoid allocating zero bytes, to keep static analysis happy. */ ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1); - if (ptr == NULL) { + if (!ptr) { return SDL_OutOfMemory(); } @@ -1438,11 +1438,11 @@ static int PCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len) return 0; } -static WaveRiffSizeHint WaveGetRiffSizeHint() +static WaveRiffSizeHint WaveGetRiffSizeHint(void) { const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "force") == 0) { return RiffSizeForce; } else if (SDL_strcmp(hint, "ignore") == 0) { @@ -1457,11 +1457,11 @@ static WaveRiffSizeHint WaveGetRiffSizeHint() return RiffSizeNoHint; } -static WaveTruncationHint WaveGetTruncationHint() +static WaveTruncationHint WaveGetTruncationHint(void) { const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "verystrict") == 0) { return TruncVeryStrict; } else if (SDL_strcmp(hint, "strict") == 0) { @@ -1476,11 +1476,11 @@ static WaveTruncationHint WaveGetTruncationHint() return TruncNoHint; } -static WaveFactChunkHint WaveGetFactChunkHint() +static WaveFactChunkHint WaveGetFactChunkHint(void) { const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "truncate") == 0) { return FactTruncate; } else if (SDL_strcmp(hint, "strict") == 0) { @@ -1497,7 +1497,7 @@ static WaveFactChunkHint WaveGetFactChunkHint() static void WaveFreeChunkData(WaveChunk *chunk) { - if (chunk->data != NULL) { + if (chunk->data) { SDL_free(chunk->data); chunk->data = NULL; } @@ -1546,7 +1546,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len if (length > 0) { chunk->data = (Uint8 *)SDL_malloc(length); - if (chunk->data == NULL) { + if (!chunk->data) { return SDL_OutOfMemory(); } @@ -1612,7 +1612,7 @@ static int WaveReadFormat(WaveFile *file) return SDL_SetError("Data of WAVE fmt chunk too big"); } fmtsrc = SDL_RWFromConstMem(chunk->data, (int)chunk->size); - if (fmtsrc == NULL) { + if (!fmtsrc) { return SDL_OutOfMemory(); } @@ -1787,7 +1787,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 * SDL_zero(datachunk); envchunkcountlimit = SDL_getenv("SDL_WAVE_CHUNK_LIMIT"); - if (envchunkcountlimit != NULL) { + if (envchunkcountlimit) { unsigned int count; if (SDL_sscanf(envchunkcountlimit, "%u", &count) == 1) { chunkcountlimit = count <= SDL_MAX_UINT32 ? count : SDL_MAX_UINT32; @@ -2085,16 +2085,16 @@ SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, SDL_zero(file); /* Make sure we are passed a valid data source */ - if (src == NULL) { + if (!src) { /* Error may come from RWops. */ return NULL; - } else if (spec == NULL) { + } else if (!spec) { SDL_InvalidParamError("spec"); return NULL; - } else if (audio_buf == NULL) { + } else if (!audio_buf) { SDL_InvalidParamError("audio_buf"); return NULL; - } else if (audio_len == NULL) { + } else if (!audio_len) { SDL_InvalidParamError("audio_len"); return NULL; } diff --git a/vs/sdl2/src/audio/SDL_wave.h b/vs/sdl2/src/audio/SDL_wave.h index 83acb44524..6d71e47dc7 100644 --- a/vs/sdl2/src/audio/SDL_wave.h +++ b/vs/sdl2/src/audio/SDL_wave.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/aaudio/SDL_aaudio.c b/vs/sdl2/src/audio/aaudio/SDL_aaudio.c index 8dfd16ce0d..401fef6a8b 100644 --- a/vs/sdl2/src/audio/aaudio/SDL_aaudio.c +++ b/vs/sdl2/src/audio/aaudio/SDL_aaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_AAUDIO +#ifdef SDL_AUDIO_DRIVER_AAUDIO #include "SDL_audio.h" #include "SDL_loadso.h" @@ -94,33 +94,29 @@ static int aaudio_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } private = this->hidden; ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq); ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels); - if(devname != NULL) { - int aaudio_device_id = SDL_atoi(devname); - LOGI("Opening device id %d", aaudio_device_id); - ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, aaudio_device_id); + if(devname) { + private->devid = SDL_atoi(devname); + LOGI("Opening device id %d", private->devid); + ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, private->devid); } { - aaudio_direction_t direction = (iscapture ? AAUDIO_DIRECTION_INPUT : AAUDIO_DIRECTION_OUTPUT); + const 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; - } + const aaudio_format_t format = (this->spec.format == AUDIO_S16SYS) ? AAUDIO_FORMAT_PCM_I16 : AAUDIO_FORMAT_PCM_FLOAT; ctx.AAudioStreamBuilder_setFormat(ctx.builder, format); } ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, private); + ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY); LOGI("AAudio Try to open %u hz %u bit chan %u %s samples %u", this->spec.freq, SDL_AUDIO_BITSIZE(this->spec.format), @@ -153,7 +149,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname) if (!iscapture) { private->mixlen = this->spec.size; private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen); - if (private->mixbuf == NULL) { + if (!private->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(private->mixbuf, this->spec.silence, this->spec.size); @@ -211,6 +207,97 @@ static Uint8 *aaudio_GetDeviceBuf(_THIS) return private->mixbuf; } +/* Try to reestablish an AAudioStream. + + This needs to get a stream with the same format as the previous one, + even if this means AAudio needs to handle a conversion it didn't when + we initially opened the device. If we can't get that, we are forced + to give up here. + + (This is more robust in SDL3, which is designed to handle + abrupt format changes.) +*/ +static int RebuildAAudioStream(SDL_AudioDevice *device) +{ + struct SDL_PrivateAudioData *hidden = device->hidden; + const SDL_bool iscapture = device->iscapture; + aaudio_result_t res; + + ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, device->spec.freq); + ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, device->spec.channels); + if(hidden->devid) { + LOGI("Reopening device id %d", hidden->devid); + ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, hidden->devid); + } + { + const aaudio_direction_t direction = (iscapture ? AAUDIO_DIRECTION_INPUT : AAUDIO_DIRECTION_OUTPUT); + ctx.AAudioStreamBuilder_setDirection(ctx.builder, direction); + } + { + const aaudio_format_t format = (device->spec.format == AUDIO_S16SYS) ? AAUDIO_FORMAT_PCM_I16 : AAUDIO_FORMAT_PCM_FLOAT; + ctx.AAudioStreamBuilder_setFormat(ctx.builder, format); + } + + ctx.AAudioStreamBuilder_setErrorCallback(ctx.builder, aaudio_errorCallback, hidden); + ctx.AAudioStreamBuilder_setPerformanceMode(ctx.builder, AAUDIO_PERFORMANCE_MODE_LOW_LATENCY); + + LOGI("AAudio Try to reopen %u hz %u bit chan %u %s samples %u", + device->spec.freq, SDL_AUDIO_BITSIZE(device->spec.format), + device->spec.channels, (device->spec.format & 0x1000) ? "BE" : "LE", device->spec.samples); + + res = ctx.AAudioStreamBuilder_openStream(ctx.builder, &hidden->stream); + if (res != AAUDIO_OK) { + LOGI("SDL Failed AAudioStreamBuilder_openStream %d", res); + return SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); + } + + { + const aaudio_format_t fmt = ctx.AAudioStream_getFormat(hidden->stream); + SDL_AudioFormat sdlfmt = (SDL_AudioFormat) 0; + if (fmt == AAUDIO_FORMAT_PCM_I16) { + sdlfmt = AUDIO_S16SYS; + } else if (fmt == AAUDIO_FORMAT_PCM_FLOAT) { + sdlfmt = AUDIO_F32SYS; + } + + /* We handle this better in SDL3, but this _needs_ to match the previous stream for SDL2. */ + if ( (device->spec.freq != ctx.AAudioStream_getSampleRate(hidden->stream)) || + (device->spec.channels != ctx.AAudioStream_getChannelCount(hidden->stream)) || + (device->spec.format != sdlfmt) ) { + LOGI("Didn't get an identical spec from AAudioStream during reopen!"); + ctx.AAudioStream_close(hidden->stream); + hidden->stream = NULL; + return SDL_SetError("Didn't get an identical spec from AAudioStream during reopen!"); + } + } + + res = ctx.AAudioStream_requestStart(hidden->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)); + } + + return 0; +} + +static int RecoverAAudioDevice(SDL_AudioDevice *device) +{ + struct SDL_PrivateAudioData *hidden = device->hidden; + AAudioStream *stream = hidden->stream; + + /* attempt to build a new stream, in case there's a new default device. */ + hidden->stream = NULL; + ctx.AAudioStream_requestStop(stream); + ctx.AAudioStream_close(stream); + + if (RebuildAAudioStream(device) < 0) { + return -1; // oh well, we tried. + } + + return 0; +} + + static void aaudio_PlayDevice(_THIS) { struct SDL_PrivateAudioData *private = this->hidden; @@ -219,6 +306,9 @@ static void aaudio_PlayDevice(_THIS) 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)); + if (RecoverAAudioDevice(this) < 0) { + return; /* oh well, we went down hard. */ + } } else { LOGI("SDL AAudio play: %d frames, wanted:%d frames", (int)res, private->mixlen / private->frame_size); } @@ -285,7 +375,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) SDL_zero(ctx); ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO); - if (ctx.handle == NULL) { + if (!ctx.handle) { LOGI("SDL couldn't find " LIB_AAUDIO_SO); goto failure; } @@ -300,7 +390,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) goto failure; } - if (ctx.builder == NULL) { + if (!ctx.builder) { LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL"); goto failure; } @@ -344,9 +434,9 @@ void aaudio_PauseDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { + SDL_LockMutex(audioDevice->mixer_lock); private = (struct SDL_PrivateAudioData *)audioDevice->hidden; - if (private->stream) { aaudio_result_t res = ctx.AAudioStream_requestPause(private->stream); if (res != AAUDIO_OK) { @@ -354,20 +444,11 @@ void aaudio_PauseDevices(void) 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) { + if (captureDevice && captureDevice->hidden) { + SDL_LockMutex(captureDevice->mixer_lock); 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); @@ -376,15 +457,6 @@ void aaudio_PauseDevices(void) 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; - } } } @@ -393,15 +465,8 @@ void aaudio_ResumeDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { 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) { @@ -409,17 +474,11 @@ void aaudio_ResumeDevices(void) SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); } } + SDL_UnlockMutex(audioDevice->mixer_lock); } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { 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) { @@ -427,6 +486,7 @@ void aaudio_ResumeDevices(void) SDL_SetError("%s : %s", __func__, ctx.AAudio_convertResultToText(res)); } } + SDL_UnlockMutex(captureDevice->mixer_lock); } } @@ -437,19 +497,24 @@ void aaudio_ResumeDevices(void) */ SDL_bool aaudio_DetectBrokenPlayState(void) { + AAudioStream *stream; struct SDL_PrivateAudioData *private; int64_t framePosition, timeNanoseconds; aaudio_result_t res; - if (audioDevice == NULL || !audioDevice->hidden) { + if (!audioDevice || !audioDevice->hidden) { return SDL_FALSE; } private = audioDevice->hidden; + stream = private->stream; + if (!stream) { + return SDL_FALSE; + } - res = ctx.AAudioStream_getTimestamp(private->stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds); + res = ctx.AAudioStream_getTimestamp(stream, CLOCK_MONOTONIC, &framePosition, &timeNanoseconds); if (res == AAUDIO_ERROR_INVALID_STATE) { - aaudio_stream_state_t currentState = ctx.AAudioStream_getState(private->stream); + aaudio_stream_state_t currentState = ctx.AAudioStream_getState(stream); /* AAudioStream_getTimestamp() will also return AAUDIO_ERROR_INVALID_STATE while the stream is still initially starting. But we only care if it silently went invalid while playing. */ if (currentState == AAUDIO_STREAM_STATE_STARTED) { LOGI("SDL aaudio_DetectBrokenPlayState: detected invalid audio device state: AAudioStream_getTimestamp result=%d, framePosition=%lld, timeNanoseconds=%lld, getState=%d", (int)res, (long long)framePosition, (long long)timeNanoseconds, (int)currentState); diff --git a/vs/sdl2/src/audio/aaudio/SDL_aaudio.h b/vs/sdl2/src/audio/aaudio/SDL_aaudio.h index d051e1ea29..d61d1b02b6 100644 --- a/vs/sdl2/src/audio/aaudio/SDL_aaudio.h +++ b/vs/sdl2/src/audio/aaudio/SDL_aaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +38,7 @@ struct SDL_PrivateAudioData Uint8 *mixbuf; int mixlen; int frame_size; - - /* Resume device if it was paused automatically */ - int resume; + int devid; }; void aaudio_ResumeDevices(void); diff --git a/vs/sdl2/src/audio/aaudio/SDL_aaudiofuncs.h b/vs/sdl2/src/audio/aaudio/SDL_aaudiofuncs.h index 3f0749ca6c..2bc674c038 100644 --- a/vs/sdl2/src/audio/aaudio/SDL_aaudiofuncs.h +++ b/vs/sdl2/src/audio/aaudio/SDL_aaudiofuncs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright , (C) 1997-2023 Sam Lantinga + Copyright , (C) 1997-2024 Sam Lantinga 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 @@ SDL_PROC(void, AAudioStreamBuilder_setFormat, (AAudioStreamBuilder * builder, aa 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(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 */ diff --git a/vs/sdl2/src/audio/alsa/SDL_alsa_audio.c b/vs/sdl2/src/audio/alsa/SDL_alsa_audio.c index c531613573..3ed66f2900 100644 --- a/vs/sdl2/src/audio/alsa/SDL_alsa_audio.c +++ b/vs/sdl2/src/audio/alsa/SDL_alsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_ALSA +#ifdef SDL_AUDIO_DRIVER_ALSA #ifndef SDL_ALSA_NON_BLOCKING #define SDL_ALSA_NON_BLOCKING 0 @@ -98,7 +98,7 @@ static void *alsa_handle = NULL; static int load_alsa_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(alsa_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -166,7 +166,7 @@ static int load_alsa_syms(void) static void UnloadALSALibrary(void) { - if (alsa_handle != NULL) { + if (alsa_handle) { SDL_UnloadObject(alsa_handle); alsa_handle = NULL; } @@ -175,9 +175,9 @@ static void UnloadALSALibrary(void) static int LoadALSALibrary(void) { int retval = 0; - if (alsa_handle == NULL) { + if (!alsa_handle) { alsa_handle = SDL_LoadObject(alsa_library); - if (alsa_handle == NULL) { + if (!alsa_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -208,13 +208,13 @@ static const char *get_audio_device(void *handle, const int channels) { const char *device; - if (handle != NULL) { + if (handle) { return (const char *)handle; } /* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */ device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ - if (device != NULL) { + if (device) { return device; } @@ -539,7 +539,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -687,7 +687,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); @@ -717,7 +717,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D char *handle = NULL; char *ptr; - if (dev == NULL) { + if (!dev) { return; } @@ -727,7 +727,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D Make sure not to free the storage associated with desc in this case */ if (hint) { desc = ALSA_snd_device_name_get_hint(hint, "DESC"); - if (desc == NULL) { + if (!desc) { SDL_free(dev); return; } @@ -741,14 +741,14 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D just chop the extra lines off, this seems to get a reasonable device name without extra details. */ ptr = SDL_strchr(desc, '\n'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } /*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/ handle = SDL_strdup(name); - if (handle == NULL) { + if (!handle) { if (hint) { free(desc); } @@ -800,7 +800,7 @@ static void ALSA_HotplugIteration(void) if we can find a preferred prefix for the system. */ for (i = 0; hints[i]; i++) { char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } @@ -829,20 +829,20 @@ static void ALSA_HotplugIteration(void) char *name; /* if we didn't find a device name prefix we like at all... */ - if ((match == NULL) && (defaultdev != i)) { + if ((!match) && (defaultdev != i)) { continue; /* ...skip anything that isn't the default device. */ } name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } /* only want physical hardware interfaces */ - if (match == NULL || (SDL_strncmp(name, match, match_len) == 0)) { + if (!match || (SDL_strncmp(name, match, match_len) == 0)) { char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID"); - const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0); - const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0); + const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0); + const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0); SDL_bool have_output = SDL_FALSE; SDL_bool have_input = SDL_FALSE; @@ -940,7 +940,7 @@ static void ALSA_Deinitialize(void) ALSA_Device *next; #if SDL_ALSA_HOTPLUG_THREAD - if (ALSA_hotplug_thread != NULL) { + if (ALSA_hotplug_thread) { SDL_AtomicSet(&ALSA_hotplug_shutdown, 1); SDL_WaitThread(ALSA_hotplug_thread, NULL); ALSA_hotplug_thread = NULL; diff --git a/vs/sdl2/src/audio/alsa/SDL_alsa_audio.h b/vs/sdl2/src/audio/alsa/SDL_alsa_audio.h index 1ce2e58888..fb3f154902 100644 --- a/vs/sdl2/src/audio/alsa/SDL_alsa_audio.h +++ b/vs/sdl2/src/audio/alsa/SDL_alsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/android/SDL_androidaudio.c b/vs/sdl2/src/audio/android/SDL_androidaudio.c index b46fdda093..8173686809 100644 --- a/vs/sdl2/src/audio/android/SDL_androidaudio.c +++ b/vs/sdl2/src/audio/android/SDL_androidaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_ANDROID +#ifdef SDL_AUDIO_DRIVER_ANDROID /* Output audio to Android */ @@ -51,7 +51,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -71,7 +71,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) { int audio_device_id = 0; - if (devname != NULL) { + if (devname) { audio_device_id = SDL_atoi(devname); } if (Android_JNI_OpenAudioDevice(iscapture, audio_device_id, &this->spec) < 0) { @@ -148,29 +148,12 @@ AudioBootStrap ANDROIDAUDIO_bootstrap = { void ANDROIDAUDIO_PauseDevices(void) { /* TODO: Handle multiple devices? */ - struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *)audioDevice->hidden; - 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 (audioDevice && audioDevice->hidden) { + SDL_LockMutex(audioDevice->mixer_lock); } - if (captureDevice != NULL && captureDevice->hidden != NULL) { - private = (struct SDL_PrivateAudioData *)captureDevice->hidden; - 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; - } + if (captureDevice && captureDevice->hidden) { + SDL_LockMutex(captureDevice->mixer_lock); } } @@ -178,23 +161,12 @@ void ANDROIDAUDIO_PauseDevices(void) void ANDROIDAUDIO_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 (audioDevice && audioDevice->hidden) { + SDL_UnlockMutex(audioDevice->mixer_lock); } - 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 (captureDevice && captureDevice->hidden) { + SDL_UnlockMutex(captureDevice->mixer_lock); } } diff --git a/vs/sdl2/src/audio/android/SDL_androidaudio.h b/vs/sdl2/src/audio/android/SDL_androidaudio.h index 4e103795ab..4e9df10f10 100644 --- a/vs/sdl2/src/audio/android/SDL_androidaudio.h +++ b/vs/sdl2/src/audio/android/SDL_androidaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +30,7 @@ struct SDL_PrivateAudioData { - /* Resume device if it was paused automatically */ - int resume; + int unused; }; void ANDROIDAUDIO_ResumeDevices(void); diff --git a/vs/sdl2/src/audio/arts/SDL_artsaudio.c b/vs/sdl2/src/audio/arts/SDL_artsaudio.c index ea4f3119b5..da91997a20 100644 --- a/vs/sdl2/src/audio/arts/SDL_artsaudio.c +++ b/vs/sdl2/src/audio/arts/SDL_artsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_ARTS +#ifdef SDL_AUDIO_DRIVER_ARTS /* Allow access to a raw mixing buffer */ @@ -88,7 +88,7 @@ static struct static void UnloadARTSLibrary() { - if (arts_handle != NULL) { + if (arts_handle) { SDL_UnloadObject(arts_handle); arts_handle = NULL; } @@ -98,9 +98,9 @@ static int LoadARTSLibrary(void) { int i, retval = -1; - if (arts_handle == NULL) { + if (!arts_handle) { arts_handle = SDL_LoadObject(arts_library); - if (arts_handle != NULL) { + if (arts_handle) { retval = 0; for (i = 0; i < SDL_arraysize(arts_functions); ++i) { *arts_functions[i].func = @@ -214,7 +214,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -281,7 +281,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -300,12 +300,12 @@ static void ARTS_Deinitialize(void) } -static SDL_bool ARTS_Init(SDL_AudioDriverImpl * impl) +static SDL_bool ARTS_Init(SDL_AudioDriverImpl *impl) { if (LoadARTSLibrary() < 0) { return SDL_FALSE; } else { - if (SDL_NAME(arts_init) () != NULL) { + if (SDL_NAME(arts_init) () != 0) { UnloadARTSLibrary(); SDL_SetError("ARTS: arts_init failed (no audio server?)"); return SDL_FALSE; diff --git a/vs/sdl2/src/audio/arts/SDL_artsaudio.h b/vs/sdl2/src/audio/arts/SDL_artsaudio.h index f2ccaea1ba..fe55bcd61d 100644 --- a/vs/sdl2/src/audio/arts/SDL_artsaudio.h +++ b/vs/sdl2/src/audio/arts/SDL_artsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.h b/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.h index 08b8cfbbc1..d5d11ca511 100644 --- a/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.h +++ b/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +26,10 @@ #include "../SDL_sysaudio.h" #if !defined(__IPHONEOS__) -#define MACOSX_COREAUDIO 1 +#define MACOSX_COREAUDIO #endif -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO #include #else #import @@ -40,7 +40,7 @@ #include /* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO #include #ifndef MAC_OS_VERSION_12_0 #define kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster @@ -62,7 +62,7 @@ struct SDL_PrivateAudioData AudioStreamBasicDescription strdesc; SDL_sem *ready_semaphore; char *thread_error; -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO AudioDeviceID deviceID; SDL_atomic_t device_change_flag; #else diff --git a/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.m b/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.m index 974fe86811..26da64d7ed 100644 --- a/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.m +++ b/vs/sdl2/src/audio/coreaudio/SDL_coreaudio.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_COREAUDIO +#ifdef SDL_AUDIO_DRIVER_COREAUDIO /* !!! FIXME: clean out some of the macro salsa in here. */ @@ -48,7 +48,7 @@ } #endif -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO static const AudioObjectPropertyAddress devlist_address = { kAudioHardwarePropertyDevices, kAudioObjectPropertyScopeGlobal, @@ -289,11 +289,11 @@ static OSStatus device_list_changed(AudioObjectID systemObj, UInt32 num_addr, co static int num_open_devices; static SDL_AudioDevice **open_devices; -#if !MACOSX_COREAUDIO +#ifndef MACOSX_COREAUDIO static BOOL session_active = NO; -static void pause_audio_devices() +static void pause_audio_devices(void) { int i; @@ -309,7 +309,7 @@ static void pause_audio_devices() } } -static void resume_audio_devices() +static void resume_audio_devices(void) { int i; @@ -532,6 +532,9 @@ static void outputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffe if (!SDL_AtomicGet(&this->enabled) || SDL_AtomicGet(&this->paused)) { /* Supply silence if audio is not enabled or paused */ SDL_memset(inBuffer->mAudioData, this->spec.silence, inBuffer->mAudioDataBytesCapacity); + if (this->stream) { + SDL_AudioStreamClear(this->stream); + } } else if (this->stream) { UInt32 remaining = inBuffer->mAudioDataBytesCapacity; Uint8 *ptr = (Uint8 *)inBuffer->mAudioData; @@ -627,7 +630,7 @@ static void inputCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBuffer AudioQueueEnqueueBuffer(this->hidden->audioQueue, inBuffer, 0, NULL); } -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO static const AudioObjectPropertyAddress alive_address = { kAudioDevicePropertyDeviceIsAlive, kAudioObjectPropertyScopeGlobal, @@ -681,7 +684,7 @@ static void COREAUDIO_CloseDevice(_THIS) /* !!! FIXME: what does iOS do when a bluetooth audio device vanishes? Headphones unplugged? */ /* !!! FIXME: (we only do a "default" device on iOS right now...can we do more?) */ -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO if (this->handle != NULL) { /* we don't register this listener for default devices. */ AudioObjectRemovePropertyListener(this->hidden->deviceID, &alive_address, device_unplugged, this); } @@ -708,7 +711,7 @@ static void COREAUDIO_CloseDevice(_THIS) open_playback_devices--; } -#if !MACOSX_COREAUDIO +#ifndef MACOSX_COREAUDIO update_audio_session(this, SDL_FALSE, SDL_TRUE); #endif @@ -737,7 +740,7 @@ static void COREAUDIO_CloseDevice(_THIS) SDL_free(this->hidden); } -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO static int prepare_device(_THIS) { void *handle = this->handle; @@ -830,7 +833,7 @@ static int prepare_audioqueue(_THIS) CHECK_RESULT("AudioQueueNewOutput"); } -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO if (!assign_device_to_audioqueue(this)) { return 0; } @@ -938,7 +941,7 @@ static int audioqueue_thread(void *arg) SDL_AudioDevice *this = (SDL_AudioDevice *)arg; int rc; -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO const AudioObjectPropertyAddress default_device_address = { this->iscapture ? kAudioHardwarePropertyDefaultInputDevice : kAudioHardwarePropertyDefaultOutputDevice, kAudioObjectPropertyScopeGlobal, @@ -966,7 +969,7 @@ static int audioqueue_thread(void *arg) while (!SDL_AtomicGet(&this->shutdown)) { CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.10, 1); -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO if ((this->handle == NULL) && SDL_AtomicGet(&this->hidden->device_change_flag)) { const AudioDeviceID prev_devid = this->hidden->deviceID; SDL_AtomicSet(&this->hidden->device_change_flag, 0); @@ -999,7 +1002,7 @@ output device (in which case we'll try again). */ CFRunLoopRunInMode(kCFRunLoopDefaultMode, secs, 0); } -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO if (this->handle == NULL) { /* we don't care if this fails; we just won't change to new default devices, but we still otherwise function in this case. */ AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &default_device_address, default_device_changed, this); @@ -1037,7 +1040,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname) open_devices[num_open_devices++] = this; } -#if !MACOSX_COREAUDIO +#ifndef MACOSX_COREAUDIO if (!update_audio_session(this, SDL_TRUE, SDL_TRUE)) { return -1; } @@ -1106,7 +1109,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname) strdesc->mBytesPerFrame = strdesc->mChannelsPerFrame * strdesc->mBitsPerChannel / 8; strdesc->mBytesPerPacket = strdesc->mBytesPerFrame * strdesc->mFramesPerPacket; -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO if (!prepare_device(this)) { return -1; } @@ -1134,7 +1137,7 @@ static int COREAUDIO_OpenDevice(_THIS, const char *devname) return (this->hidden->thread != NULL) ? 0 : -1; } -#if !MACOSX_COREAUDIO +#ifndef MACOSX_COREAUDIO static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { AVAudioSession *session = [AVAudioSession sharedInstance]; @@ -1272,7 +1275,7 @@ static int COREAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int i static void COREAUDIO_Deinitialize(void) { -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL); free_audio_device_list(&capture_devs); free_audio_device_list(&output_devs); @@ -1287,7 +1290,7 @@ static SDL_bool COREAUDIO_Init(SDL_AudioDriverImpl *impl) impl->Deinitialize = COREAUDIO_Deinitialize; impl->GetDefaultAudioInfo = COREAUDIO_GetDefaultAudioInfo; -#if MACOSX_COREAUDIO +#ifdef MACOSX_COREAUDIO impl->DetectDevices = COREAUDIO_DetectDevices; AudioObjectAddPropertyListener(kAudioObjectSystemObject, &devlist_address, device_list_changed, NULL); #else diff --git a/vs/sdl2/src/audio/directsound/SDL_directsound.c b/vs/sdl2/src/audio/directsound/SDL_directsound.c index a61a068f71..a98a1645f0 100644 --- a/vs/sdl2/src/audio/directsound/SDL_directsound.c +++ b/vs/sdl2/src/audio/directsound/SDL_directsound.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_DSOUND +#ifdef SDL_AUDIO_DRIVER_DSOUND /* Allow access to a raw mixing buffer */ @@ -30,7 +30,7 @@ #include "../SDL_audio_c.h" #include "SDL_directsound.h" #include -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H #include "../../core/windows/SDL_immdevice.h" #endif /* HAVE_MMDEVICEAPI_H */ @@ -39,7 +39,7 @@ #endif /* For Vista+, we can enumerate DSound devices with IMMDevice */ -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H static SDL_bool SupportsIMMDevice = SDL_FALSE; #endif /* HAVE_MMDEVICEAPI_H */ @@ -64,7 +64,7 @@ static void DSOUND_Unload(void) pDirectSoundCaptureCreate8 = NULL; pDirectSoundCaptureEnumerateW = NULL; - if (DSoundDLL != NULL) { + if (DSoundDLL) { SDL_UnloadObject(DSoundDLL); DSoundDLL = NULL; } @@ -77,7 +77,7 @@ static int DSOUND_Load(void) DSOUND_Unload(); DSoundDLL = SDL_LoadObject("DSOUND.DLL"); - if (DSoundDLL == NULL) { + if (!DSoundDLL) { SDL_SetError("DirectSound: failed to load DSOUND.DLL"); } else { /* Now make sure we have DirectX 8 or better... */ @@ -159,7 +159,7 @@ static void DSOUND_FreeDeviceHandle(void *handle) static int DSOUND_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) { -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { return SDL_IMMDevice_GetDefaultAudioInfo(name, spec, iscapture); } @@ -172,7 +172,7 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO const int iscapture = (int)((size_t)data); if (guid != NULL) { /* skip default device */ char *str = WIN_LookupAudioDeviceName(desc, guid); - if (str != NULL) { + if (str) { LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID)); SDL_memcpy(cpyguid, guid, sizeof(GUID)); @@ -189,14 +189,14 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO static void DSOUND_DetectDevices(void) { -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { SDL_IMMDevice_EnumerateEndpoints(SDL_TRUE); } else { #endif /* HAVE_MMDEVICEAPI_H */ pDirectSoundCaptureEnumerateW(FindAllDevs, (void *)((size_t)1)); pDirectSoundEnumerateW(FindAllDevs, (void *)((size_t)0)); -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H } #endif /* HAVE_MMDEVICEAPI_H*/ } @@ -379,18 +379,18 @@ static void DSOUND_FlushCapture(_THIS) static void DSOUND_CloseDevice(_THIS) { - if (this->hidden->mixbuf != NULL) { + if (this->hidden->mixbuf) { IDirectSoundBuffer_Stop(this->hidden->mixbuf); IDirectSoundBuffer_Release(this->hidden->mixbuf); } - if (this->hidden->sound != NULL) { + if (this->hidden->sound) { IDirectSound_Release(this->hidden->sound); } - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf); IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf); } - if (this->hidden->capture != NULL) { + if (this->hidden->capture) { IDirectSoundCapture_Release(this->hidden->capture); } SDL_free(this->hidden); @@ -493,7 +493,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -612,7 +612,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname) static void DSOUND_Deinitialize(void) { -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H if (SupportsIMMDevice) { SDL_IMMDevice_Quit(); SupportsIMMDevice = SDL_FALSE; @@ -627,7 +627,7 @@ static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl) return SDL_FALSE; } -#if HAVE_MMDEVICEAPI_H +#ifdef HAVE_MMDEVICEAPI_H SupportsIMMDevice = !(SDL_IMMDevice_Init() < 0); #endif /* HAVE_MMDEVICEAPI_H */ diff --git a/vs/sdl2/src/audio/directsound/SDL_directsound.h b/vs/sdl2/src/audio/directsound/SDL_directsound.h index 297769ef8f..051b9d7039 100644 --- a/vs/sdl2/src/audio/directsound/SDL_directsound.h +++ b/vs/sdl2/src/audio/directsound/SDL_directsound.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/disk/SDL_diskaudio.c b/vs/sdl2/src/audio/disk/SDL_diskaudio.c index e98dbea7e8..d9d4aae05b 100644 --- a/vs/sdl2/src/audio/disk/SDL_diskaudio.c +++ b/vs/sdl2/src/audio/disk/SDL_diskaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +20,11 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_DISK +#ifdef SDL_AUDIO_DRIVER_DISK /* Output raw audio data to a file. */ -#if HAVE_STDIO_H +#ifdef HAVE_STDIO_H #include #endif @@ -98,7 +98,7 @@ static void DISKAUDIO_FlushCapture(_THIS) static void DISKAUDIO_CloseDevice(_THIS) { - if (_this->hidden->io != NULL) { + if (_this->hidden->io) { SDL_RWclose(_this->hidden->io); } SDL_free(_this->hidden->mixbuf); @@ -107,9 +107,9 @@ static void DISKAUDIO_CloseDevice(_THIS) static const char *get_filename(const SDL_bool iscapture, const char *devname) { - if (devname == NULL) { + if (!devname) { devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); - if (devname == NULL) { + if (!devname) { devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE; } } @@ -126,12 +126,12 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) _this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*_this->hidden)); - if (_this->hidden == NULL) { + if (!_this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(_this->hidden); - if (envr != NULL) { + if (envr) { _this->hidden->io_delay = SDL_atoi(envr); } else { _this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq); @@ -139,14 +139,14 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) /* Open the audio device */ _this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); - if (_this->hidden->io == NULL) { + if (!_this->hidden->io) { return -1; } /* Allocate mixing buffer */ if (!iscapture) { _this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size); - if (_this->hidden->mixbuf == NULL) { + if (!_this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size); diff --git a/vs/sdl2/src/audio/disk/SDL_diskaudio.h b/vs/sdl2/src/audio/disk/SDL_diskaudio.h index f134820eac..8ae237f1ee 100644 --- a/vs/sdl2/src/audio/disk/SDL_diskaudio.h +++ b/vs/sdl2/src/audio/disk/SDL_diskaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/dsp/SDL_dspaudio.c b/vs/sdl2/src/audio/dsp/SDL_dspaudio.c index 441aa2574f..fdbad8fee9 100644 --- a/vs/sdl2/src/audio/dsp/SDL_dspaudio.c +++ b/vs/sdl2/src/audio/dsp/SDL_dspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_OSS +#ifdef SDL_AUDIO_DRIVER_OSS /* Allow access to a raw mixing buffer */ @@ -67,9 +67,9 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } @@ -86,7 +86,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -228,7 +228,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/vs/sdl2/src/audio/dsp/SDL_dspaudio.h b/vs/sdl2/src/audio/dsp/SDL_dspaudio.h index 78c94e4071..11214a52f6 100644 --- a/vs/sdl2/src/audio/dsp/SDL_dspaudio.h +++ b/vs/sdl2/src/audio/dsp/SDL_dspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/dummy/SDL_dummyaudio.c b/vs/sdl2/src/audio/dummy/SDL_dummyaudio.c index 9255e28a65..b17cd44acc 100644 --- a/vs/sdl2/src/audio/dummy/SDL_dummyaudio.c +++ b/vs/sdl2/src/audio/dummy/SDL_dummyaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 @@ */ #include "../../SDL_internal.h" +#ifdef SDL_AUDIO_DRIVER_DUMMY + /* Output audio to nowhere... */ #include "SDL_timer.h" @@ -61,4 +63,6 @@ AudioBootStrap DUMMYAUDIO_bootstrap = { "dummy", "SDL dummy audio driver", DUMMYAUDIO_Init, SDL_TRUE }; +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/audio/dummy/SDL_dummyaudio.h b/vs/sdl2/src/audio/dummy/SDL_dummyaudio.h index e93b5f94b2..500f5d97dd 100644 --- a/vs/sdl2/src/audio/dummy/SDL_dummyaudio.h +++ b/vs/sdl2/src/audio/dummy/SDL_dummyaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.c b/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.c index af5f095651..8d21dab597 100644 --- a/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_EMSCRIPTEN +#ifdef SDL_AUDIO_DRIVER_EMSCRIPTEN #include "SDL_audio.h" #include "../SDL_audio_c.h" @@ -70,7 +70,7 @@ static void HandleAudioProcess(_THIS) return; } - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ @@ -130,7 +130,7 @@ static void HandleCaptureProcess(_THIS) /* okay, we've got an interleaved float32 array in C now. */ - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ @@ -156,32 +156,28 @@ static void EMSCRIPTENAUDIO_CloseDevice(_THIS) var SDL2 = Module['SDL2']; if ($0) { if (SDL2.capture.silenceTimer !== undefined) { - clearTimeout(SDL2.capture.silenceTimer); + clearInterval(SDL2.capture.silenceTimer); } if (SDL2.capture.stream !== undefined) { var tracks = SDL2.capture.stream.getAudioTracks(); for (var i = 0; i < tracks.length; i++) { SDL2.capture.stream.removeTrack(tracks[i]); } - SDL2.capture.stream = undefined; } if (SDL2.capture.scriptProcessorNode !== undefined) { SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {}; SDL2.capture.scriptProcessorNode.disconnect(); - SDL2.capture.scriptProcessorNode = undefined; } if (SDL2.capture.mediaStreamNode !== undefined) { SDL2.capture.mediaStreamNode.disconnect(); - SDL2.capture.mediaStreamNode = undefined; - } - if (SDL2.capture.silenceBuffer !== undefined) { - SDL2.capture.silenceBuffer = undefined } SDL2.capture = undefined; } else { if (SDL2.audio.scriptProcessorNode != undefined) { SDL2.audio.scriptProcessorNode.disconnect(); - SDL2.audio.scriptProcessorNode = undefined; + } + if (SDL2.audio.silenceTimer !== undefined) { + clearInterval(SDL2.audio.silenceTimer); } SDL2.audio = undefined; } @@ -197,6 +193,8 @@ static void EMSCRIPTENAUDIO_CloseDevice(_THIS) #endif } +EM_JS_DEPS(sdlaudio, "$autoResumeAudioContext,$dynCall"); + static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) { SDL_AudioFormat test_format; @@ -225,7 +223,9 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) SDL2.audioContext = new webkitAudioContext(); } if (SDL2.audioContext) { - autoResumeAudioContext(SDL2.audioContext); + if ((typeof navigator.userActivation) === 'undefined') { // Firefox doesn't have this (as of August 2023), use autoResumeAudioContext instead. + autoResumeAudioContext(SDL2.audioContext); + } } } return SDL2.audioContext === undefined ? -1 : 0; @@ -294,8 +294,9 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) var have_microphone = function(stream) { //console.log('SDL audio capture: we have a microphone! Replacing silence callback.'); if (SDL2.capture.silenceTimer !== undefined) { - clearTimeout(SDL2.capture.silenceTimer); + clearInterval(SDL2.capture.silenceTimer); SDL2.capture.silenceTimer = undefined; + SDL2.capture.silenceBuffer = undefined } SDL2.capture.mediaStreamNode = SDL2.audioContext.createMediaStreamSource(stream); SDL2.capture.scriptProcessorNode = SDL2.audioContext.createScriptProcessor($1, $0, 1); @@ -322,7 +323,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) dynCall('vi', $2, [$3]); }; - SDL2.capture.silenceTimer = setTimeout(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); + SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); if ((navigator.mediaDevices !== undefined) && (navigator.mediaDevices.getUserMedia !== undefined)) { navigator.mediaDevices.getUserMedia({ audio: true, video: false }).then(have_microphone).catch(no_microphone); @@ -337,10 +338,37 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname) SDL2.audio.scriptProcessorNode = SDL2.audioContext['createScriptProcessor']($1, 0, $0); SDL2.audio.scriptProcessorNode['onaudioprocess'] = function (e) { if ((SDL2 === undefined) || (SDL2.audio === undefined)) { return; } + // if we're actually running the node, we don't need the fake callback anymore, so kill it. + if (SDL2.audio.silenceTimer !== undefined) { + clearInterval(SDL2.audio.silenceTimer); + SDL2.audio.silenceTimer = undefined; + SDL2.audio.silenceBuffer = undefined; + } SDL2.audio.currentOutputBuffer = e['outputBuffer']; dynCall('vi', $2, [$3]); }; + SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); + + if (SDL2.audioContext.state === 'suspended') { // uhoh, autoplay is blocked. + SDL2.audio.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate); + SDL2.audio.silenceBuffer.getChannelData(0).fill(0.0); + var silence_callback = function() { + if ((typeof navigator.userActivation) !== 'undefined') { // Almost everything modern except Firefox (as of August 2023) + if (navigator.userActivation.hasBeenActive) { + SDL2.audioContext.resume(); + } + } + + // the buffer that gets filled here just gets ignored, so the app can make progress + // and/or avoid flooding audio queues until we can actually play audio. + SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer; + dynCall('vi', $2, [$3]); + SDL2.audio.currentOutputBuffer = undefined; + }; + + SDL2.audio.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); + } }, this->spec.channels, this->spec.samples, HandleAudioProcess, this); } /* *INDENT-ON* */ /* clang-format on */ diff --git a/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.h b/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.h index 13cadcfc4d..54f605724c 100644 --- a/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.h +++ b/vs/sdl2/src/audio/emscripten/SDL_emscriptenaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/esd/SDL_esdaudio.c b/vs/sdl2/src/audio/esd/SDL_esdaudio.c index 800caaf0b8..596f51a330 100644 --- a/vs/sdl2/src/audio/esd/SDL_esdaudio.c +++ b/vs/sdl2/src/audio/esd/SDL_esdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_ESD +#ifdef SDL_AUDIO_DRIVER_ESD /* Allow access to an ESD network stream mixing buffer */ @@ -66,7 +66,7 @@ static struct static void UnloadESDLibrary() { - if (esd_handle != NULL) { + if (esd_handle) { SDL_UnloadObject(esd_handle); esd_handle = NULL; } @@ -76,7 +76,7 @@ static int LoadESDLibrary(void) { int i, retval = -1; - if (esd_handle == NULL) { + if (!esd_handle) { esd_handle = SDL_LoadObject(esd_library); if (esd_handle) { retval = 0; @@ -185,7 +185,7 @@ static char *get_progname(void) if (fp != NULL) { if (fgets(temp, sizeof(temp) - 1, fp)) { progname = SDL_strrchr(temp, '/'); - if (progname == NULL) { + if (!progname) { progname = temp; } else { progname = progname + 1; @@ -206,7 +206,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -264,7 +264,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/vs/sdl2/src/audio/esd/SDL_esdaudio.h b/vs/sdl2/src/audio/esd/SDL_esdaudio.h index 01ef9fb318..15e3d4e1dc 100644 --- a/vs/sdl2/src/audio/esd/SDL_esdaudio.h +++ b/vs/sdl2/src/audio/esd/SDL_esdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.c b/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.c index f79ab22f70..5abab2e7c1 100644 --- a/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.c +++ b/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_FUSIONSOUND +#ifdef SDL_AUDIO_DRIVER_FUSIONSOUND /* !!! FIXME: why is this is SDL_FS_* instead of FUSIONSOUND_*? */ @@ -79,7 +79,7 @@ static struct static void UnloadFusionSoundLibrary() { - if (fs_handle != NULL) { + if (fs_handle) { SDL_UnloadObject(fs_handle); fs_handle = NULL; } @@ -89,9 +89,9 @@ static int LoadFusionSoundLibrary(void) { int i, retval = -1; - if (fs_handle == NULL) { + if (!fs_handle) { fs_handle = SDL_LoadObject(fs_library); - if (fs_handle != NULL) { + if (fs_handle) { retval = 0; for (i = 0; i < SDL_arraysize(fs_functions); ++i) { *fs_functions[i].func = @@ -175,7 +175,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -250,7 +250,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.h b/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.h index fd18417610..556ea54c6f 100644 --- a/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.h +++ b/vs/sdl2/src/audio/fusionsound/SDL_fsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/haiku/SDL_haikuaudio.cc b/vs/sdl2/src/audio/haiku/SDL_haikuaudio.cc index ca946ed756..39b8d8ca7b 100644 --- a/vs/sdl2/src/audio/haiku/SDL_haikuaudio.cc +++ b/vs/sdl2/src/audio/haiku/SDL_haikuaudio.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_HAIKU +#ifdef SDL_AUDIO_DRIVER_HAIKU /* Allow access to the audio stream on Haiku */ @@ -59,7 +59,7 @@ static void FillSound(void *device, void *stream, size_t len, } else { SDL_assert(audio->spec.size == len); - if (audio->stream == NULL) { /* no conversion necessary. */ + if (!audio->stream) { /* no conversion necessary. */ callback(audio->callbackspec.userdata, (Uint8 *) stream, len); } else { /* streaming/converting */ const int stream_len = audio->callbackspec.size; diff --git a/vs/sdl2/src/audio/haiku/SDL_haikuaudio.h b/vs/sdl2/src/audio/haiku/SDL_haikuaudio.h index f40aae164e..9acb6e1b36 100644 --- a/vs/sdl2/src/audio/haiku/SDL_haikuaudio.h +++ b/vs/sdl2/src/audio/haiku/SDL_haikuaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/jack/SDL_jackaudio.c b/vs/sdl2/src/audio/jack/SDL_jackaudio.c index f9e942c57a..9be8799b4e 100644 --- a/vs/sdl2/src/audio/jack/SDL_jackaudio.c +++ b/vs/sdl2/src/audio/jack/SDL_jackaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_JACK +#ifdef SDL_AUDIO_DRIVER_JACK #include "SDL_timer.h" #include "SDL_audio.h" @@ -58,7 +58,7 @@ static void *jack_handle = NULL; static int load_jack_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(jack_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -73,7 +73,7 @@ static int load_jack_sym(const char *fn, void **addr) static void UnloadJackLibrary(void) { - if (jack_handle != NULL) { + if (jack_handle) { SDL_UnloadObject(jack_handle); jack_handle = NULL; } @@ -82,9 +82,9 @@ static void UnloadJackLibrary(void) static int LoadJackLibrary(void) { int retval = 0; - if (jack_handle == NULL) { + if (!jack_handle) { jack_handle = SDL_LoadObject(jack_library); - if (jack_handle == NULL) { + if (!jack_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -341,7 +341,7 @@ static int JACK_OpenDevice(_THIS, const char *devname) /* Build SDL's ports, which we will connect to the device ports. */ this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); - if (this->hidden->sdlports == NULL) { + if (!this->hidden->sdlports) { SDL_free(audio_ports); return SDL_OutOfMemory(); } @@ -400,7 +400,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl) /* Make sure a JACK server is running and available. */ jack_status_t status; jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL); - if (client == NULL) { + if (!client) { UnloadJackLibrary(); return SDL_FALSE; } diff --git a/vs/sdl2/src/audio/jack/SDL_jackaudio.h b/vs/sdl2/src/audio/jack/SDL_jackaudio.h index 3b58d7a81c..e0ac2e90bb 100644 --- a/vs/sdl2/src/audio/jack/SDL_jackaudio.h +++ b/vs/sdl2/src/audio/jack/SDL_jackaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.c b/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.c index ddf4e3aaeb..ea20a7ce3e 100644 --- a/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.c +++ b/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static SDL_AudioDevice *audio_device; static void FreePrivateData(_THIS); static int FindAudioFormat(_THIS); +/* fully local functions related to the wavebufs / DSP, not the same as the SDL-wide mixer lock */ static SDL_INLINE void contextLock(_THIS) { LightLock_Lock(&this->hidden->lock); @@ -48,16 +49,6 @@ static SDL_INLINE void contextUnlock(_THIS) LightLock_Unlock(&this->hidden->lock); } -static void N3DSAUD_LockAudio(_THIS) -{ - contextLock(this); -} - -static void N3DSAUD_UnlockAudio(_THIS) -{ - contextUnlock(this); -} - static void N3DSAUD_DspHook(DSP_HookType hook) { if (hook == DSPHOOK_ONCANCEL) { @@ -98,7 +89,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) float mix[12]; this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -136,14 +127,14 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS); - if (data_vaddr == NULL) { + if (!data_vaddr) { return SDL_OutOfMemory(); } @@ -195,6 +186,7 @@ static void N3DSAUDIO_PlayDevice(_THIS) { size_t nextbuf; size_t sampleLen; + contextLock(this); nextbuf = this->hidden->nextbuf; @@ -254,7 +246,7 @@ static void N3DSAUDIO_CloseDevice(_THIS) static void N3DSAUDIO_ThreadInit(_THIS) { - s32 current_priority; + s32 current_priority = 0x30; svcGetThreadPriority(¤t_priority, CUR_THREAD_HANDLE); current_priority--; /* 0x18 is reserved for video, 0x30 is the default for main thread */ @@ -271,8 +263,6 @@ static SDL_bool N3DSAUDIO_Init(SDL_AudioDriverImpl *impl) impl->GetDeviceBuf = N3DSAUDIO_GetDeviceBuf; impl->CloseDevice = N3DSAUDIO_CloseDevice; impl->ThreadInit = N3DSAUDIO_ThreadInit; - impl->LockDevice = N3DSAUD_LockAudio; - impl->UnlockDevice = N3DSAUD_UnlockAudio; impl->OnlyHasDefaultOutputDevice = SDL_TRUE; /* Should be possible, but micInit would fail */ diff --git a/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.h b/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.h index 7321f6c170..274e9f362e 100644 --- a/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.h +++ b/vs/sdl2/src/audio/n3ds/SDL_n3dsaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ /* Hidden "this" pointer for the audio functions */ #define _THIS SDL_AudioDevice *this -#define NUM_BUFFERS 2 /* -- Don't lower this! */ +#define NUM_BUFFERS 3 /* -- Minimum 2! */ struct SDL_PrivateAudioData { diff --git a/vs/sdl2/src/audio/nacl/SDL_naclaudio.c b/vs/sdl2/src/audio/nacl/SDL_naclaudio.c index cdb01bcb7b..f189256cb6 100644 --- a/vs/sdl2/src/audio/nacl/SDL_naclaudio.c +++ b/vs/sdl2/src/audio/nacl/SDL_naclaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_NACL +#ifdef SDL_AUDIO_DRIVER_NACL #include "SDL_naclaudio.h" @@ -62,7 +62,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta } else { SDL_assert(_this->spec.size == len); - if (_this->stream == NULL) { /* no conversion necessary. */ + if (!_this->stream) { /* no conversion necessary. */ callback(_this->callbackspec.userdata, stream, len); } else { /* streaming/converting */ const int stream_len = _this->callbackspec.size; @@ -103,7 +103,7 @@ static int NACLAUDIO_OpenDevice(_THIS, const char *devname) const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig(); private = (SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*private)); - if (private == NULL) { + if (!private) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/audio/nacl/SDL_naclaudio.h b/vs/sdl2/src/audio/nacl/SDL_naclaudio.h index 5ca01029e5..c08702be49 100644 --- a/vs/sdl2/src/audio/nacl/SDL_naclaudio.h +++ b/vs/sdl2/src/audio/nacl/SDL_naclaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/nas/SDL_nasaudio.c b/vs/sdl2/src/audio/nas/SDL_nasaudio.c index d6807203d8..f3eb68f33b 100644 --- a/vs/sdl2/src/audio/nas/SDL_nasaudio.c +++ b/vs/sdl2/src/audio/nas/SDL_nasaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_NAS +#ifdef SDL_AUDIO_DRIVER_NAS /* Allow access to a raw mixing buffer */ @@ -59,7 +59,7 @@ static void *nas_handle = NULL; static int load_nas_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(nas_handle, fn); - if (*addr == NULL) { + if (!*addr) { return 0; } return 1; @@ -94,7 +94,7 @@ static int load_nas_syms(void) static void UnloadNASLibrary(void) { - if (nas_handle != NULL) { + if (nas_handle) { SDL_UnloadObject(nas_handle); nas_handle = NULL; } @@ -103,9 +103,9 @@ static void UnloadNASLibrary(void) static int LoadNASLibrary(void) { int retval = 0; - if (nas_handle == NULL) { + if (!nas_handle) { nas_handle = SDL_LoadObject(nas_library); - if (nas_handle == NULL) { + if (!nas_handle) { /* Copy error string so we can use it in a new SDL_SetError(). */ const char *origerr = SDL_GetError(); const size_t len = SDL_strlen(origerr) + 1; @@ -305,7 +305,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -389,7 +389,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -410,7 +410,7 @@ static SDL_bool NAS_Init(SDL_AudioDriverImpl * impl) return SDL_FALSE; } else { AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL); - if (aud == NULL) { + if (!aud) { SDL_SetError("NAS: AuOpenServer() failed (no audio server?)"); return SDL_FALSE; } diff --git a/vs/sdl2/src/audio/nas/SDL_nasaudio.h b/vs/sdl2/src/audio/nas/SDL_nasaudio.h index af191e41c8..0275c06d60 100644 --- a/vs/sdl2/src/audio/nas/SDL_nasaudio.h +++ b/vs/sdl2/src/audio/nas/SDL_nasaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.c b/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.c index d90f28a943..cc515995ba 100644 --- a/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.c +++ b/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_NETBSD +#ifdef SDL_AUDIO_DRIVER_NETBSD /* * Driver for native NetBSD audio(4). @@ -202,16 +202,16 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -296,7 +296,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.h b/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.h index c863bb5ab6..81fd4e6d00 100644 --- a/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.h +++ b/vs/sdl2/src/audio/netbsd/SDL_netbsdaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/openslES/SDL_openslES.c b/vs/sdl2/src/audio/openslES/SDL_openslES.c index 998104c24c..d93fb5ac1f 100644 --- a/vs/sdl2/src/audio/openslES/SDL_openslES.c +++ b/vs/sdl2/src/audio/openslES/SDL_openslES.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_OPENSLES +#ifdef SDL_AUDIO_DRIVER_OPENSLES /* For more discussion of low latency audio on Android, see this: https://googlesamples.github.io/android-audio-high-performance/guides/opensl_es.html @@ -320,7 +320,7 @@ static int openslES_CreatePCMRecorder(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -566,7 +566,7 @@ static int openslES_CreatePCMPlayer(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -591,7 +591,7 @@ static int openslES_CreatePCMPlayer(_THIS) static int openslES_OpenDevice(_THIS, const char *devname) { this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/audio/openslES/SDL_openslES.h b/vs/sdl2/src/audio/openslES/SDL_openslES.h index 01464b7e50..b9943d89d7 100644 --- a/vs/sdl2/src/audio/openslES/SDL_openslES.h +++ b/vs/sdl2/src/audio/openslES/SDL_openslES.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/os2/SDL_os2audio.c b/vs/sdl2/src/audio/os2/SDL_os2audio.c index 2f1e6bc663..c61c641c84 100644 --- a/vs/sdl2/src/audio/os2/SDL_os2audio.c +++ b/vs/sdl2/src/audio/os2/SDL_os2audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_OS2 +#ifdef SDL_AUDIO_DRIVER_OS2 /* Allow access to a raw mixing buffer */ @@ -43,7 +43,7 @@ static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault) char* end; char* envval = SDL_getenv(name); - if (envval == NULL) + if (!envval) return ulDefault; ulValue = SDL_strtoul(envval, &end, 10); @@ -351,7 +351,7 @@ static void OS2_CloseDevice(_THIS) debug_os2("Enter"); - if (pAData == NULL) + if (!pAData) return; pAData->ulState = 2; @@ -429,7 +429,7 @@ static int OS2_OpenDevice(_THIS, const char *devname) } pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); - if (pAData == NULL) + if (!pAData) return SDL_OutOfMemory(); _this->hidden = pAData; diff --git a/vs/sdl2/src/audio/os2/SDL_os2audio.h b/vs/sdl2/src/audio/os2/SDL_os2audio.h index fb6a832b67..41f091fa0b 100644 --- a/vs/sdl2/src/audio/os2/SDL_os2audio.h +++ b/vs/sdl2/src/audio/os2/SDL_os2audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/paudio/SDL_paudio.c b/vs/sdl2/src/audio/paudio/SDL_paudio.c index 5c5c36fc29..b82ec8e97d 100644 --- a/vs/sdl2/src/audio/paudio/SDL_paudio.c +++ b/vs/sdl2/src/audio/paudio/SDL_paudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_PAUDIO +#ifdef SDL_AUDIO_DRIVER_PAUDIO /* Allow access to a raw mixing buffer */ @@ -78,11 +78,11 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags) if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { return -1; } fd = open(audiodev, flags, 0); - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } @@ -110,7 +110,7 @@ static int OpenAudioPath(char *path, int maxlen, int flags, int classic) if (stat(audiopath, &sb) == 0) { fd = open(audiopath, flags, 0); if (fd >= 0) { - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiopath, maxlen); } return fd; @@ -232,7 +232,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -403,7 +403,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -445,7 +445,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) } /* Check to see if we need to use SDL_IOReady() workaround */ - if (workaround != NULL) { + if (workaround) { this->hidden->frame_ticks = (float) (this->spec.samples * 1000) / this->spec.freq; this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; diff --git a/vs/sdl2/src/audio/paudio/SDL_paudio.h b/vs/sdl2/src/audio/paudio/SDL_paudio.h index 1646b03da2..7c870ca9bc 100644 --- a/vs/sdl2/src/audio/paudio/SDL_paudio.h +++ b/vs/sdl2/src/audio/paudio/SDL_paudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/pipewire/SDL_pipewire.c b/vs/sdl2/src/audio/pipewire/SDL_pipewire.c index f9694334d9..4fbe9af919 100644 --- a/vs/sdl2/src/audio/pipewire/SDL_pipewire.c +++ b/vs/sdl2/src/audio/pipewire/SDL_pipewire.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../../SDL_internal.h" #include "SDL_hints.h" -#if SDL_AUDIO_DRIVER_PIPEWIRE +#ifdef SDL_AUDIO_DRIVER_PIPEWIRE #include "SDL_audio.h" #include "SDL_loadso.h" @@ -129,7 +129,7 @@ static void *pipewire_handle = NULL; static int pipewire_dlsym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pipewire_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -145,7 +145,7 @@ static int pipewire_dlsym(const char *fn, void **addr) static int load_pipewire_library() { pipewire_handle = SDL_LoadObject(pipewire_library); - return pipewire_handle != NULL ? 0 : -1; + return pipewire_handle ? 0 : -1; } static void unload_pipewire_library() @@ -347,10 +347,10 @@ static void io_list_sort() /* Find and move the default nodes to the beginning of the list */ spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { - if (pipewire_default_sink_id != NULL && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { + if (pipewire_default_sink_id && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { default_sink = n; spa_list_remove(&n->link); - } else if (pipewire_default_source_id != NULL && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { + } else if (pipewire_default_source_id && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { default_source = n; spa_list_remove(&n->link); } @@ -399,7 +399,7 @@ static struct io_node *io_list_get_by_path(char *path) static void node_object_destroy(struct node_object *node) { - SDL_assert(node); + SDL_assert(node != NULL); spa_list_remove(&node->link); spa_hook_remove(&node->node_listener); @@ -411,7 +411,7 @@ static void node_object_destroy(struct node_object *node) /* The pending node list */ static void pending_list_add(struct node_object *node) { - SDL_assert(node); + SDL_assert(node != NULL); spa_list_append(&hotplug_pending_list, &node->link); } @@ -442,7 +442,7 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const /* Create the proxy object */ proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object)); - if (proxy == NULL) { + if (!proxy) { SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno); return NULL; } @@ -648,15 +648,15 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons { struct node_object *node = object; - if (subject == PW_ID_CORE && key != NULL && value != NULL) { + if (subject == PW_ID_CORE && key && value) { if (!SDL_strcmp(key, "default.audio.sink")) { - if (pipewire_default_sink_id != NULL) { + if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); } pipewire_default_sink_id = get_name_from_json(value); node->persist = SDL_TRUE; } else if (!SDL_strcmp(key, "default.audio.source")) { - if (pipewire_default_source_id != NULL) { + if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); } pipewire_default_source_id = get_name_from_json(value); @@ -701,7 +701,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p if (node_desc && node_path) { node = node_object_new(id, type, version, &interface_node_events, &interface_core_events); - if (node == NULL) { + if (!node) { SDL_SetError("Pipewire: Failed to allocate interface node"); return; } @@ -710,7 +710,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p desc_buffer_len = SDL_strlen(node_desc) + 1; path_buffer_len = SDL_strlen(node_path) + 1; node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len); - if (io == NULL) { + if (!io) { node_object_destroy(node); SDL_OutOfMemory(); return; @@ -731,7 +731,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p } } 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) { + if (!node) { SDL_SetError("Pipewire: Failed to allocate metadata node"); return; } @@ -759,22 +759,22 @@ static int hotplug_loop_init() spa_list_init(&hotplug_io_list); hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL); - if (hotplug_loop == NULL) { + if (!hotplug_loop) { 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) { + if (!hotplug_context) { 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) { + if (!hotplug_core) { 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) { + if (!hotplug_registry) { return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno); } @@ -806,11 +806,11 @@ static void hotplug_loop_destroy() hotplug_init_complete = SDL_FALSE; hotplug_events_enabled = SDL_FALSE; - if (pipewire_default_sink_id != NULL) { + if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); pipewire_default_sink_id = NULL; } - if (pipewire_default_source_id != NULL) { + if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); pipewire_default_source_id = NULL; } @@ -961,7 +961,7 @@ static void output_callback(void *data) /* See if a buffer is available */ pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } @@ -1025,13 +1025,13 @@ static void input_callback(void *data) } pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } spa_buf = pw_buf->buffer; (src = (Uint8 *)spa_buf->datas[0].data); - if (src == NULL) { + if (!src) { return; } @@ -1079,7 +1079,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer) this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride; this->spec.size = buffer->buffer->datas[0].maxsize; } - } else if (this->hidden->buffer == NULL) { + } else if (!this->hidden->buffer) { /* * The latency of source nodes can change, so buffering is always required. * @@ -1137,7 +1137,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) struct SDL_PrivateAudioData *priv; struct pw_properties *props; const char *app_name, *stream_name, *stream_role, *error; - Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); + Uint32 node_id = !this->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); SDL_bool iscapture = this->iscapture; int res; @@ -1146,15 +1146,15 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) /* Get the hints for the application name, stream name and role */ app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME); - if (app_name == NULL || *app_name == '\0') { + if (!app_name || *app_name == '\0') { app_name = SDL_GetHint(SDL_HINT_APP_NAME); - if (app_name == NULL || *app_name == '\0') { + if (!app_name || *app_name == '\0') { app_name = "SDL Application"; } } stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); - if (stream_name == NULL || *stream_name == '\0') { + if (!stream_name || *stream_name == '\0') { stream_name = "Audio Stream"; } @@ -1163,20 +1163,20 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) * but 'Game' seems more appropriate for the majority of SDL applications. */ stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE); - if (stream_role == NULL || *stream_role == '\0') { + 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) { + if (!params) { return SDL_SetError("Pipewire: Failed to set audio format parameters"); } priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); this->hidden = priv; - if (priv == NULL) { + if (!priv) { return SDL_OutOfMemory(); } @@ -1190,23 +1190,23 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) (void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle); priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL); - if (priv->loop == NULL) { + if (!priv->loop) { return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno); } /* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */ props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno); } priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0); - if (priv->context == NULL) { + if (!priv->context) { return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno); } props = PIPEWIRE_pw_properties_new(NULL, NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno); } @@ -1232,7 +1232,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) PIPEWIRE_pw_thread_loop_lock(hotplug_loop); node = io_list_get_by_id(node_id); - if (node != NULL) { + if (node) { PIPEWIRE_pw_properties_set(props, PW_KEY_TARGET_OBJECT, node->path); } PIPEWIRE_pw_thread_loop_unlock(hotplug_loop); @@ -1244,7 +1244,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) /* Create the new stream */ 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) { + if (!priv->stream) { return SDL_SetError("Pipewire: Failed to create stream (%i)", errno); } @@ -1272,7 +1272,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) } /* If this is a capture stream, make sure the intermediate buffer was successfully allocated. */ - if (iscapture && priv->buffer == NULL) { + if (iscapture && !priv->buffer) { return SDL_SetError("Pipewire: Failed to allocate source buffer"); } @@ -1313,13 +1313,13 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is PIPEWIRE_pw_thread_loop_lock(hotplug_loop); if (iscapture) { - if (pipewire_default_source_id == NULL) { + if (!pipewire_default_source_id) { ret = SDL_SetError("PipeWire could not find a default source"); goto failed; } target = pipewire_default_source_id; } else { - if (pipewire_default_sink_id == NULL) { + if (!pipewire_default_sink_id) { ret = SDL_SetError("PipeWire could not find a default sink"); goto failed; } @@ -1327,12 +1327,12 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is } node = io_list_get_by_path(target); - if (node == NULL) { + if (!node) { ret = SDL_SetError("PipeWire device list is out of sync with defaults"); goto failed; } - if (name != NULL) { + if (name) { *name = SDL_strdup(node->name); } SDL_copyp(spec, &node->spec); diff --git a/vs/sdl2/src/audio/pipewire/SDL_pipewire.h b/vs/sdl2/src/audio/pipewire/SDL_pipewire.h index 0f706a2be2..cf5817b1ac 100644 --- a/vs/sdl2/src/audio/pipewire/SDL_pipewire.h +++ b/vs/sdl2/src/audio/pipewire/SDL_pipewire.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/ps2/SDL_ps2audio.c b/vs/sdl2/src/audio/ps2/SDL_ps2audio.c index ffbf6c5cf1..da5c5d3284 100644 --- a/vs/sdl2/src/audio/ps2/SDL_ps2audio.c +++ b/vs/sdl2/src/audio/ps2/SDL_ps2audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -90,7 +90,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) 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) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -129,7 +129,7 @@ static void PS2AUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/vs/sdl2/src/audio/ps2/SDL_ps2audio.h b/vs/sdl2/src/audio/ps2/SDL_ps2audio.h index 0f0223cbcc..5f5989dc62 100644 --- a/vs/sdl2/src/audio/ps2/SDL_ps2audio.h +++ b/vs/sdl2/src/audio/ps2/SDL_ps2audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/psp/SDL_pspaudio.c b/vs/sdl2/src/audio/psp/SDL_pspaudio.c index 3b0156489a..30e1c234f0 100644 --- a/vs/sdl2/src/audio/psp/SDL_pspaudio.c +++ b/vs/sdl2/src/audio/psp/SDL_pspaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_PSP +#ifdef SDL_AUDIO_DRIVER_PSP #include #include @@ -52,7 +52,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -108,7 +108,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) 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) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -156,7 +156,7 @@ static void PSPAUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/vs/sdl2/src/audio/psp/SDL_pspaudio.h b/vs/sdl2/src/audio/psp/SDL_pspaudio.h index 943e9a38bf..ba351025da 100644 --- a/vs/sdl2/src/audio/psp/SDL_pspaudio.h +++ b/vs/sdl2/src/audio/psp/SDL_pspaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.c b/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.c index 27c6e755ea..5e2bb6f160 100644 --- a/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,16 +19,10 @@ 3. This notice may not be removed or altered from any source distribution. */ -/* - The PulseAudio target for SDL 1.3 is based on the 1.3 arts target, with - the appropriate parts replaced with the 1.2 PulseAudio target code. This - was the cleanest way to move it to 1.3. The 1.2 target was written by - Stéphan Kochen: stephan .a.t. kochen.nl -*/ #include "../../SDL_internal.h" #include "SDL_hints.h" -#if SDL_AUDIO_DRIVER_PULSEAUDIO +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO /* Allow access to a raw mixing buffer */ @@ -37,7 +31,6 @@ #endif #include #include -#include #include "SDL_timer.h" #include "SDL_audio.h" @@ -49,29 +42,34 @@ /* should we include monitors in the device list? Set at SDL_Init time */ static SDL_bool include_monitors = SDL_FALSE; -#if (PA_API_VERSION < 12) -/** Return non-zero if the passed state is one of the connected states */ -static SDL_INLINE int PA_CONTEXT_IS_GOOD(pa_context_state_t x) -{ - return x == PA_CONTEXT_CONNECTING || x == PA_CONTEXT_AUTHORIZING || x == PA_CONTEXT_SETTING_NAME || x == PA_CONTEXT_READY; -} -/** Return non-zero if the passed state is one of the connected states */ -static SDL_INLINE int PA_STREAM_IS_GOOD(pa_stream_state_t x) -{ - return x == PA_STREAM_CREATING || x == PA_STREAM_READY; -} -#endif /* pulseaudio <= 0.9.10 */ +static pa_threaded_mainloop *pulseaudio_threaded_mainloop = NULL; +static pa_context *pulseaudio_context = NULL; +static SDL_Thread *pulseaudio_hotplug_thread = NULL; +static SDL_atomic_t pulseaudio_hotplug_thread_active; + +/* These are the OS identifiers (i.e. ALSA strings)... */ +static char *default_sink_path = NULL; +static char *default_source_path = NULL; +/* ... and these are the descriptions we use in GetDefaultAudioInfo. */ +static char *default_sink_name = NULL; +static char *default_source_name = NULL; + static const char *(*PULSEAUDIO_pa_get_library_version)(void); static pa_channel_map *(*PULSEAUDIO_pa_channel_map_init_auto)( pa_channel_map *, unsigned, pa_channel_map_def_t); static const char *(*PULSEAUDIO_pa_strerror)(int); -static pa_mainloop *(*PULSEAUDIO_pa_mainloop_new)(void); -static pa_mainloop_api *(*PULSEAUDIO_pa_mainloop_get_api)(pa_mainloop *); -static int (*PULSEAUDIO_pa_mainloop_iterate)(pa_mainloop *, int, int *); -static int (*PULSEAUDIO_pa_mainloop_run)(pa_mainloop *, int *); -static void (*PULSEAUDIO_pa_mainloop_quit)(pa_mainloop *, int); -static void (*PULSEAUDIO_pa_mainloop_free)(pa_mainloop *); + +static pa_threaded_mainloop *(*PULSEAUDIO_pa_threaded_mainloop_new)(void); +static void (*PULSEAUDIO_pa_threaded_mainloop_set_name)(pa_threaded_mainloop *, const char *); +static pa_mainloop_api *(*PULSEAUDIO_pa_threaded_mainloop_get_api)(pa_threaded_mainloop *); +static int (*PULSEAUDIO_pa_threaded_mainloop_start)(pa_threaded_mainloop *); +static void (*PULSEAUDIO_pa_threaded_mainloop_stop)(pa_threaded_mainloop *); +static void (*PULSEAUDIO_pa_threaded_mainloop_lock)(pa_threaded_mainloop *); +static void (*PULSEAUDIO_pa_threaded_mainloop_unlock)(pa_threaded_mainloop *); +static void (*PULSEAUDIO_pa_threaded_mainloop_wait)(pa_threaded_mainloop *); +static void (*PULSEAUDIO_pa_threaded_mainloop_signal)(pa_threaded_mainloop *, int); +static void (*PULSEAUDIO_pa_threaded_mainloop_free)(pa_threaded_mainloop *); static pa_operation_state_t (*PULSEAUDIO_pa_operation_get_state)( const pa_operation *); @@ -80,6 +78,7 @@ static void (*PULSEAUDIO_pa_operation_unref)(pa_operation *); static pa_context *(*PULSEAUDIO_pa_context_new)(pa_mainloop_api *, const char *); +static void (*PULSEAUDIO_pa_context_set_state_callback)(pa_context *, pa_context_notify_cb_t, void *); static int (*PULSEAUDIO_pa_context_connect)(pa_context *, const char *, pa_context_flags_t, const pa_spawn_api *); static pa_operation *(*PULSEAUDIO_pa_context_get_sink_info_list)(pa_context *, pa_sink_info_cb_t, void *); @@ -94,6 +93,7 @@ static void (*PULSEAUDIO_pa_context_unref)(pa_context *); static pa_stream *(*PULSEAUDIO_pa_stream_new)(pa_context *, const char *, const pa_sample_spec *, const pa_channel_map *); +static void (*PULSEAUDIO_pa_stream_set_state_callback)(pa_stream *, pa_stream_notify_cb_t, void *); static int (*PULSEAUDIO_pa_stream_connect_playback)(pa_stream *, const char *, const pa_buffer_attr *, pa_stream_flags_t, const pa_cvolume *, pa_stream *); static int (*PULSEAUDIO_pa_stream_connect_record)(pa_stream *, const char *, @@ -112,6 +112,7 @@ static pa_operation *(*PULSEAUDIO_pa_stream_flush)(pa_stream *, static int (*PULSEAUDIO_pa_stream_disconnect)(pa_stream *); static void (*PULSEAUDIO_pa_stream_unref)(pa_stream *); static void (*PULSEAUDIO_pa_stream_set_write_callback)(pa_stream *, pa_stream_request_cb_t, void *); +static void (*PULSEAUDIO_pa_stream_set_read_callback)(pa_stream *, pa_stream_request_cb_t, void *); static pa_operation *(*PULSEAUDIO_pa_context_get_server_info)(pa_context *, pa_server_info_cb_t, void *); static int load_pulseaudio_syms(void); @@ -124,7 +125,7 @@ static void *pulseaudio_handle = NULL; static int load_pulseaudio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pulseaudio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -139,7 +140,7 @@ static int load_pulseaudio_sym(const char *fn, void **addr) static void UnloadPulseAudioLibrary(void) { - if (pulseaudio_handle != NULL) { + if (pulseaudio_handle) { SDL_UnloadObject(pulseaudio_handle); pulseaudio_handle = NULL; } @@ -148,9 +149,9 @@ static void UnloadPulseAudioLibrary(void) static int LoadPulseAudioLibrary(void) { int retval = 0; - if (pulseaudio_handle == NULL) { + if (!pulseaudio_handle) { pulseaudio_handle = SDL_LoadObject(pulseaudio_library); - if (pulseaudio_handle == NULL) { + if (!pulseaudio_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -182,16 +183,20 @@ static int LoadPulseAudioLibrary(void) static int load_pulseaudio_syms(void) { SDL_PULSEAUDIO_SYM(pa_get_library_version); - SDL_PULSEAUDIO_SYM(pa_mainloop_new); - SDL_PULSEAUDIO_SYM(pa_mainloop_get_api); - SDL_PULSEAUDIO_SYM(pa_mainloop_iterate); - SDL_PULSEAUDIO_SYM(pa_mainloop_run); - SDL_PULSEAUDIO_SYM(pa_mainloop_quit); - SDL_PULSEAUDIO_SYM(pa_mainloop_free); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_new); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_get_api); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_start); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_stop); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_lock); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_unlock); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_wait); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_signal); + SDL_PULSEAUDIO_SYM(pa_threaded_mainloop_free); SDL_PULSEAUDIO_SYM(pa_operation_get_state); SDL_PULSEAUDIO_SYM(pa_operation_cancel); SDL_PULSEAUDIO_SYM(pa_operation_unref); SDL_PULSEAUDIO_SYM(pa_context_new); + SDL_PULSEAUDIO_SYM(pa_context_set_state_callback); SDL_PULSEAUDIO_SYM(pa_context_connect); SDL_PULSEAUDIO_SYM(pa_context_get_sink_info_list); SDL_PULSEAUDIO_SYM(pa_context_get_source_info_list); @@ -203,6 +208,7 @@ static int load_pulseaudio_syms(void) SDL_PULSEAUDIO_SYM(pa_context_disconnect); SDL_PULSEAUDIO_SYM(pa_context_unref); SDL_PULSEAUDIO_SYM(pa_stream_new); + SDL_PULSEAUDIO_SYM(pa_stream_set_state_callback); SDL_PULSEAUDIO_SYM(pa_stream_connect_playback); SDL_PULSEAUDIO_SYM(pa_stream_connect_record); SDL_PULSEAUDIO_SYM(pa_stream_get_state); @@ -218,7 +224,18 @@ static int load_pulseaudio_syms(void) SDL_PULSEAUDIO_SYM(pa_channel_map_init_auto); SDL_PULSEAUDIO_SYM(pa_strerror); SDL_PULSEAUDIO_SYM(pa_stream_set_write_callback); + SDL_PULSEAUDIO_SYM(pa_stream_set_read_callback); SDL_PULSEAUDIO_SYM(pa_context_get_server_info); + + /* optional */ +#ifdef SDL_AUDIO_DRIVER_PULSEAUDIO_DYNAMIC + load_pulseaudio_sym("pa_threaded_mainloop_set_name", (void **)(char *)&PULSEAUDIO_pa_threaded_mainloop_set_name); +#elif (PA_PROTOCOL_VERSION >= 29) + PULSEAUDIO_pa_threaded_mainloop_set_name = pa_threaded_mainloop_set_name; +#else + PULSEAUDIO_pa_threaded_mainloop_set_name = NULL; +#endif + return 0; } @@ -240,7 +257,7 @@ static const char *getAppName(void) } else { const char *verstr = PULSEAUDIO_pa_get_library_version(); retval = "SDL Application"; /* the "oh well" default. */ - if (verstr != NULL) { + if (verstr) { int maj, min, patch; if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) { if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) { @@ -252,87 +269,103 @@ static const char *getAppName(void) return retval; } -static void WaitForPulseOperation(pa_mainloop *mainloop, pa_operation *o) +/* This function assume you are holding `mainloop`'s lock and that `o` has a callback that will signal pulseaudio_threaded_mainloop. + The caller may optionally call pa_threaded_mainloop_accept() if the signal is blocking. The operation is + unref'd in here, assuming you did the work in the callback and just want to know it's done, though. */ +static void WaitForPulseOperation(pa_operation *o) { /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */ - if (mainloop && o) { - SDL_bool okay = SDL_TRUE; - while (okay && (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING)) { - okay = (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) >= 0); + SDL_assert(pulseaudio_threaded_mainloop != NULL); + if (o) { + while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */ } PULSEAUDIO_pa_operation_unref(o); } } -static void DisconnectFromPulseServer(pa_mainloop *mainloop, pa_context *context) +static void DisconnectFromPulseServer(void) { - if (context) { - PULSEAUDIO_pa_context_disconnect(context); - PULSEAUDIO_pa_context_unref(context); + if (pulseaudio_threaded_mainloop) { + PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop); + } + if (pulseaudio_context) { + PULSEAUDIO_pa_context_disconnect(pulseaudio_context); + PULSEAUDIO_pa_context_unref(pulseaudio_context); + pulseaudio_context = NULL; } - if (mainloop != NULL) { - PULSEAUDIO_pa_mainloop_free(mainloop); + if (pulseaudio_threaded_mainloop) { + PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop); + pulseaudio_threaded_mainloop = NULL; } } -static int ConnectToPulseServer_Internal(pa_mainloop **_mainloop, pa_context **_context) +static void PulseContextStateChangeCallback(pa_context *context, void *userdata) +{ + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* just signal any waiting code, it can look up the details. */ +} + +static int ConnectToPulseServer(void) { - pa_mainloop *mainloop = NULL; - pa_context *context = NULL; pa_mainloop_api *mainloop_api = NULL; int state = 0; - *_mainloop = NULL; - *_context = NULL; + SDL_assert(pulseaudio_threaded_mainloop == NULL); + SDL_assert(pulseaudio_context == NULL); /* Set up a new main loop */ - if (!(mainloop = PULSEAUDIO_pa_mainloop_new())) { - return SDL_SetError("pa_mainloop_new() failed"); + if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) { + return SDL_SetError("pa_threaded_mainloop_new() failed"); } - mainloop_api = PULSEAUDIO_pa_mainloop_get_api(mainloop); - SDL_assert(mainloop_api); /* this never fails, right? */ + if (PULSEAUDIO_pa_threaded_mainloop_set_name) { + PULSEAUDIO_pa_threaded_mainloop_set_name(pulseaudio_threaded_mainloop, "PulseMainloop"); + } - context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); - if (context == NULL) { - PULSEAUDIO_pa_mainloop_free(mainloop); - return SDL_SetError("pa_context_new() failed"); + if (PULSEAUDIO_pa_threaded_mainloop_start(pulseaudio_threaded_mainloop) < 0) { + PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop); + pulseaudio_threaded_mainloop = NULL; + return SDL_SetError("pa_threaded_mainloop_start() failed"); } + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + + mainloop_api = PULSEAUDIO_pa_threaded_mainloop_get_api(pulseaudio_threaded_mainloop); + SDL_assert(mainloop_api != NULL); /* this never fails, right? */ + + pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); + if (!pulseaudio_context) { + SDL_SetError("pa_context_new() failed"); + goto failed; + } + + PULSEAUDIO_pa_context_set_state_callback(pulseaudio_context, PulseContextStateChangeCallback, NULL); + /* Connect to the PulseAudio server */ - if (PULSEAUDIO_pa_context_connect(context, NULL, 0, NULL) < 0) { - PULSEAUDIO_pa_context_unref(context); - PULSEAUDIO_pa_mainloop_free(mainloop); - return SDL_SetError("Could not setup connection to PulseAudio"); + if (PULSEAUDIO_pa_context_connect(pulseaudio_context, NULL, 0, NULL) < 0) { + SDL_SetError("Could not setup connection to PulseAudio"); + goto failed; } - do { - if (PULSEAUDIO_pa_mainloop_iterate(mainloop, 1, NULL) < 0) { - PULSEAUDIO_pa_context_unref(context); - PULSEAUDIO_pa_mainloop_free(mainloop); - return SDL_SetError("pa_mainloop_iterate() failed"); - } - state = PULSEAUDIO_pa_context_get_state(context); - if (!PA_CONTEXT_IS_GOOD(state)) { - PULSEAUDIO_pa_context_unref(context); - PULSEAUDIO_pa_mainloop_free(mainloop); - return SDL_SetError("Could not connect to PulseAudio"); - } - } while (state != PA_CONTEXT_READY); + state = PULSEAUDIO_pa_context_get_state(pulseaudio_context); + while (PA_CONTEXT_IS_GOOD(state) && (state != PA_CONTEXT_READY)) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + state = PULSEAUDIO_pa_context_get_state(pulseaudio_context); + } + + if (state != PA_CONTEXT_READY) { + return SDL_SetError("Could not connect to PulseAudio"); + goto failed; + } - *_context = context; - *_mainloop = mainloop; + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); return 0; /* connected and ready! */ -} -static int ConnectToPulseServer(pa_mainloop **_mainloop, pa_context **_context) -{ - const int retval = ConnectToPulseServer_Internal(_mainloop, _context); - if (retval < 0) { - DisconnectFromPulseServer(*_mainloop, *_context); - } - return retval; +failed: + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); + DisconnectFromPulseServer(); + return -1; } /* This function waits until it is possible to write a full sound buffer */ @@ -346,6 +379,7 @@ static void WriteCallback(pa_stream *p, size_t nbytes, void *userdata) struct SDL_PrivateAudioData *h = (struct SDL_PrivateAudioData *)userdata; /*printf("PULSEAUDIO WRITE CALLBACK! nbytes=%u\n", (unsigned int) nbytes);*/ h->bytes_requested += nbytes; + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } static void PULSEAUDIO_PlayDevice(_THIS) @@ -357,12 +391,14 @@ static void PULSEAUDIO_PlayDevice(_THIS) /*printf("PULSEAUDIO PLAYDEVICE START! mixlen=%d\n", available);*/ + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + while (SDL_AtomicGet(&this->enabled) && (available > 0)) { cpy = SDL_min(h->bytes_requested, available); if (cpy) { if (PULSEAUDIO_pa_stream_write(h->stream, h->mixbuf + written, cpy, NULL, 0LL, PA_SEEK_RELATIVE) < 0) { SDL_OpenedAudioDeviceDisconnected(this); - return; + break; } /*printf("PULSEAUDIO FEED! nbytes=%u\n", (unsigned int) cpy);*/ h->bytes_requested -= cpy; @@ -370,16 +406,21 @@ static void PULSEAUDIO_PlayDevice(_THIS) available -= cpy; } - /* let WriteCallback fire if necessary. */ - /*printf("PULSEAUDIO ITERATE!\n");*/ - if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || - PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || - PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { - SDL_OpenedAudioDeviceDisconnected(this); - return; + if (available > 0) { + /* let WriteCallback fire if necessary. */ + /*printf("PULSEAUDIO WAIT IN PLAYDEVICE!\n");*/ + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + + if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) { + /*printf("PULSEAUDIO DEVICE FAILURE IN PLAYDEVICE!\n");*/ + SDL_OpenedAudioDeviceDisconnected(this); + break; + } } } + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); + /*printf("PULSEAUDIO PLAYDEVICE END! written=%d\n", written);*/ } @@ -388,14 +429,23 @@ static Uint8 *PULSEAUDIO_GetDeviceBuf(_THIS) return this->hidden->mixbuf; } +static void ReadCallback(pa_stream *p, size_t nbytes, void *userdata) +{ + /*printf("PULSEAUDIO READ CALLBACK! nbytes=%u\n", (unsigned int) nbytes);*/ + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* the capture code queries what it needs, we just need to signal to end any wait */ +} + static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) { struct SDL_PrivateAudioData *h = this->hidden; const void *data = NULL; size_t nbytes = 0; + int retval = 0; + + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); while (SDL_AtomicGet(&this->enabled)) { - if (h->capturebuf != NULL) { + if (h->capturebuf) { const int cpy = SDL_min(buflen, h->capturelen); SDL_memcpy(buffer, h->capturebuf, cpy); /*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/ @@ -405,25 +455,30 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) h->capturebuf = NULL; PULSEAUDIO_pa_stream_drop(h->stream); /* done with this fragment. */ } - return cpy; /* new data, return it. */ + retval = cpy; /* new data, return it. */ + break; } - if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || - PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || - PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { - SDL_OpenedAudioDeviceDisconnected(this); - return -1; /* uhoh, pulse failed! */ + while (SDL_AtomicGet(&this->enabled) && (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0)) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) { + /*printf("PULSEAUDIO DEVICE FAILURE IN CAPTUREFROMDEVICE!\n");*/ + SDL_OpenedAudioDeviceDisconnected(this); + retval = -1; + break; + } } - if (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0) { - continue; /* no data available yet. */ + if ((retval == -1) || !SDL_AtomicGet(&this->enabled)) { /* in case this happened while we were blocking. */ + retval = -1; + break; } /* a new fragment is available! */ PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); SDL_assert(nbytes > 0); /* If data == NULL, then the buffer had a hole, ignore that */ - if (data == NULL) { + if (!data) { PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } else { /* store this fragment's data, start feeding it to SDL. */ @@ -433,7 +488,9 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) } } - return -1; /* not enabled? */ + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); + + return retval; } static void PULSEAUDIO_FlushCapture(_THIS) @@ -442,41 +499,46 @@ static void PULSEAUDIO_FlushCapture(_THIS) const void *data = NULL; size_t nbytes = 0; - if (h->capturebuf != NULL) { + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + + if (h->capturebuf) { PULSEAUDIO_pa_stream_drop(h->stream); h->capturebuf = NULL; h->capturelen = 0; } - while (SDL_AtomicGet(&this->enabled)) { - if (PULSEAUDIO_pa_context_get_state(h->context) != PA_CONTEXT_READY || - PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY || - PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { + while (SDL_AtomicGet(&this->enabled) && (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0)) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + if ((PULSEAUDIO_pa_context_get_state(pulseaudio_context) != PA_CONTEXT_READY) || (PULSEAUDIO_pa_stream_get_state(h->stream) != PA_STREAM_READY)) { + /*printf("PULSEAUDIO DEVICE FAILURE IN FLUSHCAPTURE!\n");*/ SDL_OpenedAudioDeviceDisconnected(this); - return; /* uhoh, pulse failed! */ + break; } - if (PULSEAUDIO_pa_stream_readable_size(h->stream) == 0) { - break; /* no data available, so we're done. */ + if (PULSEAUDIO_pa_stream_readable_size(h->stream) > 0) { + /* a new fragment is available! Just dump it. */ + PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); + PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } - - /* a new fragment is available! Just dump it. */ - PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); - PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } + + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); } static void PULSEAUDIO_CloseDevice(_THIS) { + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + if (this->hidden->stream) { - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { PULSEAUDIO_pa_stream_drop(this->hidden->stream); } PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); PULSEAUDIO_pa_stream_unref(this->hidden->stream); } - DisconnectFromPulseServer(this->hidden->mainloop, this->hidden->context); + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); + SDL_free(this->hidden->mixbuf); SDL_free(this->hidden->device_name); SDL_free(this->hidden); @@ -488,6 +550,7 @@ static void SinkDeviceNameCallback(pa_context *c, const pa_sink_info *i, int is_ char **devname = (char **)data; *devname = SDL_strdup(i->name); } + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } static void SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int is_last, void *data) @@ -496,29 +559,31 @@ static void SourceDeviceNameCallback(pa_context *c, const pa_source_info *i, int char **devname = (char **)data; *devname = SDL_strdup(i->name); } + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool iscapture, void *handle) { const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1; - if (handle == NULL) { /* NULL == default device. */ + if (!handle) { /* NULL == default device. */ return SDL_TRUE; } if (iscapture) { - WaitForPulseOperation(h->mainloop, - PULSEAUDIO_pa_context_get_source_info_by_index(h->context, idx, - SourceDeviceNameCallback, &h->device_name)); + WaitForPulseOperation(PULSEAUDIO_pa_context_get_source_info_by_index(pulseaudio_context, idx, SourceDeviceNameCallback, &h->device_name)); } else { - WaitForPulseOperation(h->mainloop, - PULSEAUDIO_pa_context_get_sink_info_by_index(h->context, idx, - SinkDeviceNameCallback, &h->device_name)); + WaitForPulseOperation(PULSEAUDIO_pa_context_get_sink_info_by_index(pulseaudio_context, idx, SinkDeviceNameCallback, &h->device_name)); } return h->device_name != NULL; } +static void PulseStreamStateChangeCallback(pa_stream *stream, void *userdata) +{ + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); /* just signal any waiting code, it can look up the details. */ +} + static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) { struct SDL_PrivateAudioData *h = NULL; @@ -527,14 +592,16 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) pa_buffer_attr paattr; pa_channel_map pacmap; pa_stream_flags_t flags = 0; - const char *name = NULL; SDL_bool iscapture = this->iscapture; - int state = 0, format = PA_SAMPLE_INVALID; - int rc = 0; + int format = PA_SAMPLE_INVALID; + int retval = 0; + + SDL_assert(pulseaudio_threaded_mainloop != NULL); + SDL_assert(pulseaudio_context != NULL); /* Initialize all variables that we clean on shutdown */ h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -572,7 +639,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) break; } if (!test_format) { - return SDL_SetError("%s: Unsupported audio format", "pulseaudio"); + return SDL_SetError("pulseaudio: Unsupported audio format"); } this->spec.format = test_format; paspec.format = format; @@ -584,7 +651,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) if (!iscapture) { h->mixlen = this->spec.size; h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen); - if (h->mixbuf == NULL) { + if (!h->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(h->mixbuf, this->spec.silence, this->spec.size); @@ -601,73 +668,66 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) paattr.minreq = -1; flags |= PA_STREAM_ADJUST_LATENCY; - if (ConnectToPulseServer(&h->mainloop, &h->context) < 0) { - return SDL_SetError("Could not connect to PulseAudio server"); - } + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); if (!FindDeviceName(h, iscapture, this->handle)) { - return SDL_SetError("Requested PulseAudio sink/source missing?"); - } - - /* The SDL ALSA output hints us that we use Windows' channel mapping */ - /* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */ - PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels, - PA_CHANNEL_MAP_WAVEEX); - - name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); + retval = SDL_SetError("Requested PulseAudio sink/source missing?"); + } else { + const char *name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME); + /* The SDL ALSA output hints us that we use Windows' channel mapping */ + /* https://bugzilla.libsdl.org/show_bug.cgi?id=110 */ + PULSEAUDIO_pa_channel_map_init_auto(&pacmap, this->spec.channels, + PA_CHANNEL_MAP_WAVEEX); + + h->stream = PULSEAUDIO_pa_stream_new( + pulseaudio_context, + (name && *name) ? name : "Audio Stream", /* stream description */ + &paspec, /* sample format spec */ + &pacmap /* channel map */ + ); + + if (!h->stream) { + retval = SDL_SetError("Could not set up PulseAudio stream"); + } else { + int rc; - h->stream = PULSEAUDIO_pa_stream_new( - h->context, - (name && *name) ? name : "Audio Stream", /* stream description */ - &paspec, /* sample format spec */ - &pacmap /* channel map */ - ); + PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL); + /* now that we have multi-device support, don't move a stream from + a device that was unplugged to something else, unless we're default. */ + if (h->device_name) { + flags |= PA_STREAM_DONT_MOVE; + } - if (h->stream == NULL) { - return SDL_SetError("Could not set up PulseAudio stream"); - } + if (iscapture) { + PULSEAUDIO_pa_stream_set_read_callback(h->stream, ReadCallback, h); + rc = PULSEAUDIO_pa_stream_connect_record(h->stream, h->device_name, &paattr, flags); + } else { + PULSEAUDIO_pa_stream_set_write_callback(h->stream, WriteCallback, h); + rc = PULSEAUDIO_pa_stream_connect_playback(h->stream, h->device_name, &paattr, flags, NULL, NULL); + } - /* now that we have multi-device support, don't move a stream from - a device that was unplugged to something else, unless we're default. */ - if (h->device_name != NULL) { - flags |= PA_STREAM_DONT_MOVE; - } + if (rc < 0) { + retval = SDL_SetError("Could not connect PulseAudio stream"); + } else { + int state = PULSEAUDIO_pa_stream_get_state(h->stream); + while (PA_STREAM_IS_GOOD(state) && (state != PA_STREAM_READY)) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + state = PULSEAUDIO_pa_stream_get_state(h->stream); + } - if (iscapture) { - rc = PULSEAUDIO_pa_stream_connect_record(h->stream, h->device_name, &paattr, flags); - } else { - PULSEAUDIO_pa_stream_set_write_callback(h->stream, WriteCallback, h); - rc = PULSEAUDIO_pa_stream_connect_playback(h->stream, h->device_name, &paattr, flags, NULL, NULL); + if (!PA_STREAM_IS_GOOD(state)) { + retval = SDL_SetError("Could not connect PulseAudio stream"); + } + } + } } - if (rc < 0) { - return SDL_SetError("Could not connect PulseAudio stream"); - } + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); - do { - if (PULSEAUDIO_pa_mainloop_iterate(h->mainloop, 1, NULL) < 0) { - return SDL_SetError("pa_mainloop_iterate() failed"); - } - state = PULSEAUDIO_pa_stream_get_state(h->stream); - if (!PA_STREAM_IS_GOOD(state)) { - return SDL_SetError("Could not connect PulseAudio stream"); - } - } while (state != PA_STREAM_READY); - - /* We're ready to rock and roll. :-) */ - return 0; + /* We're (hopefully) ready to rock and roll. :-) */ + return retval; } -static pa_mainloop *hotplug_mainloop = NULL; -static pa_context *hotplug_context = NULL; -static SDL_Thread *hotplug_thread = NULL; - -/* These are the OS identifiers (i.e. ALSA strings)... */ -static char *default_sink_path = NULL; -static char *default_source_path = NULL; -/* ... and these are the descriptions we use in GetDefaultAudioInfo. */ -static char *default_sink_name = NULL; -static char *default_source_name = NULL; /* device handles are device index + 1, cast to void*, so we never pass a NULL. */ @@ -712,13 +772,14 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) { - if (default_sink_name != NULL) { + if (default_sink_path && SDL_strcmp(i->name, default_sink_path) == 0) { + if (default_sink_name) { SDL_free(default_sink_name); } default_sink_name = SDL_strdup(i->description); } } + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } /* This is called when PulseAudio adds a capture ("source") device. */ @@ -742,26 +803,24 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) { - if (default_source_name != NULL) { + if (default_source_path && SDL_strcmp(i->name, default_source_path) == 0) { + if (default_source_name) { SDL_free(default_source_name); } default_source_name = SDL_strdup(i->description); } } } + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } static void ServerInfoCallback(pa_context *c, const pa_server_info *i, void *data) { - if (default_sink_path != NULL) { - SDL_free(default_sink_path); - } - if (default_source_path != NULL) { - SDL_free(default_source_path); - } + SDL_free(default_sink_path); + SDL_free(default_source_path); default_sink_path = SDL_strdup(i->default_sink_name); default_source_path = SDL_strdup(i->default_source_name); + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } /* This is called when PulseAudio has a device connected/removed/changed. */ @@ -776,43 +835,71 @@ static void HotplugCallback(pa_context *c, pa_subscription_event_type_t t, uint3 const SDL_bool source = ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE); /* adds need sink details from the PulseAudio server. Another callback... */ + /* (just unref all these operations right away, because we aren't going to wait on them and their callbacks will handle any work, so they can free as soon as that happens.) */ if ((added || changed) && sink) { if (changed) { - PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL); + PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL)); } - PULSEAUDIO_pa_context_get_sink_info_by_index(hotplug_context, idx, SinkInfoCallback, (void *)((intptr_t)added)); + PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_sink_info_by_index(pulseaudio_context, idx, SinkInfoCallback, (void *)((intptr_t)added))); } else if ((added || changed) && source) { if (changed) { - PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL); + PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL)); } - PULSEAUDIO_pa_context_get_source_info_by_index(hotplug_context, idx, SourceInfoCallback, (void *)((intptr_t)added)); + PULSEAUDIO_pa_operation_unref(PULSEAUDIO_pa_context_get_source_info_by_index(pulseaudio_context, idx, SourceInfoCallback, (void *)((intptr_t)added))); } else if (removed && (sink || source)) { /* removes we can handle just with the device index. */ SDL_RemoveAudioDevice(source != 0, (void *)((intptr_t)idx + 1)); } } + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); } /* this runs as a thread while the Pulse target is initialized to catch hotplug events. */ static int SDLCALL HotplugThread(void *data) { - pa_operation *o; + pa_operation *op; + SDL_SetThreadPriority(SDL_THREAD_PRIORITY_LOW); - PULSEAUDIO_pa_context_set_subscribe_callback(hotplug_context, HotplugCallback, NULL); - o = PULSEAUDIO_pa_context_subscribe(hotplug_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL); - PULSEAUDIO_pa_operation_unref(o); /* don't wait for it, just do our thing. */ - PULSEAUDIO_pa_mainloop_run(hotplug_mainloop, NULL); + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, HotplugCallback, NULL); + + /* don't WaitForPulseOperation on the subscription; when it's done we'll be able to get hotplug events, but waiting doesn't changing anything. */ + op = PULSEAUDIO_pa_context_subscribe(pulseaudio_context, PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE, NULL, NULL); + + SDL_SemPost(data); + + while (SDL_AtomicGet(&pulseaudio_hotplug_thread_active)) { + PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); + if (op && PULSEAUDIO_pa_operation_get_state(op) != PA_OPERATION_RUNNING) { + PULSEAUDIO_pa_operation_unref(op); + op = NULL; + } + } + + if (op) { + PULSEAUDIO_pa_operation_unref(op); + } + + PULSEAUDIO_pa_context_set_subscribe_callback(pulseaudio_context, NULL, NULL); + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); return 0; } static void PULSEAUDIO_DetectDevices() { - WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_server_info(hotplug_context, ServerInfoCallback, NULL)); - WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_sink_info_list(hotplug_context, SinkInfoCallback, (void *)((intptr_t)SDL_TRUE))); - WaitForPulseOperation(hotplug_mainloop, PULSEAUDIO_pa_context_get_source_info_list(hotplug_context, SourceInfoCallback, (void *)((intptr_t)SDL_TRUE))); + SDL_sem *ready_sem = SDL_CreateSemaphore(0); + + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + WaitForPulseOperation(PULSEAUDIO_pa_context_get_server_info(pulseaudio_context, ServerInfoCallback, NULL)); + WaitForPulseOperation(PULSEAUDIO_pa_context_get_sink_info_list(pulseaudio_context, SinkInfoCallback, (void *)((intptr_t)SDL_TRUE))); + WaitForPulseOperation(PULSEAUDIO_pa_context_get_source_info_list(pulseaudio_context, SourceInfoCallback, (void *)((intptr_t)SDL_TRUE))); + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); /* ok, we have a sane list, let's set up hotplug notifications now... */ - hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, NULL); + SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 1); + pulseaudio_hotplug_thread = SDL_CreateThreadInternal(HotplugThread, "PulseHotplug", 256 * 1024, ready_sem); /* !!! FIXME: this can probably survive in significantly less stack space. */ + SDL_SemWait(ready_sem); + SDL_DestroySemaphore(ready_sem); } static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture) @@ -822,12 +909,12 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int char *target; if (iscapture) { - if (default_source_name == NULL) { + if (!default_source_name) { return SDL_SetError("PulseAudio could not find a default source"); } target = default_source_name; } else { - if (default_sink_name == NULL) { + if (!default_sink_name) { return SDL_SetError("PulseAudio could not find a default sink"); } target = default_sink_name; @@ -836,7 +923,7 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int numdevices = SDL_GetNumAudioDevices(iscapture); for (i = 0; i < numdevices; i += 1) { if (SDL_strcmp(SDL_GetAudioDeviceName(i, iscapture), target) == 0) { - if (name != NULL) { + if (name) { *name = SDL_strdup(target); } SDL_GetAudioDeviceSpec(i, iscapture, spec); @@ -848,32 +935,25 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int static void PULSEAUDIO_Deinitialize(void) { - if (hotplug_thread) { - PULSEAUDIO_pa_mainloop_quit(hotplug_mainloop, 0); - SDL_WaitThread(hotplug_thread, NULL); - hotplug_thread = NULL; + if (pulseaudio_hotplug_thread) { + PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); + SDL_AtomicSet(&pulseaudio_hotplug_thread_active, 0); + PULSEAUDIO_pa_threaded_mainloop_signal(pulseaudio_threaded_mainloop, 0); + PULSEAUDIO_pa_threaded_mainloop_unlock(pulseaudio_threaded_mainloop); + SDL_WaitThread(pulseaudio_hotplug_thread, NULL); + pulseaudio_hotplug_thread = NULL; } - DisconnectFromPulseServer(hotplug_mainloop, hotplug_context); - hotplug_mainloop = NULL; - hotplug_context = NULL; + DisconnectFromPulseServer(); - if (default_sink_path != NULL) { - SDL_free(default_sink_path); - default_sink_path = NULL; - } - if (default_source_path != NULL) { - SDL_free(default_source_path); - default_source_path = NULL; - } - if (default_sink_name != NULL) { - SDL_free(default_sink_name); - default_sink_name = NULL; - } - if (default_source_name != NULL) { - SDL_free(default_source_name); - default_source_name = NULL; - } + SDL_free(default_sink_path); + default_sink_path = NULL; + SDL_free(default_source_path); + default_source_path = NULL; + SDL_free(default_sink_name); + default_sink_name = NULL; + SDL_free(default_source_name); + default_source_name = NULL; UnloadPulseAudioLibrary(); } @@ -882,9 +962,7 @@ static SDL_bool PULSEAUDIO_Init(SDL_AudioDriverImpl *impl) { if (LoadPulseAudioLibrary() < 0) { return SDL_FALSE; - } - - if (ConnectToPulseServer(&hotplug_mainloop, &hotplug_context) < 0) { + } else if (ConnectToPulseServer() < 0) { UnloadPulseAudioLibrary(); return SDL_FALSE; } diff --git a/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.h b/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.h index 3b2ee32538..b4ad3822ce 100644 --- a/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/vs/sdl2/src/audio/pulseaudio/SDL_pulseaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_pulseaudio_h_ #define SDL_pulseaudio_h_ -#include +#include #include "../SDL_sysaudio.h" @@ -35,8 +35,6 @@ struct SDL_PrivateAudioData char *device_name; /* pulseaudio structures */ - pa_mainloop *mainloop; - pa_context *context; pa_stream *stream; /* Raw mixing buffer */ diff --git a/vs/sdl2/src/audio/qsa/SDL_qsa_audio.c b/vs/sdl2/src/audio/qsa/SDL_qsa_audio.c index 0ab477485b..be0532cf92 100644 --- a/vs/sdl2/src/audio/qsa/SDL_qsa_audio.c +++ b/vs/sdl2/src/audio/qsa/SDL_qsa_audio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +30,7 @@ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_QSA +#ifdef SDL_AUDIO_DRIVER_QSA #include #include @@ -232,7 +232,8 @@ static Uint8 *QSA_GetDeviceBuf(_THIS) static void QSA_CloseDevice(_THIS) { - if (this->hidden->audio_handle != NULL) { + if (this->hidden->audio_handle) { +#if _NTO_VERSION < 710 if (!this->iscapture) { /* Finish playing available samples */ snd_pcm_plugin_flush(this->hidden->audio_handle, @@ -242,6 +243,7 @@ static void QSA_CloseDevice(_THIS) snd_pcm_plugin_flush(this->hidden->audio_handle, SND_PCM_CHANNEL_CAPTURE); } +#endif snd_pcm_close(this->hidden->audio_handle); } @@ -265,14 +267,14 @@ static int QSA_OpenDevice(_THIS, const char *devname) (sizeof (struct SDL_PrivateAudioData))); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } /* Initialize channel transfer parameters to default */ QSA_InitAudioParams(&cparams); - if (device != NULL) { + if (device) { /* Open requested audio device */ this->hidden->deviceno = device->deviceno; this->hidden->cardno = device->cardno; @@ -385,7 +387,7 @@ static int QSA_OpenDevice(_THIS, const char *devname) */ this->hidden->pcm_buf = (Uint8 *) SDL_malloc(this->hidden->pcm_len); - if (this->hidden->pcm_buf == NULL) { + if (!this->hidden->pcm_buf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->pcm_buf, this->spec.silence, diff --git a/vs/sdl2/src/audio/qsa/SDL_qsa_audio.h b/vs/sdl2/src/audio/qsa/SDL_qsa_audio.h index e177074b03..1e69f26c92 100644 --- a/vs/sdl2/src/audio/qsa/SDL_qsa_audio.h +++ b/vs/sdl2/src/audio/qsa/SDL_qsa_audio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/sndio/SDL_sndioaudio.c b/vs/sdl2/src/audio/sndio/SDL_sndioaudio.c index d62d179d48..499b8478cc 100644 --- a/vs/sdl2/src/audio/sndio/SDL_sndioaudio.c +++ b/vs/sdl2/src/audio/sndio/SDL_sndioaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +21,11 @@ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_SNDIO +#ifdef SDL_AUDIO_DRIVER_SNDIO /* OpenBSD sndio target */ -#if HAVE_STDIO_H +#ifdef HAVE_STDIO_H #include #endif @@ -73,7 +73,7 @@ static void *sndio_handle = NULL; static int load_sndio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(sndio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -113,7 +113,7 @@ static int load_sndio_syms(void) static void UnloadSNDIOLibrary(void) { - if (sndio_handle != NULL) { + if (sndio_handle) { SDL_UnloadObject(sndio_handle); sndio_handle = NULL; } @@ -122,9 +122,9 @@ static void UnloadSNDIOLibrary(void) static int LoadSNDIOLibrary(void) { int retval = 0; - if (sndio_handle == NULL) { + if (!sndio_handle) { sndio_handle = SDL_LoadObject(sndio_library); - if (sndio_handle == NULL) { + if (!sndio_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -211,10 +211,10 @@ static Uint8 *SNDIO_GetDeviceBuf(_THIS) static void SNDIO_CloseDevice(_THIS) { - if (this->hidden->pfd != NULL) { + if (this->hidden->pfd) { SDL_free(this->hidden->pfd); } - if (this->hidden->dev != NULL) { + if (this->hidden->dev) { SNDIO_sio_stop(this->hidden->dev); SNDIO_sio_close(this->hidden->dev); } @@ -230,7 +230,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -238,16 +238,16 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; /* Capture devices must be non-blocking for SNDIO_FlushCapture */ - this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY, + this->hidden->dev = SNDIO_sio_open(devname ? devname : SIO_DEVANY, iscapture ? SIO_REC : SIO_PLAY, iscapture); - if (this->hidden->dev == NULL) { + if (!this->hidden->dev) { return SDL_SetError("sio_open() failed"); } /* Allocate the pollfd array for capture devices */ if (iscapture) { this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev)); - if (this->hidden->pfd == NULL) { + if (!this->hidden->pfd) { return SDL_OutOfMemory(); } } @@ -315,7 +315,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); diff --git a/vs/sdl2/src/audio/sndio/SDL_sndioaudio.h b/vs/sdl2/src/audio/sndio/SDL_sndioaudio.h index d447c16936..ffd4df895c 100644 --- a/vs/sdl2/src/audio/sndio/SDL_sndioaudio.h +++ b/vs/sdl2/src/audio/sndio/SDL_sndioaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/sun/SDL_sunaudio.c b/vs/sdl2/src/audio/sun/SDL_sunaudio.c index 25deb90984..442cf2b5ec 100644 --- a/vs/sdl2/src/audio/sun/SDL_sunaudio.c +++ b/vs/sdl2/src/audio/sun/SDL_sunaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_SUNAUDIO +#ifdef SDL_AUDIO_DRIVER_SUNAUDIO /* Allow access to a raw mixing buffer */ @@ -194,16 +194,16 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -281,7 +281,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) break; /* try again */ case AUDIO_ENCODING_LINEAR: - /* linear 16bit didn't work either, resort to µ-law */ + /* linear 16bit didn't work either, resort to �-law */ enc = AUDIO_ENCODING_ULAW; this->spec.channels = 1; this->spec.freq = 8000; @@ -305,7 +305,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) (this->spec.freq / 8); this->hidden->frequency = 8; this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize); - if (this->hidden->ulaw_buf == NULL) { + if (!this->hidden->ulaw_buf) { return SDL_OutOfMemory(); } this->spec.channels = 1; @@ -325,7 +325,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/vs/sdl2/src/audio/sun/SDL_sunaudio.h b/vs/sdl2/src/audio/sun/SDL_sunaudio.h index 63a887d1e5..095254333e 100644 --- a/vs/sdl2/src/audio/sun/SDL_sunaudio.h +++ b/vs/sdl2/src/audio/sun/SDL_sunaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/vita/SDL_vitaaudio.c b/vs/sdl2/src/audio/vita/SDL_vitaaudio.c index 058896be2d..bd87323818 100644 --- a/vs/sdl2/src/audio/vita/SDL_vitaaudio.c +++ b/vs/sdl2/src/audio/vita/SDL_vitaaudio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_VITA +#ifdef SDL_AUDIO_DRIVER_VITA #include #include @@ -67,7 +67,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_memset(this->hidden, 0, sizeof(*this->hidden)); @@ -98,7 +98,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) 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) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -162,7 +162,7 @@ static void VITAAUD_CloseDevice(_THIS) this->hidden->port = -1; } - if (!this->iscapture && this->hidden->rawbuf != NULL) { + if (!this->iscapture && this->hidden->rawbuf) { free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ this->hidden->rawbuf = NULL; } diff --git a/vs/sdl2/src/audio/vita/SDL_vitaaudio.h b/vs/sdl2/src/audio/vita/SDL_vitaaudio.h index 52feb9beee..cb0aba8ec9 100644 --- a/vs/sdl2/src/audio/vita/SDL_vitaaudio.h +++ b/vs/sdl2/src/audio/vita/SDL_vitaaudio.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/wasapi/SDL_wasapi.c b/vs/sdl2/src/audio/wasapi/SDL_wasapi.c index c465776643..cf90efc0f9 100644 --- a/vs/sdl2/src/audio/wasapi/SDL_wasapi.c +++ b/vs/sdl2/src/audio/wasapi/SDL_wasapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_WASAPI +#ifdef SDL_AUDIO_DRIVER_WASAPI #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_immdevice.h" @@ -114,7 +114,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) /* make sure our scratch buffer can cover the new device spec. */ if (this->spec.size > this->work_buffer_len) { Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size); - if (ptr == NULL) { + if (!ptr) { return SDL_OutOfMemory(); } this->work_buffer = ptr; @@ -172,13 +172,18 @@ static SDL_bool RecoverWasapiIfLost(_THIS) return lost ? RecoverWasapiDevice(this) : SDL_TRUE; } +static void WASAPI_WaitDevice(_THIS); + static Uint8 *WASAPI_GetDeviceBuf(_THIS) { /* get an endpoint buffer from WASAPI. */ BYTE *buffer = NULL; while (RecoverWasapiIfLost(this) && this->hidden->render) { - if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) { + const HRESULT ret = IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer); + if (ret == AUDCLNT_E_BUFFER_TOO_LARGE) { + WASAPI_WaitDevice(this); /* see if we can wait on the buffer to drain some more first... */ + } else if (!WasapiFailed(this, ret)) { return (Uint8 *)buffer; } SDL_assert(buffer == NULL); @@ -189,7 +194,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS) static void WASAPI_PlayDevice(_THIS) { - if (this->hidden->render != NULL) { /* definitely activated? */ + if (this->hidden->render) { /* definitely activated? */ /* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */ WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0)); } @@ -415,7 +420,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->hidden->event = CreateEventW(NULL, 0, 0, NULL); #endif - if (this->hidden->event == NULL) { + if (!this->hidden->event) { return WIN_SetError("WASAPI can't create an event handle"); } @@ -486,6 +491,11 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->spec.samples = (Uint16)SDL_ceilf(period_frames); } + /* regardless of what we calculated for the period size, clamp it to the expected hardware buffer size. */ + if (this->spec.samples > bufsize) { + this->spec.samples = bufsize; + } + /* Update the fragment size as size in bytes */ SDL_CalculateAudioSpec(&this->spec); @@ -537,7 +547,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); diff --git a/vs/sdl2/src/audio/wasapi/SDL_wasapi.h b/vs/sdl2/src/audio/wasapi/SDL_wasapi.h index 96c206123d..804e0b74e9 100644 --- a/vs/sdl2/src/audio/wasapi/SDL_wasapi.h +++ b/vs/sdl2/src/audio/wasapi/SDL_wasapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/audio/wasapi/SDL_wasapi_win32.c b/vs/sdl2/src/audio/wasapi/SDL_wasapi_win32.c index 965e7ff695..88823c5ac5 100644 --- a/vs/sdl2/src/audio/wasapi/SDL_wasapi_win32.c +++ b/vs/sdl2/src/audio/wasapi/SDL_wasapi_win32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ The code in SDL_wasapi.c is used by both standard Windows and WinRT builds to deal with audio and calls into these functions. */ -#if SDL_AUDIO_DRIVER_WASAPI && !defined(__WINRT__) +#if defined(SDL_AUDIO_DRIVER_WASAPI) && !defined(__WINRT__) #include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_immdevice.h" diff --git a/vs/sdl2/src/audio/wasapi/SDL_wasapi_winrt.cpp b/vs/sdl2/src/audio/wasapi/SDL_wasapi_winrt.cpp index 93ed3b834c..26f483878a 100644 --- a/vs/sdl2/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/vs/sdl2/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ // is in SDL_wasapi_win32.c. The code in SDL_wasapi.c is used by both standard // Windows and WinRT builds to deal with audio and calls into these functions. -#if SDL_AUDIO_DRIVER_WASAPI && defined(__WINRT__) +#if defined(SDL_AUDIO_DRIVER_WASAPI) && defined(__WINRT__) #include #include @@ -405,7 +405,7 @@ static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVE } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } diff --git a/vs/sdl2/src/audio/winmm/SDL_winmm.c b/vs/sdl2/src/audio/winmm/SDL_winmm.c index d0c4b97689..47cb4ba7df 100644 --- a/vs/sdl2/src/audio/winmm/SDL_winmm.c +++ b/vs/sdl2/src/audio/winmm/SDL_winmm.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_AUDIO_DRIVER_WINMM +#ifdef SDL_AUDIO_DRIVER_WINMM /* Allow access to a raw mixing buffer */ @@ -279,7 +279,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ UINT i; - if (handle != NULL) { /* specific device requested? */ + if (handle) { /* specific device requested? */ /* -1 because we increment the original value to avoid NULL. */ const size_t val = ((size_t) handle) - 1; devId = (UINT) val; @@ -287,7 +287,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -365,14 +365,14 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Create the audio buffer semaphore */ this->hidden->audio_sem = CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL); - if (this->hidden->audio_sem == NULL) { + if (!this->hidden->audio_sem) { return SDL_SetError("Couldn't create semaphore"); } /* Create the sound buffers */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/audio/winmm/SDL_winmm.h b/vs/sdl2/src/audio/winmm/SDL_winmm.h index 6e966d5c46..8d0744a2d6 100644 --- a/vs/sdl2/src/audio/winmm/SDL_winmm.h +++ b/vs/sdl2/src/audio/winmm/SDL_winmm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/android/SDL_android.c b/vs/sdl2/src/core/android/SDL_android.c index 34dfdedf09..60620d814e 100644 --- a/vs/sdl2/src/core/android/SDL_android.c +++ b/vs/sdl2/src/core/android/SDL_android.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -420,12 +420,12 @@ JNIEnv *Android_JNI_GetEnv(void) { /* Get JNIEnv from the Thread local storage */ JNIEnv *env = pthread_getspecific(mThreadKey); - if (env == NULL) { + if (!env) { /* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */ int status; /* There should be a JVM */ - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return NULL; } @@ -454,7 +454,7 @@ int Android_JNI_SetupThread(void) int status; /* There should be a JVM */ - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM"); return 0; } @@ -480,7 +480,7 @@ static void Android_JNI_ThreadDestroyed(void *value) { /* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */ JNIEnv *env = (JNIEnv *)value; - if (env != NULL) { + if (env) { (*mJavaVM)->DetachCurrentThread(mJavaVM); Android_JNI_SetEnv(NULL); } @@ -506,7 +506,7 @@ static void Android_JNI_CreateKey_once(void) static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb) { jclass clazz = (*env)->FindClass(env, classname); - if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { + if (!clazz || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to register methods of %s", classname); return; } @@ -566,28 +566,28 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl /* Save JNIEnv of SDLActivity */ Android_JNI_SetEnv(env); - if (mJavaVM == NULL) { + if (!mJavaVM) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to found a JavaVM"); } /* Use a mutex to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'. * (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. ) */ - if (Android_ActivityMutex == NULL) { + if (!Android_ActivityMutex) { Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */ } - if (Android_ActivityMutex == NULL) { + if (!Android_ActivityMutex) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex"); } Android_PauseSem = SDL_CreateSemaphore(0); - if (Android_PauseSem == NULL) { + if (!Android_PauseSem) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore"); } Android_ResumeSem = SDL_CreateSemaphore(0); - if (Android_ResumeSem == NULL) { + if (!Android_ResumeSem) { __android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ResumeSem semaphore"); } @@ -1056,7 +1056,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceChanged)(JNIEnv *env, j { SDL_LockMutex(Android_ActivityMutex); -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (Android_Window) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_WindowData *data = (SDL_WindowData *)Android_Window->driverdata; @@ -1098,7 +1098,7 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeSurfaceDestroyed)(JNIEnv *env, } } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); data->egl_surface = EGL_NO_SURFACE; @@ -1557,7 +1557,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output"); result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, spec->samples, device_id); } - if (result == NULL) { + if (!result) { /* Error during audio initialization, error printed from Java */ return SDL_SetError("Java-side initialization failed"); } @@ -1618,7 +1618,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat); } - if (jbufobj == NULL) { + if (!jbufobj) { __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer"); return SDL_OutOfMemory(); } @@ -1910,7 +1910,7 @@ static void Internal_Android_Create_AssetManager() javaAssetManagerRef = (*env)->NewGlobalRef(env, javaAssetManager); asset_manager = AAssetManager_fromJava(env, javaAssetManagerRef); - if (asset_manager == NULL) { + if (!asset_manager) { (*env)->DeleteGlobalRef(env, javaAssetManagerRef); Android_JNI_ExceptionOccurred(SDL_TRUE); } @@ -1934,17 +1934,17 @@ int Android_JNI_FileOpen(SDL_RWops *ctx, AAsset *asset = NULL; ctx->hidden.androidio.asset = NULL; - if (asset_manager == NULL) { + if (!asset_manager) { Internal_Android_Create_AssetManager(); } - if (asset_manager == NULL) { - return -1; + if (!asset_manager) { + return SDL_SetError("Couldn't create asset manager"); } asset = AAssetManager_open(asset_manager, fileName, AASSET_MODE_UNKNOWN); - if (asset == NULL) { - return -1; + if (!asset) { + return SDL_SetError("Couldn't open asset '%s'", fileName); } ctx->hidden.androidio.asset = (void *)asset; @@ -2022,7 +2022,7 @@ char *Android_JNI_GetClipboardText(void) (*env)->DeleteLocalRef(env, string); } - return (text == NULL) ? SDL_strdup("") : text; + return (!text) ? SDL_strdup("") : text; } SDL_bool Android_JNI_HasClipboardText(void) @@ -2208,7 +2208,7 @@ void Android_JNI_SuspendScreenSaver(SDL_bool suspend) Android_JNI_SendMessage(COMMAND_SET_KEEP_SCREEN_ON, (suspend == SDL_FALSE) ? 0 : 1); } -void Android_JNI_ShowTextInput(SDL_Rect *inputRect) +void Android_JNI_ShowScreenKeyboard(SDL_Rect *inputRect) { JNIEnv *env = Android_JNI_GetEnv(); (*env)->CallStaticBooleanMethod(env, mActivityClass, midShowTextInput, @@ -2218,7 +2218,7 @@ void Android_JNI_ShowTextInput(SDL_Rect *inputRect) inputRect->h); } -void Android_JNI_HideTextInput(void) +void Android_JNI_HideScreenKeyboard(void) { /* has to match Activity constant */ const int COMMAND_TEXTEDIT_HIDE = 3; @@ -2343,7 +2343,7 @@ void *SDL_AndroidGetActivity(void) /* See SDL_system.h for caveats on using this function. */ JNIEnv *env = Android_JNI_GetEnv(); - if (env == NULL) { + if (!env) { return NULL; } @@ -2397,7 +2397,7 @@ const char *SDL_AndroidGetInternalStoragePath(void) { static char *s_AndroidInternalFilesPath = NULL; - if (s_AndroidInternalFilesPath == NULL) { + if (!s_AndroidInternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; @@ -2490,7 +2490,7 @@ const char *SDL_AndroidGetExternalStoragePath(void) { static char *s_AndroidExternalFilesPath = NULL; - if (s_AndroidExternalFilesPath == NULL) { + if (!s_AndroidExternalFilesPath) { struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__); jmethodID mid; jobject context; @@ -2646,16 +2646,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) /* Need to re-create the asset manager if locale has changed (SDL_LOCALECHANGED) */ Internal_Android_Destroy_AssetManager(); - if (asset_manager == NULL) { + if (!asset_manager) { Internal_Android_Create_AssetManager(); } - if (asset_manager == NULL) { + if (!asset_manager) { return -1; } cfg = AConfiguration_new(); - if (cfg == NULL) { + if (!cfg) { return -1; } diff --git a/vs/sdl2/src/core/android/SDL_android.h b/vs/sdl2/src/core/android/SDL_android.h index a54b2cf7de..20d1fc521b 100644 --- a/vs/sdl2/src/core/android/SDL_android.h +++ b/vs/sdl2/src/core/android/SDL_android.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +43,8 @@ extern void Android_JNI_MinizeWindow(void); extern SDL_bool Android_JNI_ShouldMinimizeOnFocusLoss(void); extern SDL_bool Android_JNI_GetAccelerometerValues(float values[3]); -extern void Android_JNI_ShowTextInput(SDL_Rect *inputRect); -extern void Android_JNI_HideTextInput(void); +extern void Android_JNI_ShowScreenKeyboard(SDL_Rect *inputRect); +extern void Android_JNI_HideScreenKeyboard(void); extern SDL_bool Android_JNI_IsScreenKeyboardShown(void); extern ANativeWindow *Android_JNI_GetNativeWindow(void); diff --git a/vs/sdl2/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/vs/sdl2/src/core/freebsd/SDL_evdev_kbd_freebsd.c index 57a4697258..a3c3456876 100644 --- a/vs/sdl2/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/vs/sdl2/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -88,7 +88,7 @@ static void kbd_cleanup(void) { struct mouse_info mData; SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; - if (kbd == NULL) { + if (!kbd) { return; } kbd_cleanup_state = NULL; @@ -179,7 +179,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -231,7 +231,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) SDL_zero(mData); mData.operation = MOUSE_HIDE; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(SDL_EVDEV_keyboard_state)); - if (kbd == NULL) { + if (!kbd) { return NULL; } @@ -297,7 +297,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { struct mouse_info mData; - if (kbd == NULL) { + if (!kbd) { return; } SDL_zero(mData); @@ -321,6 +321,18 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) SDL_free(kbd); } +void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) +{ +} + +void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) +{ +} + +void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) +{ +} + /* * Helper Functions. */ @@ -475,7 +487,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode, unsigned int final_key_state; unsigned int map_from_key_sym; - if (kbd == NULL) { + if (!kbd) { return; } diff --git a/vs/sdl2/src/core/gdk/SDL_gdk.cpp b/vs/sdl2/src/core/gdk/SDL_gdk.cpp index 61617fdcd9..0699568674 100644 --- a/vs/sdl2/src/core/gdk/SDL_gdk.cpp +++ b/vs/sdl2/src/core/gdk/SDL_gdk.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ extern "C" { static XTaskQueueHandle GDK_GlobalTaskQueue; PAPPSTATE_REGISTRATION hPLM = {}; +PAPPCONSTRAIN_REGISTRATION hCPLM = {}; HANDLE plmSuspendComplete = nullptr; extern "C" DECLSPEC int @@ -177,6 +178,23 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) return -1; } + /* Register constrain/unconstrain handling */ + auto raccn = [](BOOLEAN constrained, PVOID context) { + SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "[GDK] in RegisterAppConstrainedChangeNotification handler"); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (_this) { + if (constrained) { + SDL_SetKeyboardFocus(NULL); + } else { + SDL_SetKeyboardFocus(_this->windows); + } + } + }; + if (RegisterAppConstrainedChangeNotification(raccn, NULL, &hCPLM)) { + SDL_SetError("[GDK] Unable to call RegisterAppConstrainedChangeNotification"); + return -1; + } + /* Run the application main() code */ result = mainFunction(argc, argv); @@ -184,6 +202,9 @@ SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved) UnregisterAppStateChangeNotification(hPLM); CloseHandle(plmSuspendComplete); + /* Unregister constrain/unconstrain handling */ + UnregisterAppConstrainedChangeNotification(hCPLM); + /* !!! FIXME: This follows the docs exactly, but for some reason still leaks handles on exit? */ /* Terminate the task queue and dispatch any pending tasks */ XTaskQueueTerminate(taskQueue, false, nullptr, nullptr); @@ -218,3 +239,24 @@ SDL_GDKSuspendComplete() SetEvent(plmSuspendComplete); } } + +extern "C" DECLSPEC int +SDL_GDKGetDefaultUser(XUserHandle *outUserHandle) +{ + XAsyncBlock block = { 0 }; + HRESULT result; + + if (FAILED(result = XUserAddAsync(XUserAddOptions::AddDefaultUserAllowingUI, &block))) { + return WIN_SetErrorFromHRESULT("XUserAddAsync", result); + } + + do { + result = XUserAddResult(&block, outUserHandle); + } while (result == E_PENDING); + if (FAILED(result)) { + return WIN_SetErrorFromHRESULT("XUserAddResult", result); + } + + return 0; +} + diff --git a/vs/sdl2/src/core/gdk/SDL_gdk.h b/vs/sdl2/src/core/gdk/SDL_gdk.h index a49d0683dc..75f13ab816 100644 --- a/vs/sdl2/src/core/gdk/SDL_gdk.h +++ b/vs/sdl2/src/core/gdk/SDL_gdk.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_dbus.c b/vs/sdl2/src/core/linux/SDL_dbus.c index f2358343f2..7d706c2386 100644 --- a/vs/sdl2/src/core/linux/SDL_dbus.c +++ b/vs/sdl2/src/core/linux/SDL_dbus.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "SDL_sandbox.h" #include "../../stdlib/SDL_vacopy.h" -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS /* we never link directly to libdbus. */ #include "SDL_loadso.h" static const char *dbus_library = "libdbus-1.so.3"; @@ -99,7 +99,7 @@ static int LoadDBUSSyms(void) static void UnloadDBUSLibrary(void) { - if (dbus_handle != NULL) { + if (dbus_handle) { SDL_UnloadObject(dbus_handle); dbus_handle = NULL; } @@ -108,9 +108,9 @@ static void UnloadDBUSLibrary(void) static int LoadDBUSLibrary(void) { int retval = 0; - if (dbus_handle == NULL) { + if (!dbus_handle) { dbus_handle = SDL_LoadObject(dbus_library); - if (dbus_handle == NULL) { + if (!dbus_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -186,14 +186,13 @@ void SDL_DBus_Quit(void) dbus.connection_close(dbus.session_conn); dbus.connection_unref(dbus.session_conn); } -/* Don't do this - bug 3950 - dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it. -*/ -#if 0 - if (dbus.shutdown) { - dbus.shutdown(); + + if (SDL_GetHintBoolean(SDL_HINT_SHUTDOWN_DBUS_ON_QUIT, SDL_FALSE)) { + if (dbus.shutdown) { + dbus.shutdown(); + } } -#endif + SDL_zero(dbus); UnloadDBUSLibrary(); SDL_free(inhibit_handle); @@ -202,7 +201,7 @@ void SDL_DBus_Quit(void) SDL_DBusContext *SDL_DBus_GetContext(void) { - if (dbus_handle == NULL || !dbus.session_conn) { + if (!dbus_handle || !dbus.session_conn) { SDL_DBus_Init(); } @@ -363,7 +362,7 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char * void SDL_DBus_ScreensaverTickle(void) { - if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */ + if (screensaver_cookie == 0 && !inhibit_handle) { /* no need to tickle if we're inhibiting. */ /* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */ SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID); @@ -411,7 +410,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) { const char *default_inhibit_reason = "Playing a game"; - if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) { + if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) { return SDL_TRUE; } @@ -435,12 +434,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) const char *key = "reason"; const char *reply = NULL; const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME); - if (reason == NULL || !reason[0]) { + if (!reason || !reason[0]) { reason = default_inhibit_reason; } msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit"); - if (msg == NULL) { + if (!msg) { return SDL_FALSE; } @@ -477,10 +476,10 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit) if (inhibit) { const char *app = SDL_GetHint(SDL_HINT_APP_NAME); const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME); - if (app == NULL || !app[0]) { + if (!app || !app[0]) { app = "My SDL application"; } - if (reason == NULL || !reason[0]) { + if (!reason || !reason[0]) { reason = default_inhibit_reason; } @@ -534,6 +533,71 @@ char *SDL_DBus_GetLocalMachineId(void) return NULL; } + +/* + * Convert file drops with mime type "application/vnd.portal.filetransfer" to file paths + * Result must be freed with dbus->free_string_array(). + * https://flatpak.github.io/xdg-desktop-portal/#gdbus-method-org-freedesktop-portal-FileTransfer.RetrieveFiles + */ +char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *path_count) +{ + DBusError err; + DBusMessageIter iter, iterDict; + char **paths = NULL; + DBusMessage *reply = NULL; + DBusMessage *msg = dbus.message_new_method_call("org.freedesktop.portal.Documents", /* Node */ + "/org/freedesktop/portal/documents", /* Path */ + "org.freedesktop.portal.FileTransfer", /* Interface */ + "RetrieveFiles"); /* Method */ + + /* Make sure we have a connection to the dbus session bus */ + if (!SDL_DBus_GetContext() || !dbus.session_conn) { + /* We either cannot connect to the session bus or were unable to + * load the D-Bus library at all. */ + return NULL; + } + + dbus.error_init(&err); + + /* First argument is a "application/vnd.portal.filetransfer" key from a DnD or clipboard event */ + if (!dbus.message_append_args(msg, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { + SDL_OutOfMemory(); + dbus.message_unref(msg); + goto failed; + } + + /* Second argument is a variant dictionary for options. + * The spec doesn't define any entries yet so it's empty. */ + dbus.message_iter_init_append(msg, &iter); + if (!dbus.message_iter_open_container(&iter, DBUS_TYPE_ARRAY, "{sv}", &iterDict) || + !dbus.message_iter_close_container(&iter, &iterDict)) { + SDL_OutOfMemory(); + dbus.message_unref(msg); + goto failed; + } + + reply = dbus.connection_send_with_reply_and_block(dbus.session_conn, msg, DBUS_TIMEOUT_USE_DEFAULT, &err); + dbus.message_unref(msg); + + if (reply) { + dbus.message_get_args(reply, &err, DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &paths, path_count, DBUS_TYPE_INVALID); + dbus.message_unref(reply); + } + + if (paths) { + return paths; + } + +failed: + if (dbus.error_is_set(&err)) { + SDL_SetError("%s: %s", err.name, err.message); + dbus.error_free(&err); + } else { + SDL_SetError("Error retrieving paths for documents portal \"%s\"", key); + } + + return NULL; +} #endif /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/core/linux/SDL_dbus.h b/vs/sdl2/src/core/linux/SDL_dbus.h index cda279eca4..572ea47f94 100644 --- a/vs/sdl2/src/core/linux/SDL_dbus.h +++ b/vs/sdl2/src/core/linux/SDL_dbus.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +29,10 @@ #include "SDL_stdinc.h" #include +#ifndef DBUS_TIMEOUT_USE_DEFAULT +#define DBUS_TIMEOUT_USE_DEFAULT -1 +#endif + typedef struct SDL_DBusContext { DBusConnection *session_conn; @@ -98,6 +102,8 @@ extern SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit); extern char *SDL_DBus_GetLocalMachineId(void); +extern char **SDL_DBus_DocumentsPortalRetrieveFiles(const char *key, int *files_count); + #endif /* HAVE_DBUS_DBUS_H */ #endif /* SDL_dbus_h_ */ diff --git a/vs/sdl2/src/core/linux/SDL_evdev.c b/vs/sdl2/src/core/linux/SDL_evdev.c index e997aae492..e3b836cf75 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev.c +++ b/vs/sdl2/src/core/linux/SDL_evdev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -66,6 +66,7 @@ typedef struct SDL_evdevlist_item { char *path; int fd; + int udev_class; /* TODO: use this for every device, not just touchscreen */ SDL_bool out_of_sync; @@ -105,6 +106,8 @@ typedef struct SDL_evdevlist_item SDL_bool relative_mouse; int mouse_x, mouse_y; int mouse_wheel, mouse_hwheel; + int min_x, max_x, range_x; + int min_y, max_y, range_y; struct SDL_evdevlist_item *next; } SDL_evdevlist_item; @@ -127,7 +130,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item); static int SDL_EVDEV_device_removed(const char *dev_path); static int SDL_EVDEV_device_added(const char *dev_path, int udev_class); -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path); #endif /* SDL_USE_LIBUDEV */ @@ -148,15 +151,24 @@ static int SDL_EVDEV_SetRelativeMouseMode(SDL_bool enabled) return 0; } +static void SDL_EVDEV_UpdateKeyboardMute(void) +{ + if (SDL_EVDEV_GetDeviceCount(SDL_UDEV_DEVICE_KEYBOARD) > 0) { + SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_TRUE); + } else { + SDL_EVDEV_kbd_set_muted(_this->kbd, SDL_FALSE); + } +} + int SDL_EVDEV_Init(void) { - if (_this == NULL) { + if (!_this) { _this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); - if (_this == NULL) { + if (!_this) { return SDL_OutOfMemory(); } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV if (SDL_UDEV_Init() < 0) { SDL_free(_this); _this = NULL; @@ -201,6 +213,8 @@ int SDL_EVDEV_Init(void) #endif /* SDL_USE_LIBUDEV */ _this->kbd = SDL_EVDEV_kbd_init(); + + SDL_EVDEV_UpdateKeyboardMute(); } SDL_GetMouse()->SetRelativeMouseMode = SDL_EVDEV_SetRelativeMouseMode; @@ -212,25 +226,25 @@ int SDL_EVDEV_Init(void) void SDL_EVDEV_Quit(void) { - if (_this == NULL) { + if (!_this) { return; } _this->ref_count -= 1; if (_this->ref_count < 1) { -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV SDL_UDEV_DelCallback(SDL_EVDEV_udev_callback); SDL_UDEV_Quit(); #endif /* SDL_USE_LIBUDEV */ - SDL_EVDEV_kbd_quit(_this->kbd); - /* Remove existing devices */ - while (_this->first != NULL) { + while (_this->first) { SDL_EVDEV_device_removed(_this->first->path); } + SDL_EVDEV_kbd_quit(_this->kbd); + SDL_assert(_this->first == NULL); SDL_assert(_this->last == NULL); SDL_assert(_this->num_devices == 0); @@ -240,11 +254,11 @@ void SDL_EVDEV_Quit(void) } } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class, const char *dev_path) { - if (dev_path == NULL) { + if (!dev_path) { return; } @@ -269,6 +283,27 @@ static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_cl } #endif /* SDL_USE_LIBUDEV */ +void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data, + void (*acquire_callback)(void*), void *acquire_callback_data) +{ + SDL_EVDEV_kbd_set_vt_switch_callbacks(_this->kbd, + release_callback, release_callback_data, + acquire_callback, acquire_callback_data); +} + +int SDL_EVDEV_GetDeviceCount(int device_class) +{ + SDL_evdevlist_item *item; + int count = 0; + + for (item = _this->first; item; item = item->next) { + if ((item->udev_class & device_class) == device_class) { + ++count; + } + } + return count; +} + void SDL_EVDEV_Poll(void) { struct input_event events[32]; @@ -283,13 +318,15 @@ void SDL_EVDEV_Poll(void) return; } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV SDL_UDEV_Poll(); #endif + SDL_EVDEV_kbd_update(_this->kbd); + mouse = SDL_GetMouse(); - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { while ((len = read(item->fd, events, sizeof(events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { @@ -391,7 +428,6 @@ void SDL_EVDEV_Poll(void) } item->touchscreen_data->slots[0].x = events[i].value; } else if (!item->relative_mouse) { - /* FIXME: Normalize to input device's reported input range (EVIOCGABS) */ item->mouse_x = events[i].value; } break; @@ -402,7 +438,6 @@ void SDL_EVDEV_Poll(void) } item->touchscreen_data->slots[0].y = events[i].value; } else if (!item->relative_mouse) { - /* FIXME: Normalize to input device's reported input range (EVIOCGABS) */ item->mouse_y = events[i].value; } break; @@ -448,10 +483,20 @@ void SDL_EVDEV_Poll(void) switch (events[i].code) { case SYN_REPORT: /* Send mouse axis changes together to ensure consistency and reduce event processing overhead */ - if (item->mouse_x != 0 || item->mouse_y != 0) { - SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, item->mouse_x, item->mouse_y); - item->mouse_x = item->mouse_y = 0; + if (item->relative_mouse) { + if (item->mouse_x != 0 || item->mouse_y != 0) { + SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, item->mouse_x, item->mouse_y); + item->mouse_x = item->mouse_y = 0; + } + } else if (item->range_x > 0 && item->range_y > 0) { + /* TODO: test with multiple display scenarios */ + SDL_DisplayMode mode; + SDL_GetCurrentDisplayMode(0, &mode); + SDL_SendMouseMotion(mouse->focus, (SDL_MouseID)item->fd, item->relative_mouse, + (item->mouse_x - item->min_x) * mode.w / item->range_x, + (item->mouse_y - item->min_y) * mode.h / item->range_y); } + if (item->mouse_wheel != 0 || item->mouse_hwheel != 0) { SDL_SendMouseWheel(mouse->focus, (SDL_MouseID)item->fd, item->mouse_hwheel / (item->high_res_hwheel ? 120.0f : 1.0f), @@ -542,6 +587,32 @@ static SDL_Scancode SDL_EVDEV_translate_keycode(int keycode) return scancode; } +static int SDL_EVDEV_init_mouse(SDL_evdevlist_item *item, int udev_class) +{ + int ret; + struct input_absinfo abs_info; + + ret = ioctl(item->fd, EVIOCGABS(ABS_X), &abs_info); + if (ret < 0) { + // no absolute mode info, continue + return 0; + } + item->min_x = abs_info.minimum; + item->max_x = abs_info.maximum; + item->range_x = abs_info.maximum - abs_info.minimum; + + ret = ioctl(item->fd, EVIOCGABS(ABS_Y), &abs_info); + if (ret < 0) { + // no absolute mode info, continue + return 0; + } + item->min_y = abs_info.minimum; + item->max_y = abs_info.maximum; + item->range_y = abs_info.maximum - abs_info.minimum; + + return 0; +} + static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) { int ret, i; @@ -554,7 +625,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) } item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data)); - if (item->touchscreen_data == NULL) { + if (!item->touchscreen_data) { return SDL_OutOfMemory(); } @@ -565,7 +636,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) } item->touchscreen_data->name = SDL_strdup(name); - if (item->touchscreen_data->name == NULL) { + if (!item->touchscreen_data->name) { SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); } @@ -620,7 +691,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class) item->touchscreen_data->slots = SDL_calloc( item->touchscreen_data->max_slots, sizeof(*item->touchscreen_data->slots)); - if (item->touchscreen_data->slots == NULL) { + if (!item->touchscreen_data->slots) { SDL_free(item->touchscreen_data->name); SDL_free(item->touchscreen_data); return SDL_OutOfMemory(); @@ -681,7 +752,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item) sizeof(*mt_req_values) * item->touchscreen_data->max_slots; mt_req_code = SDL_calloc(1, mt_req_size); - if (mt_req_code == NULL) { + if (!mt_req_code) { return; } @@ -787,14 +858,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) unsigned long relbit[NBITS(REL_MAX)] = { 0 }; /* Check to make sure it's not already in list. */ - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { if (SDL_strcmp(dev_path, item->path) == 0) { return -1; /* already have this one */ } } item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -805,12 +876,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) } item->path = SDL_strdup(dev_path); - if (item->path == NULL) { + if (!item->path) { close(item->fd); SDL_free(item); return SDL_OutOfMemory(); } + item->udev_class = udev_class; + if (ioctl(item->fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0) { item->relative_mouse = test_bit(REL_X, relbit) && test_bit(REL_Y, relbit); item->high_res_wheel = test_bit(REL_WHEEL_HI_RES, relbit); @@ -827,9 +900,17 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) SDL_free(item); return ret; } + } else if (udev_class & SDL_UDEV_DEVICE_MOUSE) { + ret = SDL_EVDEV_init_mouse(item, udev_class); + if (ret < 0) { + close(item->fd); + SDL_free(item->path); + SDL_free(item); + return ret; + } } - if (_this->last == NULL) { + if (!_this->last) { _this->first = _this->last = item; } else { _this->last->next = item; @@ -838,6 +919,8 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class) SDL_EVDEV_sync_device(item); + SDL_EVDEV_UpdateKeyboardMute(); + return _this->num_devices++; } @@ -846,10 +929,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path) SDL_evdevlist_item *item; SDL_evdevlist_item *prev = NULL; - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(dev_path, item->path) == 0) { - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(_this->first == item); @@ -864,6 +947,7 @@ static int SDL_EVDEV_device_removed(const char *dev_path) close(item->fd); SDL_free(item->path); SDL_free(item); + SDL_EVDEV_UpdateKeyboardMute(); _this->num_devices--; return 0; } diff --git a/vs/sdl2/src/core/linux/SDL_evdev.h b/vs/sdl2/src/core/linux/SDL_evdev.h index 2681768bc5..c3e9c53694 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev.h +++ b/vs/sdl2/src/core/linux/SDL_evdev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 @@ extern int SDL_EVDEV_Init(void); extern void SDL_EVDEV_Quit(void); +extern void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *release_callback_data, + void (*acquire_callback)(void*), void *acquire_callback_data); +extern int SDL_EVDEV_GetDeviceCount(int device_class); extern void SDL_EVDEV_Poll(void); #endif /* SDL_INPUT_LINUXEV */ diff --git a/vs/sdl2/src/core/linux/SDL_evdev_capabilities.c b/vs/sdl2/src/core/linux/SDL_evdev_capabilities.c index b8f112b513..e1b5d74d1b 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_capabilities.c +++ b/vs/sdl2/src/core/linux/SDL_evdev_capabilities.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2020 Collabora Ltd. This software is provided 'as-is', without any express or implied @@ -23,7 +23,7 @@ #include "SDL_evdev_capabilities.h" -#if HAVE_LINUX_INPUT_H +#ifdef HAVE_LINUX_INPUT_H /* missing defines in older Linux kernel headers */ #ifndef BTN_TRIGGER_HAPPY diff --git a/vs/sdl2/src/core/linux/SDL_evdev_capabilities.h b/vs/sdl2/src/core/linux/SDL_evdev_capabilities.h index 8fcdcb6863..8d3830aec6 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_capabilities.h +++ b/vs/sdl2/src/core/linux/SDL_evdev_capabilities.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2020 Collabora Ltd. This software is provided 'as-is', without any express or implied @@ -24,7 +24,7 @@ #ifndef SDL_evdev_capabilities_h_ #define SDL_evdev_capabilities_h_ -#if HAVE_LINUX_INPUT_H +#ifdef HAVE_LINUX_INPUT_H #include diff --git a/vs/sdl2/src/core/linux/SDL_evdev_kbd.c b/vs/sdl2/src/core/linux/SDL_evdev_kbd.c index 632bbd248f..0aaefa0354 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_kbd.c +++ b/vs/sdl2/src/core/linux/SDL_evdev_kbd.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ static fn_handler_fn *fn_handler[] = { struct SDL_EVDEV_keyboard_state { int console_fd; + SDL_bool muted; int old_kbd_mode; unsigned short **key_maps; unsigned char shift_down[NR_SHIFT]; /* shift state counters.. */ @@ -99,6 +100,10 @@ struct SDL_EVDEV_keyboard_state char shift_state; char text[128]; unsigned int text_len; + void (*vt_release_callback)(void *); + void *vt_release_callback_data; + void (*vt_acquire_callback)(void *); + void *vt_acquire_callback_data; }; #ifdef DUMP_ACCENTS @@ -169,7 +174,7 @@ static int fatal_signals[] = { static void kbd_cleanup(void) { SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state; - if (kbd == NULL) { + if (!kbd) { return; } kbd_cleanup_state = NULL; @@ -254,7 +259,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx, signum; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -296,6 +301,126 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) } } +enum { + VT_SIGNAL_NONE, + VT_SIGNAL_RELEASE, + VT_SIGNAL_ACQUIRE, +}; +static int vt_release_signal; +static int vt_acquire_signal; +static SDL_atomic_t vt_signal_pending; + +typedef void (*signal_handler)(int signum); + +static void kbd_vt_release_signal_action(int signum) +{ + SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_RELEASE); +} + +static void kbd_vt_acquire_signal_action(int signum) +{ + SDL_AtomicSet(&vt_signal_pending, VT_SIGNAL_ACQUIRE); +} + +static SDL_bool setup_vt_signal(int signum, signal_handler handler) +{ + struct sigaction *old_action_p; + struct sigaction new_action; + old_action_p = &(old_sigaction[signum]); + SDL_zero(new_action); + new_action.sa_handler = handler; + new_action.sa_flags = SA_RESTART; + if (sigaction(signum, &new_action, old_action_p) < 0) { + return SDL_FALSE; + } + if (old_action_p->sa_handler != SIG_DFL) { + /* This signal is already in use */ + sigaction(signum, old_action_p, NULL); + return SDL_FALSE; + } + return SDL_TRUE; +} + +static int find_free_signal(signal_handler handler) +{ +#ifdef SIGRTMIN + int i; + + for (i = SIGRTMIN + 2; i <= SIGRTMAX; ++i) { + if (setup_vt_signal(i, handler)) { + return i; + } + } +#endif + if (setup_vt_signal(SIGUSR1, handler)) { + return SIGUSR1; + } + if (setup_vt_signal(SIGUSR2, handler)) { + return SIGUSR2; + } + return 0; +} + +static void kbd_vt_quit(int console_fd) +{ + struct vt_mode mode; + + if (vt_release_signal) { + sigaction(vt_release_signal, &old_sigaction[vt_release_signal], NULL); + vt_release_signal = 0; + } + if (vt_acquire_signal) { + sigaction(vt_acquire_signal, &old_sigaction[vt_acquire_signal], NULL); + vt_acquire_signal = 0; + } + + SDL_zero(mode); + mode.mode = VT_AUTO; + ioctl(console_fd, VT_SETMODE, &mode); +} + +static int kbd_vt_init(int console_fd) +{ + struct vt_mode mode; + + vt_release_signal = find_free_signal(kbd_vt_release_signal_action); + vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action); + if (!vt_release_signal || !vt_acquire_signal) { + kbd_vt_quit(console_fd); + return -1; + } + + SDL_zero(mode); + mode.mode = VT_PROCESS; + mode.relsig = vt_release_signal; + mode.acqsig = vt_acquire_signal; + mode.frsig = SIGIO; + if (ioctl(console_fd, VT_SETMODE, &mode) < 0) { + kbd_vt_quit(console_fd); + return -1; + } + return 0; +} + +static void kbd_vt_update(SDL_EVDEV_keyboard_state *state) +{ + int signal_pending = SDL_AtomicGet(&vt_signal_pending); + if (signal_pending != VT_SIGNAL_NONE) { + if (signal_pending == VT_SIGNAL_RELEASE) { + if (state->vt_release_callback) { + state->vt_release_callback(state->vt_release_callback_data); + } + ioctl(state->console_fd, VT_RELDISP, 1); + } else { + if (state->vt_acquire_callback) { + state->vt_acquire_callback(state->vt_acquire_callback_data); + } + ioctl(state->console_fd, VT_RELDISP, VT_ACKACQ); + } + SDL_AtomicCAS(&vt_signal_pending, signal_pending, VT_SIGNAL_NONE); + } +} + SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) { SDL_EVDEV_keyboard_state *kbd; @@ -304,7 +429,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) char shift_state[sizeof(long)] = { TIOCL_GETSHIFTSTATE, 0 }; kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd)); - if (kbd == NULL) { + if (!kbd) { return NULL; } @@ -333,35 +458,77 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) ioctl(kbd->console_fd, KDSKBMODE, K_UNICODE); } - /* Allow inhibiting keyboard mute with env. variable for debugging etc. */ - if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) { - /* Mute the keyboard so keystrokes only generate evdev events - * and do not leak through to the console - */ - ioctl(kbd->console_fd, KDSKBMODE, K_OFF); + kbd_vt_init(kbd->console_fd); - /* Make sure to restore keyboard if application fails to call - * SDL_Quit before exit or fatal signal is raised. - */ - if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { - kbd_register_emerg_cleanup(kbd); - } - } return kbd; } -void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) +void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) { - if (state == NULL) { + if (!state) { return; } - kbd_unregister_emerg_cleanup(); + if (muted == state->muted) { + return; + } + + if (muted) { + /* Allow inhibiting keyboard mute with env. variable for debugging etc. */ + if (SDL_getenv("SDL_INPUT_LINUX_KEEP_KBD") == NULL) { + /* Mute the keyboard so keystrokes only generate evdev events + * and do not leak through to the console + */ + ioctl(state->console_fd, KDSKBMODE, K_OFF); + + /* Make sure to restore keyboard if application fails to call + * SDL_Quit before exit or fatal signal is raised. + */ + if (!SDL_GetHintBoolean(SDL_HINT_NO_SIGNAL_HANDLERS, SDL_FALSE)) { + kbd_register_emerg_cleanup(state); + } + } + } else { + kbd_unregister_emerg_cleanup(); - if (state->console_fd >= 0) { /* Restore the original keyboard mode */ ioctl(state->console_fd, KDSKBMODE, state->old_kbd_mode); + } + state->muted = muted; +} +void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) +{ + if (!state) { + return; + } + + state->vt_release_callback = release_callback; + state->vt_release_callback_data = release_callback_data; + state->vt_acquire_callback = acquire_callback; + state->vt_acquire_callback_data = acquire_callback_data; +} + +void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) +{ + if (!state) { + return; + } + + kbd_vt_update(state); +} + +void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) +{ + if (!state) { + return; + } + + SDL_EVDEV_kbd_set_muted(state, SDL_FALSE); + + kbd_vt_quit(state->console_fd); + + if (state->console_fd >= 0) { close(state->console_fd); state->console_fd = -1; } @@ -726,7 +893,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode unsigned short *key_map; unsigned short keysym; - if (state == NULL) { + if (!state) { return; } @@ -734,7 +901,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode shift_final = (state->shift_state | state->slockstate) ^ state->lockstate; key_map = state->key_maps[shift_final]; - if (key_map == NULL) { + if (!key_map) { /* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */ state->shift_state = 0; state->slockstate = 0; @@ -809,6 +976,18 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void) return NULL; } +void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) +{ +} + +void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) +{ +} + +void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) +{ +} + void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down) { } diff --git a/vs/sdl2/src/core/linux/SDL_evdev_kbd.h b/vs/sdl2/src/core/linux/SDL_evdev_kbd.h index 8105ab8be1..52a4778e8d 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_kbd.h +++ b/vs/sdl2/src/core/linux/SDL_evdev_kbd.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 @@ struct SDL_EVDEV_keyboard_state; typedef struct SDL_EVDEV_keyboard_state SDL_EVDEV_keyboard_state; extern SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void); +extern void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted); +extern void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data); +extern void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state); extern void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode, int down); extern void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state); diff --git a/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_accents.h b/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_accents.h index 4b33a17ca9..d0d5234557 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_accents.h +++ b/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_accents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_keymap.h b/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_keymap.h index 04e71277df..d744a54a29 100644 --- a/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_keymap.h +++ b/vs/sdl2/src/core/linux/SDL_evdev_kbd_default_keymap.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_fcitx.c b/vs/sdl2/src/core/linux/SDL_fcitx.c index 5f76a626ef..88b6d06f40 100644 --- a/vs/sdl2/src/core/linux/SDL_fcitx.c +++ b/vs/sdl2/src/core/linux/SDL_fcitx.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../events/SDL_keyboard_c.h" #include "SDL_dbus.h" #include "SDL_syswm.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 # include "../../video/x11/SDL_x11video.h" #endif #include "SDL_hints.h" @@ -438,7 +438,7 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } @@ -449,7 +449,7 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) SDL_GetWindowPosition(focused_win, &x, &y); -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 if (info.subsystem == SDL_SYSWM_X11) { SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; diff --git a/vs/sdl2/src/core/linux/SDL_fcitx.h b/vs/sdl2/src/core/linux/SDL_fcitx.h index 3e5699e74f..4a893f2f94 100644 --- a/vs/sdl2/src/core/linux/SDL_fcitx.h +++ b/vs/sdl2/src/core/linux/SDL_fcitx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_ibus.c b/vs/sdl2/src/core/linux/SDL_ibus.c index 4241cd4ad2..31179d4fa2 100644 --- a/vs/sdl2/src/core/linux/SDL_ibus.c +++ b/vs/sdl2/src/core/linux/SDL_ibus.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../video/SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "../../video/x11/SDL_x11video.h" #endif @@ -112,7 +112,7 @@ static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, S } dbus->message_iter_get_basic(inside, &struct_id); - if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) { + if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) { return SDL_FALSE; } return SDL_TRUE; @@ -306,7 +306,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path) FILE *addr_file; addr_file = fopen(file_path, "r"); - if (addr_file == NULL) { + if (!addr_file) { return NULL; } @@ -351,7 +351,7 @@ static char *IBus_GetDBusAddressFilename(void) } dbus = SDL_DBus_GetContext(); - if (dbus == NULL) { + if (!dbus) { return NULL; } @@ -365,7 +365,7 @@ static char *IBus_GetDBusAddressFilename(void) and look up the address from a filepath using all those bits, eek. */ disp_env = SDL_getenv("DISPLAY"); - if (disp_env == NULL || !*disp_env) { + if (!disp_env || !*disp_env) { display = SDL_strdup(":0.0"); } else { display = SDL_strdup(disp_env); @@ -375,7 +375,7 @@ static char *IBus_GetDBusAddressFilename(void) disp_num = SDL_strrchr(display, ':'); screen_num = SDL_strrchr(display, '.'); - if (disp_num == NULL) { + if (!disp_num) { SDL_free(display); return NULL; } @@ -389,7 +389,7 @@ static char *IBus_GetDBusAddressFilename(void) if (!*host) { const char *session = SDL_getenv("XDG_SESSION_TYPE"); - if (session != NULL && SDL_strcmp(session, "wayland") == 0) { + if (session && SDL_strcmp(session, "wayland") == 0) { host = "unix-wayland"; } else { host = "unix"; @@ -403,7 +403,7 @@ static char *IBus_GetDBusAddressFilename(void) SDL_strlcpy(config_dir, conf_env, sizeof(config_dir)); } else { const char *home_env = SDL_getenv("HOME"); - if (home_env == NULL || !*home_env) { + if (!home_env || !*home_env) { SDL_free(display); return NULL; } @@ -412,7 +412,7 @@ static char *IBus_GetDBusAddressFilename(void) key = SDL_DBus_GetLocalMachineId(); - if (key == NULL) { + if (!key) { SDL_free(display); return NULL; } @@ -473,7 +473,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) ibus_input_interface = IBUS_INPUT_INTERFACE; ibus_conn = dbus->connection_open_private(addr, NULL); - if (ibus_conn == NULL) { + if (!ibus_conn) { return SDL_FALSE; /* oh well. */ } @@ -513,7 +513,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr) static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) { - if (dbus == NULL) { + if (!dbus) { return SDL_FALSE; } @@ -533,7 +533,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus) struct inotify_event *event = (struct inotify_event *)p; if (event->len > 0) { char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/'); - if (addr_file_no_path == NULL) { + if (!addr_file_no_path) { return SDL_FALSE; } @@ -570,19 +570,21 @@ SDL_bool SDL_IBus_Init(void) char *addr; char *addr_file_dir; - if (addr_file == NULL) { + if (!addr_file) { return SDL_FALSE; } - /* !!! FIXME: if ibus_addr_file != NULL, this will overwrite it and leak (twice!) */ - ibus_addr_file = SDL_strdup(addr_file); - addr = IBus_ReadAddressFromFile(addr_file); - if (addr == NULL) { + if (!addr) { SDL_free(addr_file); return SDL_FALSE; } + if (ibus_addr_file) { + SDL_free(ibus_addr_file); + } + ibus_addr_file = SDL_strdup(addr_file); + if (inotify_fd < 0) { inotify_fd = inotify_init(); fcntl(inotify_fd, F_SETFL, O_NONBLOCK); @@ -659,7 +661,7 @@ static void IBus_SimpleMessage(const char *method) { SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) { + if ((input_ctx_path) && (IBus_CheckConnection(dbus))) { SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, method, DBUS_TYPE_INVALID); } } @@ -710,7 +712,7 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } @@ -721,7 +723,7 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) SDL_GetWindowPosition(focused_win, &x, &y); -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 if (info.subsystem == SDL_SYSWM_X11) { SDL_DisplayData *displaydata = (SDL_DisplayData *) SDL_GetDisplayForWindow(focused_win)->driverdata; diff --git a/vs/sdl2/src/core/linux/SDL_ibus.h b/vs/sdl2/src/core/linux/SDL_ibus.h index da00741dfb..a4ea140b5c 100644 --- a/vs/sdl2/src/core/linux/SDL_ibus.h +++ b/vs/sdl2/src/core/linux/SDL_ibus.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_ime.c b/vs/sdl2/src/core/linux/SDL_ime.c index f40e83c5aa..6c28e5f6b5 100644 --- a/vs/sdl2/src/core/linux/SDL_ime.c +++ b/vs/sdl2/src/core/linux/SDL_ime.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +56,9 @@ static void InitIME() /* See if fcitx IME support is being requested */ #ifdef HAVE_FCITX - if (SDL_IME_Init_Real == NULL && + if (!SDL_IME_Init_Real && ((im_module && SDL_strcmp(im_module, "fcitx") == 0) || - (im_module == NULL && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) { + (!im_module && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) { SDL_IME_Init_Real = SDL_Fcitx_Init; SDL_IME_Quit_Real = SDL_Fcitx_Quit; SDL_IME_SetFocus_Real = SDL_Fcitx_SetFocus; @@ -71,7 +71,7 @@ static void InitIME() /* default to IBus */ #ifdef HAVE_IBUS_IBUS_H - if (SDL_IME_Init_Real == NULL) { + if (!SDL_IME_Init_Real) { SDL_IME_Init_Real = SDL_IBus_Init; SDL_IME_Quit_Real = SDL_IBus_Quit; SDL_IME_SetFocus_Real = SDL_IBus_SetFocus; diff --git a/vs/sdl2/src/core/linux/SDL_ime.h b/vs/sdl2/src/core/linux/SDL_ime.h index 8e4851be8b..0c1e2d07ed 100644 --- a/vs/sdl2/src/core/linux/SDL_ime.h +++ b/vs/sdl2/src/core/linux/SDL_ime.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/linux/SDL_sandbox.c b/vs/sdl2/src/core/linux/SDL_sandbox.c index 1539031727..e93e183015 100644 --- a/vs/sdl2/src/core/linux/SDL_sandbox.c +++ b/vs/sdl2/src/core/linux/SDL_sandbox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2022 Collabora Ltd. This software is provided 'as-is', without any express or implied diff --git a/vs/sdl2/src/core/linux/SDL_sandbox.h b/vs/sdl2/src/core/linux/SDL_sandbox.h index eecac07491..4e66918067 100644 --- a/vs/sdl2/src/core/linux/SDL_sandbox.h +++ b/vs/sdl2/src/core/linux/SDL_sandbox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2022 Collabora Ltd. This software is provided 'as-is', without any express or implied diff --git a/vs/sdl2/src/core/linux/SDL_threadprio.c b/vs/sdl2/src/core/linux/SDL_threadprio.c index 57406c6dfc..80d448e472 100644 --- a/vs/sdl2/src/core/linux/SDL_threadprio.c +++ b/vs/sdl2/src/core/linux/SDL_threadprio.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_stdinc.h" #include "SDL_thread.h" -#if !SDL_THREADS_DISABLED +#ifndef SDL_THREADS_DISABLED #include #include #include @@ -44,7 +44,7 @@ #include "SDL_dbus.h" -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS #include /* d-bus queries to org.freedesktop.RealtimeKit1. */ @@ -116,19 +116,19 @@ static void rtkit_initialize() dbus_conn = get_rtkit_dbus_connection(); /* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel", DBUS_TYPE_INT32, &rtkit_min_nice_level)) { rtkit_min_nice_level = -20; } /* Try getting maximum realtime priority: this can be less than the POSIX default (99). */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority", DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) { rtkit_max_realtime_priority = 99; } /* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */ - if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax", + if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax", DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) { rtkit_max_rttime_usec = 200000; } @@ -207,7 +207,7 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level) nice = rtkit_min_nice_level; } - if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn, + if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID", DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID, DBUS_TYPE_INVALID)) { @@ -238,7 +238,7 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) // go through to determine whether it really needs to fail or not. rtkit_initialize_realtime_thread(); - if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn, + if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID", DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID, DBUS_TYPE_INVALID)) { @@ -256,14 +256,14 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority) /* this is a public symbol, so it has to exist even if threads are disabled. */ int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return SDL_Unsupported(); #else if (setpriority(PRIO_PROCESS, (id_t)threadID, priority) == 0) { return 0; } -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS /* Note that this fails you most likely: * Have your process's scheduler incorrectly configured. See the requirements at: @@ -288,7 +288,7 @@ int SDL_LinuxSetThreadPriority(Sint64 threadID, int priority) /* this is a public symbol, so it has to exist even if threads are disabled. */ int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int schedPolicy) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return SDL_Unsupported(); #else int osPriority; @@ -319,7 +319,7 @@ int SDL_LinuxSetThreadPriorityAndPolicy(Sint64 threadID, int sdlPriority, int sc } } -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS /* Note that this fails you most likely: * Have your process's scheduler incorrectly configured. See the requirements at: diff --git a/vs/sdl2/src/core/linux/SDL_udev.c b/vs/sdl2/src/core/linux/SDL_udev.c index 39368c7e00..5bdfc0db81 100644 --- a/vs/sdl2/src/core/linux/SDL_udev.c +++ b/vs/sdl2/src/core/linux/SDL_udev.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ #ifdef SDL_USE_LIBUDEV #include +#include #include "SDL_assert.h" #include "SDL_evdev_capabilities.h" @@ -47,12 +48,15 @@ static _THIS = NULL; static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr); static int SDL_UDEV_load_syms(void); static SDL_bool SDL_UDEV_hotplug_update_available(void); +static void get_caps(struct udev_device *dev, struct udev_device *pdev, const char *attr, unsigned long *bitmask, size_t bitmask_len); +static int guess_device_class(struct udev_device *dev); +static int device_class(struct udev_device *dev); static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev); static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(_this->udev_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return SDL_FALSE; } @@ -100,7 +104,7 @@ static int SDL_UDEV_load_syms(void) static SDL_bool SDL_UDEV_hotplug_update_available(void) { - if (_this->udev_mon != NULL) { + if (_this->udev_mon) { const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon); if (SDL_IOReady(fd, SDL_IOR_READ, 0)) { return SDL_TRUE; @@ -113,9 +117,9 @@ int SDL_UDEV_Init(void) { int retval = 0; - if (_this == NULL) { + if (!_this) { _this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this)); - if (_this == NULL) { + if (!_this) { return SDL_OutOfMemory(); } @@ -130,13 +134,13 @@ int SDL_UDEV_Init(void) */ _this->udev = _this->syms.udev_new(); - if (_this->udev == NULL) { + if (!_this->udev) { SDL_UDEV_Quit(); return SDL_SetError("udev_new() failed"); } _this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev"); - if (_this->udev_mon == NULL) { + if (!_this->udev_mon) { SDL_UDEV_Quit(); return SDL_SetError("udev_monitor_new_from_netlink() failed"); } @@ -158,7 +162,7 @@ void SDL_UDEV_Quit(void) { SDL_UDEV_CallbackList *item; - if (_this == NULL) { + if (!_this) { return; } @@ -166,17 +170,17 @@ void SDL_UDEV_Quit(void) if (_this->ref_count < 1) { - if (_this->udev_mon != NULL) { + if (_this->udev_mon) { _this->syms.udev_monitor_unref(_this->udev_mon); _this->udev_mon = NULL; } - if (_this->udev != NULL) { + if (_this->udev) { _this->syms.udev_unref(_this->udev); _this->udev = NULL; } /* Remove existing devices */ - while (_this->first != NULL) { + while (_this->first) { item = _this->first; _this->first = _this->first->next; SDL_free(item); @@ -194,12 +198,12 @@ void SDL_UDEV_Scan(void) struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; - if (_this == NULL) { + if (!_this) { return; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_UDEV_Quit(); SDL_SetError("udev_enumerate_new() failed"); return; @@ -213,7 +217,7 @@ void SDL_UDEV_Scan(void) for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { + if (dev) { device_event(SDL_UDEV_DEVICEADDED, dev); _this->syms.udev_device_unref(dev); } @@ -222,66 +226,70 @@ void SDL_UDEV_Scan(void) _this->syms.udev_enumerate_unref(enumerate); } -SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version) +SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class) { - struct udev_enumerate *enumerate = NULL; - struct udev_list_entry *devs = NULL; - struct udev_list_entry *item = NULL; - SDL_bool found = SDL_FALSE; + struct stat statbuf; + char type; + struct udev_device *dev; + const char* val; + int class_temp; - if (_this == NULL) { + if (!_this) { return SDL_FALSE; } - enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { - SDL_SetError("udev_enumerate_new() failed"); + if (stat(device_path, &statbuf) == -1) { return SDL_FALSE; } - _this->syms.udev_enumerate_scan_devices(enumerate); - devs = _this->syms.udev_enumerate_get_list_entry(enumerate); - for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) { - const char *path = _this->syms.udev_list_entry_get_name(item); - struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { - const char *val = NULL; - const char *existing_path; + if (S_ISBLK(statbuf.st_mode)) { + type = 'b'; + } + else if (S_ISCHR(statbuf.st_mode)) { + type = 'c'; + } + else { + return SDL_FALSE; + } - existing_path = _this->syms.udev_device_get_devnode(dev); - if (existing_path && SDL_strcmp(device_path, existing_path) == 0) { - found = SDL_TRUE; + dev = _this->syms.udev_device_new_from_devnum(_this->udev, type, statbuf.st_rdev); - val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID"); - if (val != NULL) { - *vendor = (Uint16)SDL_strtol(val, NULL, 16); - } + if (!dev) { + return SDL_FALSE; + } - val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID"); - if (val != NULL) { - *product = (Uint16)SDL_strtol(val, NULL, 16); - } + val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID"); + if (val) { + *vendor = (Uint16)SDL_strtol(val, NULL, 16); + } - val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION"); - if (val != NULL) { - *version = (Uint16)SDL_strtol(val, NULL, 16); - } - } - _this->syms.udev_device_unref(dev); - } + val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID"); + if (val) { + *product = (Uint16)SDL_strtol(val, NULL, 16); } - _this->syms.udev_enumerate_unref(enumerate); - return found; + val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION"); + if (val) { + *version = (Uint16)SDL_strtol(val, NULL, 16); + } + + class_temp = device_class(dev); + if (class_temp) { + *class = class_temp; + } + + _this->syms.udev_device_unref(dev); + + return SDL_TRUE; } void SDL_UDEV_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { return; } - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { SDL_UnloadObject(_this->udev_handle); _this->udev_handle = NULL; } @@ -291,7 +299,7 @@ int SDL_UDEV_LoadLibrary(void) { int retval = 0, i; - if (_this == NULL) { + if (!_this) { return SDL_SetError("UDEV not initialized"); } @@ -302,9 +310,9 @@ int SDL_UDEV_LoadLibrary(void) #ifdef SDL_UDEV_DYNAMIC /* Check for the build environment's libudev first */ - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC); - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); @@ -313,10 +321,10 @@ int SDL_UDEV_LoadLibrary(void) } #endif - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) { _this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]); - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { retval = SDL_UDEV_load_syms(); if (retval < 0) { SDL_UDEV_UnloadLibrary(); @@ -326,7 +334,7 @@ int SDL_UDEV_LoadLibrary(void) } } - if (_this->udev_handle == NULL) { + if (!_this->udev_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } @@ -345,7 +353,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch SDL_memset(bitmask, 0, bitmask_len * sizeof(*bitmask)); value = _this->syms.udev_device_get_sysattr_value(pdev, attr); - if (value == NULL) { + if (!value) { return; } @@ -379,7 +387,7 @@ static int guess_device_class(struct udev_device *dev) while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) { pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL); } - if (pdev == NULL) { + if (!pdev) { return 0; } @@ -394,43 +402,40 @@ static int guess_device_class(struct udev_device *dev) &bitmask_rel[0]); } -static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) +static int device_class(struct udev_device *dev) { const char *subsystem; const char *val = NULL; int devclass = 0; - const char *path; - SDL_UDEV_CallbackList *item; - path = _this->syms.udev_device_get_devnode(dev); - if (path == NULL) { - return; + subsystem = _this->syms.udev_device_get_subsystem(dev); + if (!subsystem) { + return 0; } - subsystem = _this->syms.udev_device_get_subsystem(dev); if (SDL_strcmp(subsystem, "sound") == 0) { devclass = SDL_UDEV_DEVICE_SOUND; } else if (SDL_strcmp(subsystem, "input") == 0) { /* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER"); if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) && - val != NULL && SDL_strcmp(val, "1") == 0) { + val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_JOYSTICK; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_MOUSE; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN; } @@ -441,34 +446,49 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183 */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_KEYBOARD; } if (devclass == 0) { /* Fall back to old style input classes */ val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS"); - if (val != NULL) { + if (val) { if (SDL_strcmp(val, "joystick") == 0) { devclass = SDL_UDEV_DEVICE_JOYSTICK; } else if (SDL_strcmp(val, "mouse") == 0) { devclass = SDL_UDEV_DEVICE_MOUSE; } else if (SDL_strcmp(val, "kbd") == 0) { devclass = SDL_UDEV_DEVICE_KEYBOARD; - } else { - return; } } else { /* We could be linked with libudev on a system that doesn't have udev running */ devclass = guess_device_class(dev); } } - } else { + } + + return devclass; +} + +static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) +{ + int devclass = 0; + const char *path; + SDL_UDEV_CallbackList *item; + + path = _this->syms.udev_device_get_devnode(dev); + if (!path) { return; } + devclass = device_class(dev); + if (!devclass) { + return; + } + /* Process callbacks */ - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { item->callback(type, devclass, path); } } @@ -478,13 +498,13 @@ void SDL_UDEV_Poll(void) struct udev_device *dev = NULL; const char *action = NULL; - if (_this == NULL) { + if (!_this) { return; } while (SDL_UDEV_hotplug_update_available()) { dev = _this->syms.udev_monitor_receive_device(_this->udev_mon); - if (dev == NULL) { + if (!dev) { break; } action = _this->syms.udev_device_get_action(dev); @@ -505,13 +525,13 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb) { SDL_UDEV_CallbackList *item; item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } item->callback = cb; - if (_this->last == NULL) { + if (!_this->last) { _this->first = _this->last = item; } else { _this->last->next = item; @@ -526,14 +546,14 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb) SDL_UDEV_CallbackList *item; SDL_UDEV_CallbackList *prev = NULL; - if (_this == NULL) { + if (!_this) { return; } - for (item = _this->first; item != NULL; item = item->next) { + for (item = _this->first; item; item = item->next) { /* found it, remove it. */ if (item->callback == cb) { - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(_this->first == item); diff --git a/vs/sdl2/src/core/linux/SDL_udev.h b/vs/sdl2/src/core/linux/SDL_udev.h index b8920b71c9..1489a852b4 100644 --- a/vs/sdl2/src/core/linux/SDL_udev.h +++ b/vs/sdl2/src/core/linux/SDL_udev.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ #ifndef SDL_udev_h_ #define SDL_udev_h_ -#if HAVE_LIBUDEV_H && HAVE_LINUX_INPUT_H +#if defined(HAVE_LIBUDEV_H) && defined(HAVE_LINUX_INPUT_H) #ifndef SDL_USE_LIBUDEV #define SDL_USE_LIBUDEV 1 @@ -103,7 +103,7 @@ extern void SDL_UDEV_UnloadLibrary(void); extern int SDL_UDEV_LoadLibrary(void); extern void SDL_UDEV_Poll(void); extern void SDL_UDEV_Scan(void); -extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version); +extern SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 *product, Uint16 *version, int *class); extern int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb); extern void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb); extern const SDL_UDEV_Symbols *SDL_UDEV_GetUdevSyms(void); diff --git a/vs/sdl2/src/core/openbsd/SDL_wscons.h b/vs/sdl2/src/core/openbsd/SDL_wscons.h index e53e574238..40e102d005 100644 --- a/vs/sdl2/src/core/openbsd/SDL_wscons.h +++ b/vs/sdl2/src/core/openbsd/SDL_wscons.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/openbsd/SDL_wscons_kbd.c b/vs/sdl2/src/core/openbsd/SDL_wscons_kbd.c index 583c420141..975ba82363 100644 --- a/vs/sdl2/src/core/openbsd/SDL_wscons_kbd.c +++ b/vs/sdl2/src/core/openbsd/SDL_wscons_kbd.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -423,7 +423,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) #endif SDL_WSCONS_input_data *input = (SDL_WSCONS_input_data *)SDL_calloc(1, sizeof(SDL_WSCONS_input_data)); - if (input == NULL) { + if (!input) { return input; } input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC); @@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) return NULL; } input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES); - if (input->keymap.map == NULL) { + if (!input->keymap.map) { free(input); return NULL; } @@ -583,7 +583,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input) keysym_t *group; keysym_t ksym, result; - if (input == NULL) { + if (!input) { return; } if ((n = read(input->fd, events, sizeof(events))) > 0) { @@ -927,7 +927,7 @@ void SDL_WSCONS_PumpEvents() for (i = 0; i < 4; i++) { updateKeyboard(inputs[i]); } - if (mouseInputData != NULL) { + if (mouseInputData) { updateMouse(mouseInputData); } } diff --git a/vs/sdl2/src/core/openbsd/SDL_wscons_mouse.c b/vs/sdl2/src/core/openbsd/SDL_wscons_mouse.c index 617cea7bca..5a8664c035 100644 --- a/vs/sdl2/src/core/openbsd/SDL_wscons_mouse.c +++ b/vs/sdl2/src/core/openbsd/SDL_wscons_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse() #endif SDL_WSCONS_mouse_input_data *mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data)); - if (mouseInputData == NULL) { + if (!mouseInputData) { return NULL; } mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC); @@ -126,7 +126,7 @@ void updateMouse(SDL_WSCONS_mouse_input_data *inputData) void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData) { - if (inputData == NULL) { + if (!inputData) { return; } close(inputData->fd); diff --git a/vs/sdl2/src/core/os2/SDL_os2.c b/vs/sdl2/src/core/os2/SDL_os2.c index 66d15a4358..76ad59d4a9 100644 --- a/vs/sdl2/src/core/os2/SDL_os2.c +++ b/vs/sdl2/src/core/os2/SDL_os2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/os2/SDL_os2.h b/vs/sdl2/src/core/os2/SDL_os2.h index a7deec2f65..9f88c70c4f 100644 --- a/vs/sdl2/src/core/os2/SDL_os2.h +++ b/vs/sdl2/src/core/os2/SDL_os2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/os2/geniconv/geniconv.c b/vs/sdl2/src/core/os2/geniconv/geniconv.c index f85e8b3ada..df9c7c78dc 100644 --- a/vs/sdl2/src/core/os2/geniconv/geniconv.c +++ b/vs/sdl2/src/core/os2/geniconv/geniconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/os2/geniconv/geniconv.h b/vs/sdl2/src/core/os2/geniconv/geniconv.h index 5c3f9592b2..463255b96c 100644 --- a/vs/sdl2/src/core/os2/geniconv/geniconv.h +++ b/vs/sdl2/src/core/os2/geniconv/geniconv.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/os2/geniconv/os2cp.c b/vs/sdl2/src/core/os2/geniconv/os2cp.c index ae8bec7b4b..36d808eed2 100644 --- a/vs/sdl2/src/core/os2/geniconv/os2cp.c +++ b/vs/sdl2/src/core/os2/geniconv/os2cp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -357,7 +357,7 @@ unsigned long os2cpFromName(char *cp) PCHAR pcEnd; CHAR acBuf[64]; - if (cp == NULL) { + if (!cp) { ULONG aulCP[3]; ULONG cCP; return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0]; @@ -368,7 +368,7 @@ unsigned long os2cpFromName(char *cp) } pcEnd = SDL_strchr(cp, ' '); - if (pcEnd == NULL) { + if (!pcEnd) { pcEnd = SDL_strchr(cp, '\0'); } ulNext = pcEnd - cp; diff --git a/vs/sdl2/src/core/os2/geniconv/os2cp.h b/vs/sdl2/src/core/os2/geniconv/os2cp.h index 7f5be10502..7024e9daf5 100644 --- a/vs/sdl2/src/core/os2/geniconv/os2cp.h +++ b/vs/sdl2/src/core/os2/geniconv/os2cp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/os2/geniconv/os2iconv.c b/vs/sdl2/src/core/os2/geniconv/os2iconv.c index 0e75484cfb..4c6a024e2f 100644 --- a/vs/sdl2/src/core/os2/geniconv/os2iconv.c +++ b/vs/sdl2/src/core/os2/geniconv/os2iconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -76,7 +76,7 @@ static int _createUconvObj(const char *code, UconvObject *uobj) const unsigned char *ch = (const unsigned char *)code; - if (code == NULL) + if (!code) uc_code[0] = 0; else { for (i = 0; i < MAX_CP_NAME_LEN; i++) { @@ -119,10 +119,10 @@ iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode) int rc; iuconv_obj *iuobj; - if (tocode == NULL) { + if (!tocode) { tocode = ""; } - if (fromcode == NULL) { + if (!fromcode) { fromcode = ""; } @@ -169,7 +169,7 @@ size_t _System os2_iconv(iconv_t cd, int rc; size_t ret = (size_t)(-1); - if (uo_tocode == NULL && uo_fromcode == NULL) { + if (!uo_tocode && !uo_fromcode) { uc_buf_len = SDL_min(*inbytesleft, *outbytesleft); SDL_memcpy(*outbuf, *inbuf, uc_buf_len); *inbytesleft -= uc_buf_len; diff --git a/vs/sdl2/src/core/os2/geniconv/sys2utf8.c b/vs/sdl2/src/core/os2/geniconv/sys2utf8.c index 1c8be8a179..75dd7dd641 100644 --- a/vs/sdl2/src/core/os2/geniconv/sys2utf8.c +++ b/vs/sdl2/src/core/os2/geniconv/sys2utf8.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +95,7 @@ char *StrUTF8New(int to_utf8, char *str, int c_str) int c_newstr = (((c_str > 4) ? c_str : 4) + 1) * 2; char * newstr = (char *) SDL_malloc(c_newstr); - if (newstr == NULL) { + if (!newstr) { return NULL; } diff --git a/vs/sdl2/src/core/os2/geniconv/test.c b/vs/sdl2/src/core/os2/geniconv/test.c index 2214b9789a..2fe19acef3 100644 --- a/vs/sdl2/src/core/os2/geniconv/test.c +++ b/vs/sdl2/src/core/os2/geniconv/test.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int main(void) { char acBuf[128]; - char *inbuf = "ôÅÓÔ - ÐÒÏ×ÅÒËÁ"; /* KOI8-R string */ + char *inbuf = "\xf4\xc5\xd3\xd4\x20\x2d\x20\xd0\xd2\xcf\xd7\xc5\xd2\xcb\xc1"; /* KOI8-R encoding of "ТеÑÑ‚ - проверка" */ size_t inbytesleft = strlen(inbuf); char *outbuf = acBuf; size_t outbytesleft = sizeof(acBuf); diff --git a/vs/sdl2/src/core/unix/SDL_poll.c b/vs/sdl2/src/core/unix/SDL_poll.c index 9254981d5b..1a34c57d2e 100644 --- a/vs/sdl2/src/core/unix/SDL_poll.c +++ b/vs/sdl2/src/core/unix/SDL_poll.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/unix/SDL_poll.h b/vs/sdl2/src/core/unix/SDL_poll.h index f862673521..67e52ecdad 100644 --- a/vs/sdl2/src/core/unix/SDL_poll.h +++ b/vs/sdl2/src/core/unix/SDL_poll.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/windows/SDL_directx.h b/vs/sdl2/src/core/windows/SDL_directx.h index 6c2ad7da13..98c63ec376 100644 --- a/vs/sdl2/src/core/windows/SDL_directx.h +++ b/vs/sdl2/src/core/windows/SDL_directx.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/windows/SDL_hid.c b/vs/sdl2/src/core/windows/SDL_hid.c index 40829502e9..60b9d14eb1 100644 --- a/vs/sdl2/src/core/windows/SDL_hid.c +++ b/vs/sdl2/src/core/windows/SDL_hid.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +58,9 @@ int WIN_LoadHIDDLL(void) SDL_HidP_GetValueCaps = (HidP_GetValueCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetValueCaps"); SDL_HidP_MaxDataListLength = (HidP_MaxDataListLength_t)GetProcAddress(s_pHIDDLL, "HidP_MaxDataListLength"); SDL_HidP_GetData = (HidP_GetData_t)GetProcAddress(s_pHIDDLL, "HidP_GetData"); - if (SDL_HidD_GetManufacturerString == NULL || SDL_HidD_GetProductString == NULL || - SDL_HidP_GetCaps == NULL || SDL_HidP_GetButtonCaps == NULL || - SDL_HidP_GetValueCaps == NULL || SDL_HidP_MaxDataListLength == NULL || SDL_HidP_GetData == NULL) { + if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString || + !SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps || + !SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) { WIN_UnloadHIDDLL(); return -1; } diff --git a/vs/sdl2/src/core/windows/SDL_hid.h b/vs/sdl2/src/core/windows/SDL_hid.h index d1348b7a56..f75ea24af4 100644 --- a/vs/sdl2/src/core/windows/SDL_hid.h +++ b/vs/sdl2/src/core/windows/SDL_hid.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/windows/SDL_immdevice.c b/vs/sdl2/src/core/windows/SDL_immdevice.c index d2900f9ccf..a8e8b458a7 100644 --- a/vs/sdl2/src/core/windows/SDL_immdevice.c +++ b/vs/sdl2/src/core/windows/SDL_immdevice.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if (defined(__WIN32__) || defined(__GDK__)) && HAVE_MMDEVICEAPI_H +#if (defined(__WIN32__) || defined(__GDK__)) && defined(HAVE_MMDEVICEAPI_H) #include "SDL_windows.h" #include "SDL_immdevice.h" @@ -136,7 +136,7 @@ static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAV } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } @@ -364,7 +364,7 @@ int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) SDL_assert(device != NULL); while (SDL_TRUE) { - if (devid == NULL) { + if (!devid) { const EDataFlow dataflow = iscapture ? eCapture : eRender; ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, device); } else { @@ -443,7 +443,7 @@ static void EnumerateEndpointsForFlow(const SDL_bool iscapture) } items = (EndpointItem *)SDL_calloc(total, sizeof(EndpointItem)); - if (items == NULL) { + if (!items) { return; /* oh well. */ } @@ -500,7 +500,7 @@ int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int isca return WIN_SetErrorFromHRESULT("WASAPI can't find default audio endpoint", ret); } - if (name == NULL) { + if (!name) { name = &filler; } diff --git a/vs/sdl2/src/core/windows/SDL_immdevice.h b/vs/sdl2/src/core/windows/SDL_immdevice.h index e5b7008cb8..b15b903359 100644 --- a/vs/sdl2/src/core/windows/SDL_immdevice.h +++ b/vs/sdl2/src/core/windows/SDL_immdevice.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/windows/SDL_windows.c b/vs/sdl2/src/core/windows/SDL_windows.c index 350198eb7e..1da9418131 100644 --- a/vs/sdl2/src/core/windows/SDL_windows.c +++ b/vs/sdl2/src/core/windows/SDL_windows.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -285,7 +285,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid) } strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR)); - if (strw == NULL) { + if (!strw) { RegCloseKey(hkey); return WIN_StringToUTF8(name); /* oh well. */ } diff --git a/vs/sdl2/src/core/windows/SDL_windows.h b/vs/sdl2/src/core/windows/SDL_windows.h index 3842e082b4..2bd6257d1a 100644 --- a/vs/sdl2/src/core/windows/SDL_windows.h +++ b/vs/sdl2/src/core/windows/SDL_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #endif #undef WINVER #undef _WIN32_WINNT -#if defined(SDL_VIDEO_RENDER_D3D12) +#if SDL_VIDEO_RENDER_D3D12 #define _WIN32_WINNT 0xA00 /* For D3D12, 0xA00 is required */ #elif defined(HAVE_SHELLSCALINGAPI_H) #define _WIN32_WINNT 0x603 /* For DPI support */ @@ -92,16 +92,6 @@ #include #include /* for REFIID with broken mingw.org headers */ -/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ -#if defined(_MSC_VER) && (_MSC_VER <= 1200) -#ifndef DWORD_PTR -#define DWORD_PTR DWORD -#endif -#ifndef LONG_PTR -#define LONG_PTR LONG -#endif -#endif - #include "SDL_rect.h" /* Routines to convert from UTF8 to native Windows text */ diff --git a/vs/sdl2/src/core/windows/SDL_xinput.c b/vs/sdl2/src/core/windows/SDL_xinput.c index 1ebefcf2c4..053473e0cb 100644 --- a/vs/sdl2/src/core/windows/SDL_xinput.c +++ b/vs/sdl2/src/core/windows/SDL_xinput.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ extern "C" { XInputGetState_t SDL_XInputGetState = NULL; XInputSetState_t SDL_XInputSetState = NULL; XInputGetCapabilities_t SDL_XInputGetCapabilities = NULL; +XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx = NULL; XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation = NULL; DWORD SDL_XInputVersion = 0; @@ -106,13 +107,15 @@ int WIN_LoadXInputDLL(void) /* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */ SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100); - if (SDL_XInputGetState == NULL) { + if (!SDL_XInputGetState) { SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState"); } SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState"); SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities"); + /* 108 is the ordinal for _XInputGetCapabilitiesEx, which additionally returns VID/PID of the controller. */ + SDL_XInputGetCapabilitiesEx = (XInputGetCapabilitiesEx_t)GetProcAddress(s_pXInputDLL, (LPCSTR)108); SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation"); - if (SDL_XInputGetState == NULL || SDL_XInputSetState == NULL || SDL_XInputGetCapabilities == NULL) { + if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) { WIN_UnloadXInputDLL(); return -1; } diff --git a/vs/sdl2/src/core/windows/SDL_xinput.h b/vs/sdl2/src/core/windows/SDL_xinput.h index acdd8d5d4c..efdb86282e 100644 --- a/vs/sdl2/src/core/windows/SDL_xinput.h +++ b/vs/sdl2/src/core/windows/SDL_xinput.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #ifdef HAVE_XINPUT_H #if defined(__XBOXONE__) || defined(__XBOXSERIES__) /* Xbox supports an XInput wrapper which is a C++-only header... */ +#include /* Required to compile with recent MSVC... */ #include using namespace XInputOnGameInput; #else @@ -44,6 +45,9 @@ using namespace XInputOnGameInput; #ifndef XINPUT_CAPS_FFB_SUPPORTED #define XINPUT_CAPS_FFB_SUPPORTED 0x0001 #endif +#ifndef XINPUT_CAPS_WIRELESS +#define XINPUT_CAPS_WIRELESS 0x0002 +#endif #ifndef XINPUT_DEVSUBTYPE_UNKNOWN #define XINPUT_DEVSUBTYPE_UNKNOWN 0x00 @@ -163,28 +167,8 @@ extern "C" { /* typedef's for XInput structs we use */ -#ifndef HAVE_XINPUT_GAMEPAD_EX -typedef struct -{ - WORD wButtons; - BYTE bLeftTrigger; - BYTE bRightTrigger; - SHORT sThumbLX; - SHORT sThumbLY; - SHORT sThumbRX; - SHORT sThumbRY; - DWORD dwPaddingReserved; -} XINPUT_GAMEPAD_EX; -#endif - -#ifndef HAVE_XINPUT_STATE_EX -typedef struct -{ - DWORD dwPacketNumber; - XINPUT_GAMEPAD_EX Gamepad; -} XINPUT_STATE_EX; -#endif +/* This is the same as XINPUT_BATTERY_INFORMATION, but always defined instead of just if WIN32_WINNT >= _WIN32_WINNT_WIN8 */ typedef struct { BYTE BatteryType; @@ -204,6 +188,12 @@ typedef struct SHORT sThumbRY; } XINPUT_GAMEPAD; +typedef struct +{ + DWORD dwPacketNumber; + XINPUT_GAMEPAD Gamepad; +} XINPUT_STATE; + typedef struct { WORD wLeftMotorSpeed; @@ -221,10 +211,21 @@ typedef struct #endif /* HAVE_XINPUT_H */ +/* This struct is not defined in XInput headers. */ +typedef struct +{ + XINPUT_CAPABILITIES Capabilities; + WORD VendorId; + WORD ProductId; + WORD ProductVersion; + WORD unk1; + DWORD unk2; +} SDL_XINPUT_CAPABILITIES_EX; + /* Forward decl's for XInput API's we load dynamically and use if available */ typedef DWORD(WINAPI *XInputGetState_t)( DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ - XINPUT_STATE_EX *pState /* [out] Receives the current state */ + XINPUT_STATE *pState /* [out] Receives the current state */ ); typedef DWORD(WINAPI *XInputSetState_t)( @@ -238,6 +239,14 @@ typedef DWORD(WINAPI *XInputGetCapabilities_t)( XINPUT_CAPABILITIES *pCapabilities /* [out] Receives the capabilities */ ); +/* Only available in XInput 1.4 that is shipped with Windows 8 and newer. */ +typedef DWORD(WINAPI *XInputGetCapabilitiesEx_t)( + DWORD dwReserved, /* [in] Must be 1 */ + DWORD dwUserIndex, /* [in] Index of the gamer associated with the device */ + DWORD dwFlags, /* [in] Input flags that identify the device type */ + SDL_XINPUT_CAPABILITIES_EX *pCapabilitiesEx /* [out] Receives the capabilities */ +); + typedef DWORD(WINAPI *XInputGetBatteryInformation_t)( DWORD dwUserIndex, BYTE devType, @@ -249,6 +258,7 @@ extern void WIN_UnloadXInputDLL(void); extern XInputGetState_t SDL_XInputGetState; extern XInputSetState_t SDL_XInputSetState; extern XInputGetCapabilities_t SDL_XInputGetCapabilities; +extern XInputGetCapabilitiesEx_t SDL_XInputGetCapabilitiesEx; extern XInputGetBatteryInformation_t SDL_XInputGetBatteryInformation; extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ @@ -260,6 +270,7 @@ extern DWORD SDL_XInputVersion; /* ((major << 16) & 0xFF00) | (minor & 0xFF) */ #define XINPUTGETSTATE SDL_XInputGetState #define XINPUTSETSTATE SDL_XInputSetState #define XINPUTGETCAPABILITIES SDL_XInputGetCapabilities +#define XINPUTGETCAPABILITIESEX SDL_XInputGetCapabilitiesEx #define XINPUTGETBATTERYINFORMATION SDL_XInputGetBatteryInformation #endif /* SDL_xinput_h_ */ diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_common.cpp b/vs/sdl2/src/core/winrt/SDL_winrtapp_common.cpp index 52618b2bc1..9d16492374 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_common.cpp +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_common.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_common.h b/vs/sdl2/src/core/winrt/SDL_winrtapp_common.h index e1a89df018..fdc8294da9 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_common.h +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_common.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.cpp b/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.cpp index 5fe6f33148..0115c5da48 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,12 +20,6 @@ */ #include "../../SDL_internal.h" -/* Standard C++11 includes */ -#include -#include -#include -using namespace std; - /* Windows includes */ #include "ppltasks.h" using namespace concurrency; @@ -39,7 +33,7 @@ using namespace Windows::System; using namespace Windows::UI::Core; using namespace Windows::UI::Input; -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE using namespace Windows::Phone::UI::Input; #endif @@ -64,7 +58,7 @@ extern "C" { #include "SDL_winrtapp_common.h" #include "SDL_winrtapp_direct3d.h" -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 /* Calling IDXGIDevice3::Trim on the active Direct3D 11.x device is necessary * when Windows 8.1 apps are about to get suspended. */ @@ -126,7 +120,7 @@ static void WINRT_ProcessWindowSizeChange() // TODO: Pass an SDL_Window-identify int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width); int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height); -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8) +#if SDL_WINAPI_FAMILY_PHONE && (NTDDI_VERSION == NTDDI_WIN8) /* WinPhone 8.0 always keeps its native window size in portrait, regardless of orientation. This changes in WinPhone 8.1, in which the native window's size changes along with @@ -227,7 +221,7 @@ void SDL_WinRTApp::OnOrientationChanged(Object ^ sender) WINRT_ProcessWindowSizeChange(); -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE // HACK: Make sure that orientation changes // lead to the Direct3D renderer's viewport getting updated: // @@ -273,7 +267,7 @@ void SDL_WinRTApp::SetWindow(CoreWindow ^ window) window->Closed += ref new TypedEventHandler(this, &SDL_WinRTApp::OnWindowClosed); -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#if !SDL_WINAPI_FAMILY_PHONE window->PointerCursor = ref new CoreCursor(CoreCursorType::Arrow, 0); #endif @@ -295,7 +289,7 @@ void SDL_WinRTApp::SetWindow(CoreWindow ^ window) window->PointerWheelChanged += ref new TypedEventHandler(this, &SDL_WinRTApp::OnPointerWheelChanged); -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#if !SDL_WINAPI_FAMILY_PHONE // Retrieves relative-only mouse movements: Windows::Devices::Input::MouseDevice::GetForCurrentView()->MouseMoved += ref new TypedEventHandler(this, &SDL_WinRTApp::OnMouseMoved); @@ -313,7 +307,7 @@ void SDL_WinRTApp::SetWindow(CoreWindow ^ window) #if NTDDI_VERSION >= NTDDI_WIN10 Windows::UI::Core::SystemNavigationManager::GetForCurrentView()->BackRequested += ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); -#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#elif SDL_WINAPI_FAMILY_PHONE HardwareButtons::BackPressed += ref new EventHandler(this, &SDL_WinRTApp::OnBackButtonPressed); #endif @@ -348,7 +342,7 @@ void SDL_WinRTApp::Run() // representation of command line arguments. int argc = 1; char **argv = (char **)SDL_malloc(2 * sizeof(*argv)); - if (argv == NULL) { + if (!argv) { return; } argv[0] = SDL_strdup("WinRTApp"); @@ -555,7 +549,7 @@ void SDL_WinRTApp::OnWindowActivated(CoreWindow ^ sender, WindowActivatedEventAr Don't do it on WinPhone 8.0 though, as CoreWindow's 'PointerPosition' property isn't available. */ -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION >= NTDDI_WINBLUE) +#if !SDL_WINAPI_FAMILY_PHONE || (NTDDI_VERSION >= NTDDI_WINBLUE) Point cursorPos = WINRT_TransformCursorPosition(window, sender->PointerPosition, TransformToSDLWindowSize); SDL_SendMouseMotion(window, 0, 0, (int)cursorPos.X, (int)cursorPos.Y); #endif @@ -628,7 +622,7 @@ void SDL_WinRTApp::OnSuspending(Platform::Object ^ sender, SuspendingEventArgs ^ // Let the Direct3D 11 renderer prepare for the app to be backgrounded. // This is necessary for Windows 8.1, possibly elsewhere in the future. // More details at: http://msdn.microsoft.com/en-us/library/windows/apps/Hh994929.aspx -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 if (WINRT_GlobalSDLWindow) { SDL_Renderer *renderer = SDL_GetRenderer(WINRT_GlobalSDLWindow); if (renderer && (SDL_strcmp(renderer->info.name, "direct3d11") == 0)) { @@ -762,7 +756,7 @@ void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::C { WINRT_OnBackButtonPressed(args); } -#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#elif SDL_WINAPI_FAMILY_PHONE void SDL_WinRTApp::OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args) { diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.h b/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.h index 0208a6a4dc..fcd6ab791c 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.h +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_direct3d.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ ref class SDL_WinRTApp sealed : public Windows::ApplicationModel::Core::IFramewo #if NTDDI_VERSION >= NTDDI_WIN10 void OnBackButtonPressed(Platform::Object ^ sender, Windows::UI::Core::BackRequestedEventArgs ^ args); -#elif WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#elif SDL_WINAPI_FAMILY_PHONE void OnBackButtonPressed(Platform::Object ^ sender, Windows::Phone::UI::Input::BackPressedEventArgs ^ args); #endif diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.cpp b/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.cpp index 118f64bb65..9174f0d23c 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.cpp +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -88,7 +88,7 @@ static void WINRT_OnRenderViaXAML(_In_ Platform::Object ^ sender, _In_ Platform: int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPanelAsIInspectable) { -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE return SDL_SetError("XAML support is not yet available in Windows Phone."); #else // Declare C++/CX namespaces: @@ -143,5 +143,5 @@ int SDL_WinRTInitXAMLApp(int (*mainFunction)(int, char **), void *backgroundPane // All done, for now. return 0; -#endif // WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else +#endif // SDL_WINAPI_FAMILY_PHONE / else } diff --git a/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.h b/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.h index 5ee15e8990..b41475383b 100644 --- a/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.h +++ b/vs/sdl2/src/core/winrt/SDL_winrtapp_xaml.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/cpuinfo/SDL_cpuinfo.c b/vs/sdl2/src/cpuinfo/SDL_cpuinfo.c index 337ae335af..34aa424eb3 100644 --- a/vs/sdl2/src/cpuinfo/SDL_cpuinfo.c +++ b/vs/sdl2/src/cpuinfo/SDL_cpuinfo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +57,7 @@ #elif defined(__FreeBSD__) && defined(__powerpc__) #include #include -#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP +#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) #include #include #endif @@ -123,7 +123,7 @@ #define CPU_CFG2_LSX (1 << 6) #define CPU_CFG2_LASX (1 << 7) -#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__ && !__FreeBSD__ +#if defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) && !defined(__MACOSX__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) /* This is the brute force way of detecting instruction sets... the idea is borrowed from the libmpeg2 library - thanks! */ @@ -352,7 +352,7 @@ static int CPU_haveAltiVec(void) elf_aux_info(AT_HWCAP, &cpufeatures, sizeof(cpufeatures)); altivec = cpufeatures & PPC_FEATURE_HAS_ALTIVEC; return altivec; -#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP +#elif defined(SDL_ALTIVEC_BLITTERS) && defined(HAVE_SETJMP) void (*handler)(int sig); handler = signal(SIGILL, illegal_instruction); if (setjmp(jmpbuf) == 0) { @@ -468,9 +468,9 @@ static int CPU_haveNEON(void) return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0; #elif (defined(__ARM_ARCH) && (__ARM_ARCH >= 8)) || defined(__aarch64__) return 1; /* ARMv8 always has non-optional NEON support. */ -#elif __VITA__ +#elif defined(__VITA__) return 1; -#elif __3DS__ +#elif defined(__3DS__) return 0; #elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */ @@ -1079,16 +1079,19 @@ int SDL_GetSystemRAM(void) #endif #ifdef HAVE_SYSCTLBYNAME if (SDL_SystemRAM <= 0) { -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__DragonFly__) -#ifdef HW_REALMEM +#ifdef HW_PHYSMEM64 + /* (64-bit): NetBSD since 2003, OpenBSD */ + int mib[2] = { CTL_HW, HW_PHYSMEM64 }; +#elif defined(HW_REALMEM) + /* (64-bit): FreeBSD since 2005, DragonFly */ int mib[2] = { CTL_HW, HW_REALMEM }; +#elif defined(HW_MEMSIZE) + /* (64-bit): Darwin */ + int mib[2] = { CTL_HW, HW_MEMSIZE }; #else - /* might only report up to 2 GiB */ + /* (32-bit): very old BSD, might only report up to 2 GiB */ int mib[2] = { CTL_HW, HW_PHYSMEM }; -#endif /* HW_REALMEM */ -#else - int mib[2] = { CTL_HW, HW_MEMSIZE }; -#endif /* __FreeBSD__ || __FreeBSD_kernel__ */ +#endif /* HW_PHYSMEM64 */ Uint64 memsize = 0; size_t len = sizeof(memsize); @@ -1198,7 +1201,7 @@ void *SDL_SIMDRealloc(void *mem, const size_t len) ptr = (Uint8 *)SDL_realloc(mem, to_allocate); - if (ptr == NULL) { + if (!ptr) { return NULL; /* Out of memory, bail! */ } diff --git a/vs/sdl2/src/dynapi/SDL2.exports b/vs/sdl2/src/dynapi/SDL2.exports index 696e2be9d5..5b67182783 100644 --- a/vs/sdl2/src/dynapi/SDL2.exports +++ b/vs/sdl2/src/dynapi/SDL2.exports @@ -870,3 +870,5 @@ # ++'_SDL_GDKSuspendComplete'.'SDL2.dll'.'SDL_GDKSuspendComplete' ++'_SDL_HasWindowSurface'.'SDL2.dll'.'SDL_HasWindowSurface' ++'_SDL_DestroyWindowSurface'.'SDL2.dll'.'SDL_DestroyWindowSurface' +# ++'_SDL_GDKGetDefaultUser'.'SDL2.dll'.'SDL_GDKGetDefaultUser' +++'_SDL_GameControllerGetSteamHandle'.'SDL2.dll'.'SDL_GameControllerGetSteamHandle' diff --git a/vs/sdl2/src/dynapi/SDL_dynapi.c b/vs/sdl2/src/dynapi/SDL_dynapi.c index 6151f0148b..861f88a55d 100644 --- a/vs/sdl2/src/dynapi/SDL_dynapi.c +++ b/vs/sdl2/src/dynapi/SDL_dynapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -195,7 +195,7 @@ static SDL_DYNAPI_jump_table jump_table = { SDL_InitDynamicAPI(); \ ret jump_table.fn args; \ } -#define SDL_DYNAPI_PROC_NO_VARARGS 1 +#define SDL_DYNAPI_PROC_NO_VARARGS #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS @@ -212,7 +212,7 @@ SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI()) { \ ret jump_table.fn args; \ } -#define SDL_DYNAPI_PROC_NO_VARARGS 1 +#define SDL_DYNAPI_PROC_NO_VARARGS #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS @@ -295,7 +295,7 @@ SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Error, ERROR) SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Critical, CRITICAL) #define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \ rc SDLCALL fn##_LOGSDLCALLS params { SDL_Log_REAL("SDL2CALL %s", #fn); ret fn##_REAL args; } -#define SDL_DYNAPI_PROC_NO_VARARGS 1 +#define SDL_DYNAPI_PROC_NO_VARARGS #include "SDL_dynapi_procs.h" #undef SDL_DYNAPI_PROC #undef SDL_DYNAPI_PROC_NO_VARARGS @@ -372,7 +372,7 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) void *retval = NULL; if (lib) { retval = (void *) GetProcAddress(lib, sym); - if (retval == NULL) { + if (!retval) { FreeLibrary(lib); } } @@ -385,9 +385,9 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym) { void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL); void *retval = NULL; - if (lib != NULL) { + if (lib) { retval = dlsym(lib, sym); - if (retval == NULL) { + if (!retval) { dlclose(lib); } } @@ -505,7 +505,7 @@ static void SDL_InitDynamicAPI(void) /* SDL_AtomicLock calls SDL mutex functions to emulate if SDL_ATOMIC_DISABLED, which we can't do here, so in such a configuration, you're on your own. */ - #if !SDL_ATOMIC_DISABLED + #ifndef SDL_ATOMIC_DISABLED static SDL_SpinLock lock = 0; SDL_AtomicLock_REAL(&lock); #endif @@ -515,7 +515,7 @@ static void SDL_InitDynamicAPI(void) already_initialized = SDL_TRUE; } - #if !SDL_ATOMIC_DISABLED + #ifndef SDL_ATOMIC_DISABLED SDL_AtomicUnlock_REAL(&lock); #endif } diff --git a/vs/sdl2/src/dynapi/SDL_dynapi.h b/vs/sdl2/src/dynapi/SDL_dynapi.h index 99ca08008f..95b20aaefa 100644 --- a/vs/sdl2/src/dynapi/SDL_dynapi.h +++ b/vs/sdl2/src/dynapi/SDL_dynapi.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #define SDL_DYNAMIC_API 0 #elif defined(SDL_BUILDING_WINRT) && SDL_BUILDING_WINRT /* probably not useful on WinRT, given current .dll loading restrictions */ #define SDL_DYNAMIC_API 0 -#elif defined(__PS2__) && __PS2__ +#elif defined(__PS2__) #define SDL_DYNAMIC_API 0 #elif defined(__PSP__) && __PSP__ #define SDL_DYNAMIC_API 0 diff --git a/vs/sdl2/src/dynapi/SDL_dynapi_overrides.h b/vs/sdl2/src/dynapi/SDL_dynapi_overrides.h index 0b59a21749..f57c5222e1 100644 --- a/vs/sdl2/src/dynapi/SDL_dynapi_overrides.h +++ b/vs/sdl2/src/dynapi/SDL_dynapi_overrides.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -896,3 +896,5 @@ #define SDL_GDKSuspendComplete SDL_GDKSuspendComplete_REAL #define SDL_HasWindowSurface SDL_HasWindowSurface_REAL #define SDL_DestroyWindowSurface SDL_DestroyWindowSurface_REAL +#define SDL_GDKGetDefaultUser SDL_GDKGetDefaultUser_REAL +#define SDL_GameControllerGetSteamHandle SDL_GameControllerGetSteamHandle_REAL diff --git a/vs/sdl2/src/dynapi/SDL_dynapi_procs.h b/vs/sdl2/src/dynapi/SDL_dynapi_procs.h index 8e1d36d063..7f5d325252 100644 --- a/vs/sdl2/src/dynapi/SDL_dynapi_procs.h +++ b/vs/sdl2/src/dynapi/SDL_dynapi_procs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +30,7 @@ */ /* direct jump magic can use these, the rest needs special code. */ -#if !SDL_DYNAPI_PROC_NO_VARARGS +#ifndef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_PROC(int,SDL_SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return) SDL_DYNAPI_PROC(void,SDL_Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),) SDL_DYNAPI_PROC(void,SDL_LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),) @@ -888,7 +888,7 @@ SDL_DYNAPI_PROC(void*,SDL_GetTextureUserData,(SDL_Texture *a),(a),return) SDL_DYNAPI_PROC(int,SDL_RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const SDL_Vertex *c, int d, const int *e, int f),(a,b,c,d,e,f),return) SDL_DYNAPI_PROC(int,SDL_RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_Color *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return) SDL_DYNAPI_PROC(int,SDL_RenderSetVSync,(SDL_Renderer *a, int b),(a,b),return) -#if !SDL_DYNAPI_PROC_NO_VARARGS +#ifndef SDL_DYNAPI_PROC_NO_VARARGS SDL_DYNAPI_PROC(int,SDL_asprintf,(char **a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return) #endif SDL_DYNAPI_PROC(int,SDL_vasprintf,(char **a, const char *b, va_list c),(a,b,c),return) @@ -981,3 +981,7 @@ SDL_DYNAPI_PROC(void,SDL_GDKSuspendComplete,(void),(),) #endif SDL_DYNAPI_PROC(SDL_bool,SDL_HasWindowSurface,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_DestroyWindowSurface,(SDL_Window *a),(a),return) +#if defined(__GDK__) +SDL_DYNAPI_PROC(int,SDL_GDKGetDefaultUser,(XUserHandle *a),(a),return) +#endif +SDL_DYNAPI_PROC(Uint64,SDL_GameControllerGetSteamHandle,(SDL_GameController *a),(a),return) diff --git a/vs/sdl2/src/dynapi/gendynapi.pl b/vs/sdl2/src/dynapi/gendynapi.pl index 47509f8479..dad2bc4878 100755 --- a/vs/sdl2/src/dynapi/gendynapi.pl +++ b/vs/sdl2/src/dynapi/gendynapi.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Simple DirectMedia Layer -# Copyright (C) 1997-2023 Sam Lantinga +# Copyright (C) 1997-2024 Sam Lantinga # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_clipboardevents.c b/vs/sdl2/src/events/SDL_clipboardevents.c index 050807450f..68b9a76366 100644 --- a/vs/sdl2/src/events/SDL_clipboardevents.c +++ b/vs/sdl2/src/events/SDL_clipboardevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_clipboardevents_c.h b/vs/sdl2/src/events/SDL_clipboardevents_c.h index abbdb1f493..77e2e42e43 100644 --- a/vs/sdl2/src/events/SDL_clipboardevents_c.h +++ b/vs/sdl2/src/events/SDL_clipboardevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_displayevents.c b/vs/sdl2/src/events/SDL_displayevents.c index ec5e158bb7..9777d5d7a2 100644 --- a/vs/sdl2/src/events/SDL_displayevents.c +++ b/vs/sdl2/src/events/SDL_displayevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data { int posted; - if (display == NULL) { + if (!display) { return 0; } switch (displayevent) { diff --git a/vs/sdl2/src/events/SDL_displayevents_c.h b/vs/sdl2/src/events/SDL_displayevents_c.h index 0f0c9d3dd5..d2e2b57648 100644 --- a/vs/sdl2/src/events/SDL_displayevents_c.h +++ b/vs/sdl2/src/events/SDL_displayevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_dropevents.c b/vs/sdl2/src/events/SDL_dropevents.c index 3665a17d20..7c7cc56072 100644 --- a/vs/sdl2/src/events/SDL_dropevents.c +++ b/vs/sdl2/src/events/SDL_dropevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_dropevents_c.h b/vs/sdl2/src/events/SDL_dropevents_c.h index 1a7864720f..83177a8757 100644 --- a/vs/sdl2/src/events/SDL_dropevents_c.h +++ b/vs/sdl2/src/events/SDL_dropevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_events.c b/vs/sdl2/src/events/SDL_events.c index 05c2bf830c..b432703b4d 100644 --- a/vs/sdl2/src/events/SDL_events.c +++ b/vs/sdl2/src/events/SDL_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,19 +28,12 @@ #include "SDL_events_c.h" #include "../SDL_hints_c.h" #include "../timer/SDL_timer_c.h" -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED #include "../joystick/SDL_joystick_c.h" #endif #include "../video/SDL_sysvideo.h" #include "SDL_syswm.h" -#undef SDL_PRIs64 -#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__CYGWIN__) -#define SDL_PRIs64 "I64d" -#else -#define SDL_PRIs64 "lld" -#endif - /* An arbitrary limit so we don't have unbounded growth */ #define SDL_MAX_QUEUED_EVENTS 65535 @@ -98,7 +91,7 @@ static struct SDL_SysWMEntry *wmmsg_free; } SDL_EventQ = { NULL, SDL_FALSE, { 0 }, 0, NULL, NULL, NULL, NULL, NULL }; -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED static SDL_bool SDL_update_joysticks = SDL_TRUE; @@ -119,7 +112,7 @@ static void SDLCALL SDL_AutoUpdateJoysticksChanged(void *userdata, const char *n #endif /* !SDL_JOYSTICK_DISABLED */ -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED static SDL_bool SDL_update_sensors = SDL_TRUE; @@ -425,6 +418,9 @@ static void SDL_LogEvent(const SDL_Event *event) SDL_EVENT_CASE(SDL_CONTROLLERDEVICEREMAPPED) PRINT_CONTROLLERDEV_EVENT(event); break; + SDL_EVENT_CASE(SDL_CONTROLLERSTEAMHANDLEUPDATED) + PRINT_CONTROLLERDEV_EVENT(event); + break; #undef PRINT_CONTROLLERDEV_EVENT #define PRINT_CTOUCHPAD_EVENT(event) \ @@ -451,8 +447,8 @@ static void SDL_LogEvent(const SDL_Event *event) #define PRINT_FINGER_EVENT(event) \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " fingerid=%" SDL_PRIs64 " x=%f y=%f dx=%f dy=%f pressure=%f)", \ - (uint)event->tfinger.timestamp, (long long)event->tfinger.touchId, \ - (long long)event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ + (uint)event->tfinger.timestamp, event->tfinger.touchId, \ + event->tfinger.fingerId, event->tfinger.x, event->tfinger.y, \ event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure) SDL_EVENT_CASE(SDL_FINGERDOWN) PRINT_FINGER_EVENT(event); @@ -467,8 +463,8 @@ static void SDL_LogEvent(const SDL_Event *event) #define PRINT_DOLLAR_EVENT(event) \ (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " gestureid=%" SDL_PRIs64 " numfingers=%u error=%f x=%f y=%f)", \ - (uint)event->dgesture.timestamp, (long long)event->dgesture.touchId, \ - (long long)event->dgesture.gestureId, (uint)event->dgesture.numFingers, \ + (uint)event->dgesture.timestamp, event->dgesture.touchId, \ + event->dgesture.gestureId, (uint)event->dgesture.numFingers, \ event->dgesture.error, event->dgesture.x, event->dgesture.y) SDL_EVENT_CASE(SDL_DOLLARGESTURE) PRINT_DOLLAR_EVENT(event); @@ -480,7 +476,7 @@ static void SDL_LogEvent(const SDL_Event *event) SDL_EVENT_CASE(SDL_MULTIGESTURE) (void)SDL_snprintf(details, sizeof(details), " (timestamp=%u touchid=%" SDL_PRIs64 " dtheta=%f ddist=%f x=%f y=%f numfingers=%u)", - (uint)event->mgesture.timestamp, (long long)event->mgesture.touchId, + (uint)event->mgesture.timestamp, event->mgesture.touchId, event->mgesture.dTheta, event->mgesture.dDist, event->mgesture.x, event->mgesture.y, (uint)event->mgesture.numFingers); break; @@ -621,7 +617,7 @@ int SDL_StartEventLoop(void) */ /* Create the lock and set ourselves active */ -#if !SDL_THREADS_DISABLED +#ifndef SDL_THREADS_DISABLED if (!SDL_EventQ.lock) { SDL_EventQ.lock = SDL_CreateMutex(); if (SDL_EventQ.lock == NULL) { @@ -737,7 +733,7 @@ static void SDL_CutEvent(SDL_EventEntry *entry) SDL_AtomicAdd(&SDL_EventQ.count, -1); } -static int SDL_SendWakeupEvent() +static int SDL_SendWakeupEvent(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); if (_this == NULL || !_this->SendWakeupEvent) { @@ -922,14 +918,14 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) _this->PumpEvents(_this); } -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED /* Check for joystick state change */ if (SDL_update_joysticks) { SDL_JoystickUpdate(); } #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED /* Check for sensor state change */ if (SDL_update_sensors) { SDL_SensorUpdate(); @@ -952,7 +948,7 @@ static void SDL_PumpEventsInternal(SDL_bool push_sentinel) } } -void SDL_PumpEvents() +void SDL_PumpEvents(void) { SDL_PumpEventsInternal(SDL_FALSE); } @@ -964,16 +960,16 @@ int SDL_PollEvent(SDL_Event *event) return SDL_WaitEventTimeout(event, 0); } -static SDL_bool SDL_events_need_periodic_poll() +static SDL_bool SDL_events_need_periodic_poll(void) { SDL_bool need_periodic_poll = SDL_FALSE; -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED need_periodic_poll = SDL_WasInit(SDL_INIT_JOYSTICK) && SDL_update_joysticks; #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED need_periodic_poll = need_periodic_poll || (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors); #endif @@ -1049,18 +1045,18 @@ static int SDL_WaitEventTimeout_Device(_THIS, SDL_Window *wakeup_window, SDL_Eve return 0; } -static SDL_bool SDL_events_need_polling() +static SDL_bool SDL_events_need_polling(void) { SDL_bool need_polling = SDL_FALSE; -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED need_polling = SDL_WasInit(SDL_INIT_JOYSTICK) && SDL_update_joysticks && (SDL_NumJoysticks() > 0); #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED need_polling = need_polling || (SDL_WasInit(SDL_INIT_SENSOR) && SDL_update_sensors && (SDL_NumSensors() > 0)); #endif @@ -1342,10 +1338,10 @@ Uint8 SDL_EventState(Uint32 type, int state) SDL_disabled_events[hi]->bits[lo / 32] &= ~(1 << (lo & 31)); } -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED SDL_CalculateShouldUpdateJoysticks(SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_TRUE)); #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED SDL_CalculateShouldUpdateSensors(SDL_GetHintBoolean(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_TRUE)); #endif } @@ -1413,10 +1409,10 @@ int SDL_SendLocaleChangedEvent(void) int SDL_EventsInit(void) { -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL); #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED SDL_AddHintCallback(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_AutoUpdateSensorsChanged, NULL); #endif SDL_AddHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL); @@ -1437,10 +1433,10 @@ void SDL_EventsQuit(void) SDL_StopEventLoop(); SDL_DelHintCallback(SDL_HINT_POLL_SENTINEL, SDL_PollSentinelChanged, NULL); SDL_DelHintCallback(SDL_HINT_EVENT_LOGGING, SDL_EventLoggingChanged, NULL); -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED SDL_DelHintCallback(SDL_HINT_AUTO_UPDATE_JOYSTICKS, SDL_AutoUpdateJoysticksChanged, NULL); #endif -#if !SDL_SENSOR_DISABLED +#ifndef SDL_SENSOR_DISABLED SDL_DelHintCallback(SDL_HINT_AUTO_UPDATE_SENSORS, SDL_AutoUpdateSensorsChanged, NULL); #endif } diff --git a/vs/sdl2/src/events/SDL_events_c.h b/vs/sdl2/src/events/SDL_events_c.h index 7f27b1a2fd..6a9cf4ce63 100644 --- a/vs/sdl2/src/events/SDL_events_c.h +++ b/vs/sdl2/src/events/SDL_events_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_gesture.c b/vs/sdl2/src/events/SDL_gesture.c index 1769457eb7..63362c0f6a 100644 --- a/vs/sdl2/src/events/SDL_gesture.c +++ b/vs/sdl2/src/events/SDL_gesture.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -61,7 +61,7 @@ typedef struct typedef struct { SDL_FloatPoint path[DOLLARNPOINTS]; - unsigned long hash; + Sint64 hash; } SDL_DollarTemplate; typedef struct @@ -110,7 +110,7 @@ int SDL_RecordGesture(SDL_TouchID touchId) return touchId < 0; } -void SDL_GestureQuit() +void SDL_GestureQuit(void) { SDL_free(SDL_gestureTouch); SDL_gestureTouch = NULL; @@ -129,7 +129,7 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint *points) static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) { - if (dst == NULL) { + if (!dst) { return 0; } @@ -200,7 +200,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *p (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, (index + 1) * sizeof(SDL_DollarTemplate)); - if (dollarTemplate == NULL) { + if (!dollarTemplate) { return SDL_OutOfMemory(); } inTouch->dollarTemplate = dollarTemplate; @@ -217,7 +217,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path) { int index = -1; int i = 0; - if (inTouch == NULL) { + if (!inTouch) { if (SDL_numGestureTouches == 0) { return SDL_SetError("no gesture touch devices registered"); } @@ -238,7 +238,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { int i, loaded = 0; SDL_GestureTouch *touch = NULL; - if (src == NULL) { + if (!src) { return 0; } if (touchId >= 0) { @@ -247,7 +247,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) touch = &SDL_gestureTouch[i]; } } - if (touch == NULL) { + if (!touch) { return SDL_SetError("given touch id not found"); } } @@ -475,7 +475,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId) (SDL_numGestureTouches + 1) * sizeof(SDL_GestureTouch)); - if (gestureTouch == NULL) { + if (!gestureTouch) { return SDL_OutOfMemory(); } @@ -589,7 +589,7 @@ void SDL_GestureProcessEvent(SDL_Event *event) SDL_GestureTouch *inTouch = SDL_GetGestureTouch(event->tfinger.touchId); /* Shouldn't be possible */ - if (inTouch == NULL) { + if (!inTouch) { return; } @@ -630,7 +630,7 @@ void SDL_GestureProcessEvent(SDL_Event *event) &bestTempl, inTouch); if (bestTempl >= 0) { /* Send Event */ - unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; + Sint64 gestureId = inTouch->dollarTemplate[bestTempl].hash; SDL_SendGestureDollar(inTouch, gestureId, error); /* printf ("%s\n",);("Dollar error: %f\n",error); */ } diff --git a/vs/sdl2/src/events/SDL_gesture_c.h b/vs/sdl2/src/events/SDL_gesture_c.h index d359290c73..04320d5255 100644 --- a/vs/sdl2/src/events/SDL_gesture_c.h +++ b/vs/sdl2/src/events/SDL_gesture_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_keyboard.c b/vs/sdl2/src/events/SDL_keyboard.c index 5a14f85bf8..58a95c907b 100644 --- a/vs/sdl2/src/events/SDL_keyboard.c +++ b/vs/sdl2/src/events/SDL_keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -768,7 +768,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window) { SDL_Keyboard *keyboard = &SDL_keyboard; - if (keyboard->focus && window == NULL) { + if (keyboard->focus && !window) { /* We won't get anymore keyboard messages, so reset keyboard state */ SDL_ResetKeyboard(); } @@ -1183,7 +1183,7 @@ const char *SDL_GetScancodeName(SDL_Scancode scancode) } name = SDL_scancode_names[scancode]; - if (name != NULL) { + if (name) { return name; } @@ -1194,7 +1194,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name) { int i; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } @@ -1254,7 +1254,7 @@ SDL_Keycode SDL_GetKeyFromName(const char *name) SDL_Keycode key; /* Check input */ - if (name == NULL) { + if (!name) { return SDLK_UNKNOWN; } diff --git a/vs/sdl2/src/events/SDL_keyboard_c.h b/vs/sdl2/src/events/SDL_keyboard_c.h index 16a5fad2e0..4c5cd2f8b2 100644 --- a/vs/sdl2/src/events/SDL_keyboard_c.h +++ b/vs/sdl2/src/events/SDL_keyboard_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_keysym_to_scancode.c b/vs/sdl2/src/events/SDL_keysym_to_scancode.c index df0b6b12f7..ddf4ae3fb2 100644 --- a/vs/sdl2/src/events/SDL_keysym_to_scancode.c +++ b/vs/sdl2/src/events/SDL_keysym_to_scancode.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11 +#if defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_X11) #include "SDL_keyboard_c.h" #include "SDL_scancode_tables_c.h" diff --git a/vs/sdl2/src/events/SDL_keysym_to_scancode_c.h b/vs/sdl2/src/events/SDL_keysym_to_scancode_c.h index e9f28d8c63..11e2d370ac 100644 --- a/vs/sdl2/src/events/SDL_keysym_to_scancode_c.h +++ b/vs/sdl2/src/events/SDL_keysym_to_scancode_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_mouse.c b/vs/sdl2/src/events/SDL_mouse.c index 000b22deb5..431354f88b 100644 --- a/vs/sdl2/src/events/SDL_mouse.c +++ b/vs/sdl2/src/events/SDL_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static void SDLCALL SDL_MouseRelativeWarpMotionChanged(void *userdata, const cha } /* Public functions */ -int SDL_MouseInit(void) +int SDL_MousePreInit(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -216,11 +216,62 @@ int SDL_MouseInit(void) return 0; } +void SDL_MousePostInit(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + /* Create a dummy mouse cursor for video backends that don't support true cursors, + * so that mouse grab and focus functionality will work. + */ + if (!mouse->def_cursor) { + SDL_Surface *surface = SDL_CreateRGBSurface(0, 1, 1, 32, 0xFF, 0xFF, 0xFF, 0xFF); + if (surface) { + SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch); + SDL_SetDefaultCursor(SDL_CreateColorCursor(surface, 0, 0)); + SDL_FreeSurface(surface); + } + } +} + void SDL_SetDefaultCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); + if (cursor == mouse->def_cursor) { + return; + } + + if (mouse->def_cursor) { + SDL_Cursor *default_cursor = mouse->def_cursor; + SDL_Cursor *prev, *curr; + + if (mouse->cur_cursor == mouse->def_cursor) { + mouse->cur_cursor = NULL; + } + mouse->def_cursor = NULL; + + for (prev = NULL, curr = mouse->cursors; curr; + prev = curr, curr = curr->next) { + if (curr == default_cursor) { + if (prev) { + prev->next = curr->next; + } else { + mouse->cursors = curr->next; + } + + break; + } + } + + if (mouse->FreeCursor && default_cursor->driverdata) { + mouse->FreeCursor(default_cursor); + } else { + SDL_free(default_cursor); + } + } + mouse->def_cursor = cursor; + if (!mouse->cur_cursor) { SDL_SetCursor(cursor); } @@ -440,7 +491,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values) } v = (float *)SDL_realloc(mouse->system_scale_values, num_values * sizeof(*values)); - if (v == NULL) { + if (!v) { return SDL_OutOfMemory(); } SDL_memcpy(v, values, num_values * sizeof(*values)); @@ -661,7 +712,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button) if (button >= mouse->num_clickstates) { int i, count = button + 1; SDL_MouseClickState *clickstate = (SDL_MouseClickState *)SDL_realloc(mouse->clickstate, count * sizeof(*mouse->clickstate)); - if (clickstate == NULL) { + if (!clickstate) { return NULL; } mouse->clickstate = clickstate; @@ -683,7 +734,7 @@ static int SDL_PrivateSendMouseButton(SDL_Window *window, SDL_MouseID mouseID, U SDL_MouseInputSource *source; source = GetMouseInputSource(mouse, mouseID); - if (source == NULL) { + if (!source) { return 0; } buttonstate = source->buttonstate; @@ -979,10 +1030,10 @@ Uint32 SDL_GetGlobalMouseState(int *x, int *y) int tmpx, tmpy; /* make sure these are never NULL for the backend implementations... */ - if (x == NULL) { + if (!x) { x = &tmpx; } - if (y == NULL) { + if (!y) { y = &tmpy; } @@ -998,11 +1049,11 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ign { SDL_Mouse *mouse = SDL_GetMouse(); - if (window == NULL) { + if (!window) { window = mouse->focus; } - if (window == NULL) { + if (!window) { return; } @@ -1127,7 +1178,7 @@ int SDL_SetRelativeMouseMode(SDL_bool enabled) return 0; } -SDL_bool SDL_GetRelativeMouseMode() +SDL_bool SDL_GetRelativeMouseMode(void) { SDL_Mouse *mouse = SDL_GetMouse(); @@ -1233,7 +1284,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, 0x0000FF00, 0x000000FF, 0xFF000000); - if (surface == NULL) { + if (!surface) { return NULL; } for (y = 0; y < h; ++y) { @@ -1266,16 +1317,11 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_Surface *temp = NULL; SDL_Cursor *cursor; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } - if (!mouse->CreateCursor) { - SDL_SetError("Cursors are not currently supported"); - return NULL; - } - /* Sanity check the hot spot */ if ((hot_x < 0) || (hot_y < 0) || (hot_x >= surface->w) || (hot_y >= surface->h)) { @@ -1285,13 +1331,21 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (temp == NULL) { + if (!temp) { return NULL; } surface = temp; } - cursor = mouse->CreateCursor(surface, hot_x, hot_y); + if (mouse->CreateCursor) { + cursor = mouse->CreateCursor(surface, hot_x, hot_y); + } else { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + SDL_OutOfMemory(); + } + } + if (cursor) { cursor->next = mouse->cursors; mouse->cursors = cursor; @@ -1344,7 +1398,7 @@ void SDL_SetCursor(SDL_Cursor *cursor) break; } } - if (found == NULL) { + if (!found) { SDL_SetError("Cursor not associated with the current mouse"); return; } @@ -1373,7 +1427,7 @@ SDL_Cursor *SDL_GetCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->cur_cursor; @@ -1383,7 +1437,7 @@ SDL_Cursor *SDL_GetDefaultCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->def_cursor; @@ -1394,7 +1448,7 @@ void SDL_FreeCursor(SDL_Cursor *cursor) SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; - if (cursor == NULL) { + if (!cursor) { return; } @@ -1416,6 +1470,8 @@ void SDL_FreeCursor(SDL_Cursor *cursor) if (mouse->FreeCursor) { mouse->FreeCursor(curr); + } else { + SDL_free(curr); } return; } @@ -1427,7 +1483,7 @@ int SDL_ShowCursor(int toggle) SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; - if (mouse == NULL) { + if (!mouse) { return 0; } diff --git a/vs/sdl2/src/events/SDL_mouse_c.h b/vs/sdl2/src/events/SDL_mouse_c.h index 64e82ab8ed..4204f6201f 100644 --- a/vs/sdl2/src/events/SDL_mouse_c.h +++ b/vs/sdl2/src/events/SDL_mouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +131,8 @@ typedef struct } SDL_Mouse; /* Initialize the mouse subsystem */ -extern int SDL_MouseInit(void); +extern int SDL_MousePreInit(void); +extern void SDL_MousePostInit(void); /* Get the mouse state structure */ SDL_Mouse *SDL_GetMouse(void); diff --git a/vs/sdl2/src/events/SDL_quit.c b/vs/sdl2/src/events/SDL_quit.c index dba801a68c..cd629a927f 100644 --- a/vs/sdl2/src/events/SDL_quit.c +++ b/vs/sdl2/src/events/SDL_quit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +85,7 @@ static void SDL_EventSignal_Init(const int sig) action.sa_handler = SDL_HandleSIG; sigaction(sig, &action, NULL); } -#elif HAVE_SIGNAL_H +#elif defined(HAVE_SIGNAL_H) void (*ohandler)(int) = signal(sig, SDL_HandleSIG); if (ohandler != SIG_DFL) { signal(sig, ohandler); @@ -102,7 +102,7 @@ static void SDL_EventSignal_Quit(const int sig) action.sa_handler = SIG_DFL; sigaction(sig, &action, NULL); } -#elif HAVE_SIGNAL_H +#elif defined(HAVE_SIGNAL_H) void (*ohandler)(int) = signal(sig, SIG_DFL); if (ohandler != SDL_HandleSIG) { signal(sig, ohandler); diff --git a/vs/sdl2/src/events/SDL_scancode_tables.c b/vs/sdl2/src/events/SDL_scancode_tables.c index 359feb1e6d..db6d861966 100644 --- a/vs/sdl2/src/events/SDL_scancode_tables.c +++ b/vs/sdl2/src/events/SDL_scancode_tables.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../SDL_internal.h" -#if SDL_INPUT_LINUXEV || SDL_VIDEO_DRIVER_DIRECTFB || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11 +#if defined(SDL_INPUT_LINUXEV) || defined(SDL_VIDEO_DRIVER_DIRECTFB) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_X11) #include "SDL_scancode_tables_c.h" diff --git a/vs/sdl2/src/events/SDL_scancode_tables_c.h b/vs/sdl2/src/events/SDL_scancode_tables_c.h index b1181e243f..481e7a59ee 100644 --- a/vs/sdl2/src/events/SDL_scancode_tables_c.h +++ b/vs/sdl2/src/events/SDL_scancode_tables_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_touch.c b/vs/sdl2/src/events/SDL_touch.c index cff41b0560..b5ec77bd55 100644 --- a/vs/sdl2/src/events/SDL_touch.c +++ b/vs/sdl2/src/events/SDL_touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +138,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID) SDL_Finger *SDL_GetTouchFinger(SDL_TouchID touchID, int index) { SDL_Touch *touch = SDL_GetTouch(touchID); - if (touch == NULL) { + if (!touch) { return NULL; } if (index < 0 || index >= touch->num_fingers) { @@ -161,7 +161,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name /* Add the touch to the list of touch */ touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices, (SDL_num_touch + 1) * sizeof(*touchDevices)); - if (touchDevices == NULL) { + if (!touchDevices) { return SDL_OutOfMemory(); } @@ -198,7 +198,7 @@ static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float if (touch->num_fingers == touch->max_fingers) { SDL_Finger **new_fingers; new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers)); - if (new_fingers == NULL) { + if (!new_fingers) { return SDL_OutOfMemory(); } touch->fingers = new_fingers; @@ -241,7 +241,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_Mouse *mouse; SDL_Touch *touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -334,7 +334,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, posted = (SDL_PushEvent(&event) > 0); } } else { - if (finger == NULL) { + if (!finger) { /* This finger is already up */ return 0; } @@ -370,7 +370,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo float xrel, yrel, prel; touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -413,7 +413,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo } finger = SDL_GetFinger(touch, fingerid); - if (finger == NULL) { + if (!finger) { return SDL_SendTouch(id, fingerid, window, SDL_TRUE, x, y, pressure); } @@ -464,7 +464,7 @@ void SDL_DelTouch(SDL_TouchID id) index = SDL_GetTouchIndex(id); touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return; } diff --git a/vs/sdl2/src/events/SDL_touch_c.h b/vs/sdl2/src/events/SDL_touch_c.h index 1ece04cff3..85f1f90c8e 100644 --- a/vs/sdl2/src/events/SDL_touch_c.h +++ b/vs/sdl2/src/events/SDL_touch_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/SDL_windowevents.c b/vs/sdl2/src/events/SDL_windowevents.c index 800c8aae5f..2ef1e745e6 100644 --- a/vs/sdl2/src/events/SDL_windowevents.c +++ b/vs/sdl2/src/events/SDL_windowevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -84,7 +84,7 @@ int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, { int posted; - if (window == NULL) { + if (!window) { return 0; } switch (windowevent) { diff --git a/vs/sdl2/src/events/SDL_windowevents_c.h b/vs/sdl2/src/events/SDL_windowevents_c.h index fa2c353b66..cf7fc3a77e 100644 --- a/vs/sdl2/src/events/SDL_windowevents_c.h +++ b/vs/sdl2/src/events/SDL_windowevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/blank_cursor.h b/vs/sdl2/src/events/blank_cursor.h index 020474b2a9..1c317b712a 100644 --- a/vs/sdl2/src/events/blank_cursor.h +++ b/vs/sdl2/src/events/blank_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/default_cursor.h b/vs/sdl2/src/events/default_cursor.h index e8758f15a5..3eecf6c45f 100644 --- a/vs/sdl2/src/events/default_cursor.h +++ b/vs/sdl2/src/events/default_cursor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #define DEFAULT_CHOTX 0 #define DEFAULT_CHOTY 0 -/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */ +/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */ #define USE_MACOS_CURSOR #ifdef USE_MACOS_CURSOR diff --git a/vs/sdl2/src/events/imKStoUCS.c b/vs/sdl2/src/events/imKStoUCS.c index 4aa85d4239..d851dc1b6e 100644 --- a/vs/sdl2/src/events/imKStoUCS.c +++ b/vs/sdl2/src/events/imKStoUCS.c @@ -26,7 +26,7 @@ DEALINGS IN THE SOFTWARE. #include "../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 || SDL_VIDEO_DRIVER_WAYLAND +#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) #include "imKStoUCS.h" static unsigned short const keysym_to_unicode_1a1_1ff[] = { diff --git a/vs/sdl2/src/events/scancodes_ascii.h b/vs/sdl2/src/events/scancodes_ascii.h index 852370aeb8..a4a0ecca9f 100644 --- a/vs/sdl2/src/events/scancodes_ascii.h +++ b/vs/sdl2/src/events/scancodes_ascii.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/scancodes_darwin.h b/vs/sdl2/src/events/scancodes_darwin.h index ded67f656f..de23de4de0 100644 --- a/vs/sdl2/src/events/scancodes_darwin.h +++ b/vs/sdl2/src/events/scancodes_darwin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/scancodes_linux.h b/vs/sdl2/src/events/scancodes_linux.h index 67737ac2e6..03d84a9829 100644 --- a/vs/sdl2/src/events/scancodes_linux.h +++ b/vs/sdl2/src/events/scancodes_linux.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/scancodes_windows.h b/vs/sdl2/src/events/scancodes_windows.h index 614afba5a8..e902e76007 100644 --- a/vs/sdl2/src/events/scancodes_windows.h +++ b/vs/sdl2/src/events/scancodes_windows.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/events/scancodes_xfree86.h b/vs/sdl2/src/events/scancodes_xfree86.h index d01f3d9f72..20d02fe58f 100644 --- a/vs/sdl2/src/events/scancodes_xfree86.h +++ b/vs/sdl2/src/events/scancodes_xfree86.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/file/SDL_rwops.c b/vs/sdl2/src/file/SDL_rwops.c index 2f66dcf41a..bf47ba7110 100644 --- a/vs/sdl2/src/file/SDL_rwops.c +++ b/vs/sdl2/src/file/SDL_rwops.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +36,8 @@ #ifdef HAVE_STDIO_H #include +#include #endif - #ifdef HAVE_LIMITS_H #include #endif @@ -62,7 +62,7 @@ #include "SDL_system.h" #endif -#if __NACL__ +#ifdef __NACL__ #include "nacl_io/nacl_io.h" #endif @@ -86,7 +86,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c DWORD must_exist, truncate; int a_mode; - if (context == NULL) { + if (!context) { return -1; /* failed (invalid call) */ } @@ -154,7 +154,7 @@ static Sint64 SDLCALL windows_file_size(SDL_RWops *context) { LARGE_INTEGER size; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_size: invalid context/file not opened"); } @@ -170,7 +170,7 @@ static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int w DWORD windowswhence; LARGE_INTEGER windowsoffset; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_seek: invalid context/file not opened"); } @@ -211,7 +211,7 @@ windows_file_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) total_need = size * maxnum; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { return 0; } @@ -264,7 +264,7 @@ windows_file_write(SDL_RWops *context, const void *ptr, size_t size, total_bytes = size * num; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { return 0; } @@ -523,10 +523,29 @@ static int SDLCALL mem_close(SDL_RWops *context) /* Functions to create SDL_RWops structures from various data sources */ +#if defined(HAVE_STDIO_H) && !(defined(__WIN32__) || defined(__GDK__)) +static SDL_bool IsRegularFileOrPipe(FILE *f) +{ + #ifdef __WINRT__ + struct __stat64 st; + if (_fstat64(_fileno(f), &st) < 0 || + !((st.st_mode & _S_IFMT) == _S_IFREG || (st.st_mode & _S_IFMT) == _S_IFIFO)) { + return SDL_FALSE; + } + #else + struct stat st; + if (fstat(fileno(f), &st) < 0 || !(S_ISREG(st.st_mode) || S_ISFIFO(st.st_mode))) { + return SDL_FALSE; + } + #endif + return SDL_TRUE; +} +#endif + SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) { SDL_RWops *rwops = NULL; - if (file == NULL || !*file || mode == NULL || !*mode) { + if (!file || !*file || !mode || !*mode) { SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } @@ -536,6 +555,11 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) if (*file == '/') { FILE *fp = fopen(file, mode); if (fp) { + if (!IsRegularFileOrPipe(fp)) { + fclose(fp); + SDL_SetError("%s is not a regular file or pipe", file); + return NULL; + } return SDL_RWFromFP(fp, 1); } } else { @@ -551,6 +575,11 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) fp = fopen(path, mode); SDL_stack_free(path); if (fp) { + if (!IsRegularFileOrPipe(fp)) { + fclose(fp); + SDL_SetError("%s is not a regular file or pipe", path); + return NULL; + } return SDL_RWFromFP(fp, 1); } } @@ -559,7 +588,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) /* Try to open the file from the asset system */ rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -576,7 +605,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) #elif defined(__WIN32__) || defined(__GDK__) rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -590,20 +619,24 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) rwops->write = windows_file_write; rwops->close = windows_file_close; rwops->type = SDL_RWOPS_WINFILE; -#elif HAVE_STDIO_H +#elif defined(HAVE_STDIO_H) { -#if __APPLE__ && !SDL_FILE_DISABLED // TODO: add dummy? +#if defined(__APPLE__) && !defined(SDL_FILE_DISABLED) // TODO: add dummy? FILE *fp = SDL_OpenFPFromBundleOrFallback(file, mode); -#elif __WINRT__ +#elif defined(__WINRT__) FILE *fp = NULL; fopen_s(&fp, file, mode); -#elif __3DS__ +#elif defined(__3DS__) FILE *fp = N3DS_FileOpen(file, mode); #else FILE *fp = fopen(file, mode); #endif - if (fp == NULL) { + if (!fp) { SDL_SetError("Couldn't open %s", file); + } else if (!IsRegularFileOrPipe(fp)) { + fclose(fp); + fp = NULL; + SDL_SetError("%s is not a regular file or pipe", file); } else { rwops = SDL_RWFromFP(fp, SDL_TRUE); } @@ -621,7 +654,7 @@ SDL_RWops *SDL_RWFromFP(FILE * fp, SDL_bool autoclose) SDL_RWops *rwops = NULL; rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = stdio_size; rwops->seek = stdio_seek; rwops->read = stdio_read; @@ -644,7 +677,7 @@ SDL_RWops *SDL_RWFromFP(void * fp, SDL_bool autoclose) SDL_RWops *SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -654,7 +687,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -671,7 +704,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -681,7 +714,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -700,7 +733,7 @@ SDL_RWops *SDL_AllocRW(void) SDL_RWops *area; area = (SDL_RWops *)SDL_malloc(sizeof(*area)); - if (area == NULL) { + if (!area) { SDL_OutOfMemory(); } else { area->type = SDL_RWOPS_UNKNOWN; @@ -718,12 +751,12 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) { static const Sint64 FILE_CHUNK_SIZE = 1024; Sint64 size; - size_t size_read, size_total; + size_t size_read, size_total = 0; void *data = NULL, *newdata; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); - return NULL; + goto done; } size = SDL_RWsize(src); @@ -731,13 +764,16 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) size = FILE_CHUNK_SIZE; } data = SDL_malloc((size_t)(size + 1)); + if (!data) { + SDL_OutOfMemory(); + goto done; + } - size_total = 0; for (;;) { if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) { size = (size_total + FILE_CHUNK_SIZE); newdata = SDL_realloc(data, (size_t)(size + 1)); - if (newdata == NULL) { + if (!newdata) { SDL_free(data); data = NULL; SDL_OutOfMemory(); @@ -753,12 +789,12 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) size_total += size_read; } - if (datasize) { - *datasize = size_total; - } ((char *)data)[size_total] = '\0'; done: + if (datasize) { + *datasize = size_total; + } if (freesrc && src) { SDL_RWclose(src); } diff --git a/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.h b/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.h index 17bc86b4f2..c57ce45293 100644 --- a/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.h +++ b/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.m b/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.m index 8d6ec70470..1fdce06018 100644 --- a/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.m +++ b/vs/sdl2/src/file/cocoa/SDL_rwopsbundlesupport.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.c b/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.c index 467bae3c49..9ca81a1b84 100644 --- a/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.c +++ b/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -66,7 +66,7 @@ static FILE *TryOpenFile(const char *file, const char *mode) FILE *fp = NULL; fp = TryOpenInRomfs(file, mode); - if (fp == NULL) { + if (!fp) { fp = fopen(file, mode); } diff --git a/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.h b/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.h index b7a80a0097..1ec1567377 100644 --- a/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.h +++ b/vs/sdl2/src/file/n3ds/SDL_rwopsromfs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/filesystem/android/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/android/SDL_sysfilesystem.c index 9df679013f..5e372987b8 100644 --- a/vs/sdl2/src/filesystem/android/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/android/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +45,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) if (path) { size_t pathlen = SDL_strlen(path) + 2; char *fullpath = (char *)SDL_malloc(pathlen); - if (fullpath == NULL) { + if (!fullpath) { SDL_OutOfMemory(); return NULL; } diff --git a/vs/sdl2/src/filesystem/cocoa/SDL_sysfilesystem.m b/vs/sdl2/src/filesystem/cocoa/SDL_sysfilesystem.m index 94ee7830e5..3d48ef6aa3 100644 --- a/vs/sdl2/src/filesystem/cocoa/SDL_sysfilesystem.m +++ b/vs/sdl2/src/filesystem/cocoa/SDL_sysfilesystem.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/filesystem/dummy/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/dummy/SDL_sysfilesystem.c index 83819edeb8..0243cce6d6 100644 --- a/vs/sdl2/src/filesystem/dummy/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/dummy/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/filesystem/emscripten/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/emscripten/SDL_sysfilesystem.c index af39e3626f..3163972093 100644 --- a/vs/sdl2/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,17 +45,17 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/vs/sdl2/src/filesystem/gdk/SDL_sysfilesystem.cpp b/vs/sdl2/src/filesystem/gdk/SDL_sysfilesystem.cpp new file mode 100644 index 0000000000..22cc9c2881 --- /dev/null +++ b/vs/sdl2/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -0,0 +1,138 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2024 Sam Lantinga + + 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" + + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent filesystem routines */ + +#include "../../core/windows/SDL_windows.h" +#include "SDL_hints.h" +#include "SDL_system.h" +#include "SDL_filesystem.h" +#include + +char * +SDL_GetBasePath(void) +{ + /* NOTE: This function is a UTF8 version of the Win32 SDL_GetBasePath()! + * The GDK actually _recommends_ the 'A' functions over the 'W' functions :o + */ + DWORD buflen = 128; + CHAR *path = NULL; + DWORD len = 0; + int i; + + while (SDL_TRUE) { + void *ptr = SDL_realloc(path, buflen * sizeof(CHAR)); + if (!ptr) { + SDL_free(path); + SDL_OutOfMemory(); + return NULL; + } + + path = (CHAR *)ptr; + + len = GetModuleFileNameA(NULL, path, buflen); + /* if it truncated, then len >= buflen - 1 */ + /* if there was enough room (or failure), len < buflen - 1 */ + if (len < buflen - 1) { + break; + } + + /* buffer too small? Try again. */ + buflen *= 2; + } + + if (len == 0) { + SDL_free(path); + WIN_SetError("Couldn't locate our .exe"); + return NULL; + } + + for (i = len - 1; i > 0; i--) { + if (path[i] == '\\') { + break; + } + } + + SDL_assert(i > 0); /* Should have been an absolute path. */ + path[i + 1] = '\0'; /* chop off filename. */ + + return path; +} + +char * +SDL_GetPrefPath(const char *org, const char *app) +{ + XUserHandle user = NULL; + XAsyncBlock block = { 0 }; + char *folderPath; + HRESULT result; + const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID"); + + if (!app) { + SDL_InvalidParamError("app"); + return NULL; + } + + /* This should be set before calling SDL_GetPrefPath! */ + if (!csid) { + SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!"); + return SDL_strdup("T:\\"); + } + + if (SDL_GDKGetDefaultUser(&user) < 0) { + /* Error already set, just return */ + return NULL; + } + + if (FAILED(result = XGameSaveFilesGetFolderWithUiAsync(user, csid, &block))) { + WIN_SetErrorFromHRESULT("XGameSaveFilesGetFolderWithUiAsync", result); + return NULL; + } + + folderPath = (char*) SDL_malloc(MAX_PATH); + do { + result = XGameSaveFilesGetFolderWithUiResult(&block, MAX_PATH, folderPath); + } while (result == E_PENDING); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT("XGameSaveFilesGetFolderWithUiResult", result); + SDL_free(folderPath); + return NULL; + } + + /* We aren't using 'app' here because the container rules are a lot more + * strict than the NTFS rules, so it will most likely be invalid :( + */ + SDL_strlcat(folderPath, "\\SDLPrefPath\\", MAX_PATH); + if (CreateDirectoryA(folderPath, NULL) == FALSE) { + if (GetLastError() != ERROR_ALREADY_EXISTS) { + WIN_SetError("CreateDirectoryA"); + SDL_free(folderPath); + return NULL; + } + } + return folderPath; +} + + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/filesystem/haiku/SDL_sysfilesystem.cc b/vs/sdl2/src/filesystem/haiku/SDL_sysfilesystem.cc index b6dc7d1366..5585c48c65 100644 --- a/vs/sdl2/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/vs/sdl2/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ char *SDL_GetBasePath(void) const size_t len = SDL_strlen(str); char *retval = (char *) SDL_malloc(len + 2); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -75,11 +75,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) const char *append = "/config/settings/"; size_t len = SDL_strlen(home); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -88,7 +88,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) } len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; char *retval = (char *) SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); } else { if (*org) { diff --git a/vs/sdl2/src/filesystem/n3ds/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/n3ds/SDL_sysfilesystem.c index fe2fd3ff81..fe46076216 100644 --- a/vs/sdl2/src/filesystem/n3ds/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/n3ds/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 @@ char *SDL_GetBasePath(void) char *SDL_GetPrefPath(const char *org, const char *app) { char *pref_path = NULL; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } pref_path = MakePrefPath(app); - if (pref_path == NULL) { + if (!pref_path) { return NULL; } diff --git a/vs/sdl2/src/filesystem/nacl/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/nacl/SDL_sysfilesystem.c index 91e7a98812..1ef34dd0c1 100644 --- a/vs/sdl2/src/filesystem/nacl/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/nacl/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/filesystem/os2/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/os2/SDL_sysfilesystem.c index fb7d52815a..4e9597f0ca 100644 --- a/vs/sdl2/src/filesystem/os2/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/os2/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/filesystem/ps2/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/ps2/SDL_sysfilesystem.c index 86dcb14b63..6b6446656c 100644 --- a/vs/sdl2/src/filesystem/ps2/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/ps2/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +82,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *retval = NULL; size_t len; char *base = SDL_GetBasePath(); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } diff --git a/vs/sdl2/src/filesystem/psp/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/psp/SDL_sysfilesystem.c index c163fa146b..7ed87e0eb6 100644 --- a/vs/sdl2/src/filesystem/psp/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/psp/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +50,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *retval = NULL; size_t len; char *base = SDL_GetBasePath(); - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } diff --git a/vs/sdl2/src/filesystem/riscos/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/riscos/SDL_sysfilesystem.c index 2537340656..4617895549 100644 --- a/vs/sdl2/src/filesystem/riscos/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/riscos/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,21 +38,21 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len, { const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */ - if (buffer == NULL) { + if (!buffer) { /* This matches the logic in __unixify, with an additional byte for the * extra path separator. */ buf_len = SDL_strlen(ro_path) + 14 + 1; buffer = SDL_malloc(buf_len); - if (buffer == NULL) { + if (!buffer) { SDL_OutOfMemory(); return NULL; } } if (!__unixify_std(ro_path, buffer, buf_len, filetype)) { - if (in_buf == NULL) { + if (!in_buf) { SDL_free(buffer); } @@ -92,7 +92,7 @@ static char *canonicalisePath(const char *path, const char *pathVar) regs.r[5] = 1 - regs.r[5]; buf = SDL_malloc(regs.r[5]); - if (buf == NULL) { + if (!buf) { SDL_OutOfMemory(); return NULL; } @@ -121,7 +121,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path) *ptr = '\0'; error = _kernel_swi(OS_File, ®s, ®s); *ptr = '.'; - if (error != NULL) { + if (error) { return error; } } @@ -141,13 +141,13 @@ char *SDL_GetBasePath(void) } canon = canonicalisePath((const char *)regs.r[0], "Run$Path"); - if (canon == NULL) { + if (!canon) { return NULL; } /* chop off filename. */ ptr = SDL_strrchr(canon, '.'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } @@ -162,22 +162,22 @@ char *SDL_GetPrefPath(const char *org, const char *app) size_t len; _kernel_oserror *error; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } canon = canonicalisePath("", "Run$Path"); - if (canon == NULL) { + if (!canon) { return NULL; } len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4; dir = (char *)SDL_malloc(len); - if (dir == NULL) { + if (!dir) { SDL_OutOfMemory(); SDL_free(canon); return NULL; @@ -192,7 +192,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) SDL_free(canon); error = createDirectoryRecursive(dir); - if (error != NULL) { + if (error) { SDL_SetError("Couldn't create directory: %s", error->errmess); SDL_free(dir); return NULL; diff --git a/vs/sdl2/src/filesystem/unix/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/unix/SDL_sysfilesystem.c index 42e6e48ae1..c69a99168c 100644 --- a/vs/sdl2/src/filesystem/unix/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/unix/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 char *readSymLink(const char *path) while (1) { char *ptr = (char *)SDL_realloc(retval, (size_t)len); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); break; } @@ -86,13 +86,13 @@ static char *search_path_for_binary(const char *bin) char *start = envr; char *ptr; - if (envr == NULL) { + if (!envr) { SDL_SetError("No $PATH set"); return NULL; } envr = SDL_strdup(envr); - if (envr == NULL) { + if (!envr) { SDL_OutOfMemory(); return NULL; } @@ -118,7 +118,7 @@ static char *search_path_for_binary(const char *bin) } } start = ptr + 1; /* start points to beginning of next element. */ - } while (ptr != NULL); + } while (ptr); SDL_free(envr); SDL_free(exe); @@ -138,7 +138,7 @@ char *SDL_GetBasePath(void) const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) { retval = SDL_strdup(fullpath); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -152,13 +152,13 @@ char *SDL_GetBasePath(void) if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) { char *exe, *pwddst; char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1); - if (realpathbuf == NULL) { + if (!realpathbuf) { SDL_OutOfMemory(); return NULL; } cmdline = SDL_malloc(len); - if (cmdline == NULL) { + if (!cmdline) { SDL_free(realpathbuf); SDL_OutOfMemory(); return NULL; @@ -180,7 +180,7 @@ char *SDL_GetBasePath(void) } if (exe) { - if (pwddst == NULL) { + if (!pwddst) { if (realpath(exe, realpathbuf) != NULL) { retval = realpathbuf; } @@ -196,7 +196,7 @@ char *SDL_GetBasePath(void) } } - if (retval == NULL) { + if (!retval) { SDL_free(realpathbuf); } @@ -205,7 +205,7 @@ char *SDL_GetBasePath(void) #endif /* is a Linux-style /proc filesystem available? */ - if (retval == NULL && (access("/proc", F_OK) == 0)) { + if (!retval && (access("/proc", F_OK) == 0)) { /* !!! FIXME: after 2.0.6 ships, let's delete this code and just use the /proc/%llu version. There's no reason to have two copies of this plus all the #ifdefs. --ryan. */ @@ -219,7 +219,7 @@ char *SDL_GetBasePath(void) retval = SDL_LoadFile("/proc/self/exefile", NULL); #else retval = readSymLink("/proc/self/exe"); /* linux. */ - if (retval == NULL) { + if (!retval) { /* older kernels don't have /proc/self ... try PID version... */ char path[64]; const int rc = SDL_snprintf(path, sizeof(path), @@ -248,9 +248,9 @@ char *SDL_GetBasePath(void) /* If we had access to argv[0] here, we could check it for a path, or troll through $PATH looking for it, too. */ - if (retval != NULL) { /* chop off filename. */ + if (retval) { /* chop off filename. */ char *ptr = SDL_strrchr(retval, '/'); - if (ptr != NULL) { + if (ptr) { *(ptr + 1) = '\0'; } else { /* shouldn't happen, but just in case... */ SDL_free(retval); @@ -258,10 +258,10 @@ char *SDL_GetBasePath(void) } } - if (retval != NULL) { + if (retval) { /* try to shrink buffer... */ char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1); - if (ptr != NULL) { + if (ptr) { retval = ptr; /* oh well if it failed. */ } } @@ -284,18 +284,18 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } - if (envr == NULL) { + if (!envr) { /* You end up with "$HOME/.local/share/Game Name 2" */ envr = SDL_getenv("HOME"); - if (envr == NULL) { + if (!envr) { /* we could take heroic measures with /etc/passwd, but oh well. */ SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set"); return NULL; @@ -312,7 +312,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/vs/sdl2/src/filesystem/vita/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/vita/SDL_sysfilesystem.c index bb572708a6..eb7e159efb 100644 --- a/vs/sdl2/src/filesystem/vita/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/vita/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +53,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) char *ptr = NULL; size_t len = 0; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -65,7 +65,7 @@ char *SDL_GetPrefPath(const char *org, const char *app) len += SDL_strlen(org) + SDL_strlen(app) + 3; retval = (char *)SDL_malloc(len); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } diff --git a/vs/sdl2/src/filesystem/windows/SDL_sysfilesystem.c b/vs/sdl2/src/filesystem/windows/SDL_sysfilesystem.c index 06842706f1..a653291175 100644 --- a/vs/sdl2/src/filesystem/windows/SDL_sysfilesystem.c +++ b/vs/sdl2/src/filesystem/windows/SDL_sysfilesystem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,7 @@ char *SDL_GetBasePath(void) while (SDL_TRUE) { void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR)); - if (ptr == NULL) { + if (!ptr) { SDL_free(path); SDL_OutOfMemory(); return NULL; @@ -99,11 +99,11 @@ char *SDL_GetPrefPath(const char *org, const char *app) size_t new_wpath_len = 0; BOOL api_result = FALSE; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } @@ -113,13 +113,13 @@ char *SDL_GetPrefPath(const char *org, const char *app) } worg = WIN_UTF8ToStringW(org); - if (worg == NULL) { + if (!worg) { SDL_OutOfMemory(); return NULL; } wapp = WIN_UTF8ToStringW(app); - if (wapp == NULL) { + if (!wapp) { SDL_free(worg); SDL_OutOfMemory(); return NULL; @@ -170,20 +170,4 @@ char *SDL_GetPrefPath(const char *org, const char *app) #endif /* SDL_FILESYSTEM_WINDOWS */ -#ifdef SDL_FILESYSTEM_XBOX -#include "SDL_filesystem.h" -#include "SDL_error.h" -char *SDL_GetBasePath(void) -{ - SDL_Unsupported(); - return NULL; -} - -char *SDL_GetPrefPath(const char *org, const char *app) -{ - SDL_Unsupported(); - return NULL; -} -#endif /* SDL_FILESYSTEM_XBOX */ - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/filesystem/winrt/SDL_sysfilesystem.cpp b/vs/sdl2/src/filesystem/winrt/SDL_sysfilesystem.cpp index b8ba6fdeca..85cfd190ef 100644 --- a/vs/sdl2/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/vs/sdl2/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,7 +71,7 @@ SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType) return path.c_str(); } -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8) +#if !SDL_WINAPI_FAMILY_PHONE || (NTDDI_VERSION > NTDDI_WIN8) case SDL_WINRT_PATH_ROAMING_FOLDER: { static wstring path; @@ -111,7 +111,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) } const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); - if (ucs2Path == NULL) { + if (!ucs2Path) { return NULL; } @@ -128,14 +128,14 @@ SDL_GetBasePath(void) size_t destPathLen; char *destPath = NULL; - if (srcPath == NULL) { + if (!srcPath) { SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError()); return NULL; } destPathLen = SDL_strlen(srcPath) + 2; destPath = (char *)SDL_malloc(destPathLen); - if (destPath == NULL) { + if (!destPath) { SDL_OutOfMemory(); return NULL; } @@ -161,16 +161,16 @@ SDL_GetPrefPath(const char *org, const char *app) size_t new_wpath_len = 0; BOOL api_result = FALSE; - if (app == NULL) { + if (!app) { SDL_InvalidParamError("app"); return NULL; } - if (org == NULL) { + if (!org) { org = ""; } srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER); - if (srcPath == NULL) { + if (!srcPath) { SDL_SetError("Unable to find a source path"); return NULL; } @@ -182,13 +182,13 @@ SDL_GetPrefPath(const char *org, const char *app) SDL_wcslcpy(path, srcPath, SDL_arraysize(path)); worg = WIN_UTF8ToString(org); - if (worg == NULL) { + if (!worg) { SDL_OutOfMemory(); return NULL; } wapp = WIN_UTF8ToString(app); - if (wapp == NULL) { + if (!wapp) { SDL_free(worg); SDL_OutOfMemory(); return NULL; diff --git a/vs/sdl2/src/haptic/SDL_haptic.c b/vs/sdl2/src/haptic/SDL_haptic.c index ee64bcbd2b..256d6677a4 100644 --- a/vs/sdl2/src/haptic/SDL_haptic.c +++ b/vs/sdl2/src/haptic/SDL_haptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "../joystick/SDL_joystick_c.h" /* For SDL_PrivateJoystickValid */ /* Global for SDL_windowshaptic.c */ -#if (defined(SDL_HAPTIC_DINPUT) && SDL_HAPTIC_DINPUT) || (defined(SDL_HAPTIC_XINPUT) && SDL_HAPTIC_XINPUT) +#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT) SDL_Haptic *SDL_haptics = NULL; #else static SDL_Haptic *SDL_haptics = NULL; @@ -55,7 +55,7 @@ static int ValidHaptic(SDL_Haptic *haptic) SDL_Haptic *hapticlist; valid = 0; - if (haptic != NULL) { + if (haptic) { hapticlist = SDL_haptics; while (hapticlist) { if (hapticlist == haptic) { @@ -124,7 +124,7 @@ SDL_Haptic *SDL_HapticOpen(int device_index) /* Create the haptic device */ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic)); - if (haptic == NULL) { + if (!haptic) { SDL_OutOfMemory(); return NULL; } @@ -296,7 +296,7 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick) /* Create the haptic device */ haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic)); - if (haptic == NULL) { + if (!haptic) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -609,7 +609,7 @@ int SDL_HapticSetGain(SDL_Haptic *haptic, int gain) /* We use the envvar to get the maximum gain. */ env = SDL_getenv("SDL_HAPTIC_GAIN_MAX"); - if (env != NULL) { + if (env) { max_gain = SDL_atoi(env); /* Check for sanity. */ diff --git a/vs/sdl2/src/haptic/SDL_haptic_c.h b/vs/sdl2/src/haptic/SDL_haptic_c.h index 55e791f607..a1b1ed7131 100644 --- a/vs/sdl2/src/haptic/SDL_haptic_c.h +++ b/vs/sdl2/src/haptic/SDL_haptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/haptic/SDL_syshaptic.h b/vs/sdl2/src/haptic/SDL_syshaptic.h index f81295120b..31f37dde1a 100644 --- a/vs/sdl2/src/haptic/SDL_syshaptic.h +++ b/vs/sdl2/src/haptic/SDL_syshaptic.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/haptic/android/SDL_syshaptic.c b/vs/sdl2/src/haptic/android/SDL_syshaptic.c index 111c43c0bf..15fbdd2805 100644 --- a/vs/sdl2/src/haptic/android/SDL_syshaptic.c +++ b/vs/sdl2/src/haptic/android/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -80,7 +80,7 @@ static SDL_hapticlist_item *HapticByOrder(int index) static SDL_hapticlist_item *HapticByDevId(int device_id) { SDL_hapticlist_item *item; - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (device_id == item->device_id) { /*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/ return item; @@ -92,7 +92,7 @@ static SDL_hapticlist_item *HapticByDevId(int device_id) const char *SDL_SYS_HapticName(int index) { SDL_hapticlist_item *item = HapticByOrder(index); - if (item == NULL) { + if (!item) { SDL_SetError("No such device"); return NULL; } @@ -101,11 +101,11 @@ const char *SDL_SYS_HapticName(int index) static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item) { - if (item == NULL) { + if (!item) { SDL_SetError("No such device"); return NULL; } - if (item->haptic != NULL) { + if (item->haptic) { SDL_SetError("Haptic already opened"); return NULL; } @@ -117,7 +117,7 @@ static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item * haptic->neffects = 1; haptic->nplaying = haptic->neffects; haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); return NULL; } @@ -149,7 +149,7 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) { SDL_hapticlist_item *item; item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id); - return (item != NULL) ? 1 : 0; + return (item) ? 1 : 0; } int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick) @@ -257,18 +257,18 @@ int Android_AddHaptic(int device_id, const char *name) { SDL_hapticlist_item *item; item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return -1; } item->device_id = device_id; item->name = SDL_strdup(name); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); return -1; } - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -284,12 +284,12 @@ int Android_RemoveHaptic(int device_id) SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (device_id == item->device_id) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); diff --git a/vs/sdl2/src/haptic/darwin/SDL_syshaptic.c b/vs/sdl2/src/haptic/darwin/SDL_syshaptic.c index dea1ee7c2e..d33e4d6aa3 100644 --- a/vs/sdl2/src/haptic/darwin/SDL_syshaptic.c +++ b/vs/sdl2/src/haptic/darwin/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +157,7 @@ int SDL_SYS_HapticInit(void) /* Get HID devices. */ match = IOServiceMatching(kIOHIDDeviceKey); - if (match == NULL) { + if (!match) { return SDL_SetError("Haptic: Failed to get IOServiceMatching."); } @@ -229,7 +229,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_SetError("Could not allocate haptic storage"); } @@ -265,7 +265,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device) CFRelease(hidProperties); } - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -287,12 +287,12 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device) return -1; /* not initialized. ignore this. */ } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (IOObjectIsEqualTo((io_object_t)item->dev, device)) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -478,7 +478,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_OutOfMemory(); goto creat_err; } @@ -516,7 +516,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic /* Allocate effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto open_err; } @@ -530,7 +530,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic open_err: FFReleaseDevice(haptic->hwdata->device); creat_err: - if (haptic->hwdata != NULL) { + if (haptic->hwdata) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -703,7 +703,7 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); - if (rglDir == NULL) { + if (!rglDir) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); @@ -776,7 +776,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe /* Envelope. */ envelope = SDL_malloc(sizeof(FFENVELOPE)); - if (envelope == NULL) { + if (!envelope) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(FFENVELOPE)); @@ -791,7 +791,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); - if (axes == NULL) { + if (!axes) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ @@ -809,7 +809,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(FFCONSTANTFORCE)); - if (constant == NULL) { + if (!constant) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE)); @@ -851,7 +851,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(FFPERIODIC)); - if (periodic == NULL) { + if (!periodic) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(FFPERIODIC)); @@ -896,7 +896,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe hap_condition = &src->condition; if (dest->cAxes > 0) { condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes); - if (condition == NULL) { + if (!condition) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(FFCONDITION)); @@ -939,7 +939,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(FFRAMPFORCE)); - if (ramp == NULL) { + if (!ramp) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(FFRAMPFORCE)); @@ -977,7 +977,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(FFCUSTOMFORCE)); - if (custom == NULL) { + if (!custom) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE)); @@ -1037,7 +1037,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type) effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; - if (effect->lpvTypeSpecificParams != NULL) { + if (effect->lpvTypeSpecificParams) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); @@ -1112,14 +1112,14 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { SDL_OutOfMemory(); goto err_hweffect; } /* Get the type. */ type = SDL_SYS_HapticEffectType(base->type); - if (type == NULL) { + if (!type) { goto err_hweffect; } diff --git a/vs/sdl2/src/haptic/darwin/SDL_syshaptic_c.h b/vs/sdl2/src/haptic/darwin/SDL_syshaptic_c.h index 8247fe8847..49b54bb2cc 100644 --- a/vs/sdl2/src/haptic/darwin/SDL_syshaptic_c.h +++ b/vs/sdl2/src/haptic/darwin/SDL_syshaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/haptic/dummy/SDL_syshaptic.c b/vs/sdl2/src/haptic/dummy/SDL_syshaptic.c index 433093ccbb..861aa6ed14 100644 --- a/vs/sdl2/src/haptic/dummy/SDL_syshaptic.c +++ b/vs/sdl2/src/haptic/dummy/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/haptic/linux/SDL_syshaptic.c b/vs/sdl2/src/haptic/linux/SDL_syshaptic.c index 55a8ca1a16..a21c118612 100644 --- a/vs/sdl2/src/haptic/linux/SDL_syshaptic.c +++ b/vs/sdl2/src/haptic/linux/SDL_syshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +46,7 @@ #define MAX_HAPTICS 32 /* It's doubtful someone has more then 32 evdev */ static int MaybeAddDevice(const char *path); -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char *path); static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath); #endif /* SDL_USE_LIBUDEV */ @@ -164,7 +164,7 @@ int SDL_SYS_HapticInit(void) MaybeAddDevice(path); } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV if (SDL_UDEV_Init() < 0) { return SDL_SetError("Could not initialize UDEV"); } @@ -203,10 +203,10 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) return item; } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { + if (!devpath || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) { return; } @@ -232,7 +232,7 @@ static int MaybeAddDevice(const char *path) int success; SDL_hapticlist_item *item; - if (path == NULL) { + if (!path) { return -1; } @@ -242,7 +242,7 @@ static int MaybeAddDevice(const char *path) } /* check for duplicates */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->dev_num == sb.st_rdev) { return -1; /* duplicate. */ } @@ -266,12 +266,12 @@ static int MaybeAddDevice(const char *path) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return -1; } item->fname = SDL_strdup(path); - if (item->fname == NULL) { + if (!item->fname) { SDL_free(item); return -1; } @@ -279,7 +279,7 @@ static int MaybeAddDevice(const char *path) item->dev_num = sb.st_rdev; /* TODO: should we add instance IDs? */ - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -293,22 +293,22 @@ static int MaybeAddDevice(const char *path) return numhaptics; } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static int MaybeRemoveDevice(const char *path) { SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - if (path == NULL) { + if (!path) { return -1; } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->fname) == 0) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -365,7 +365,7 @@ const char *SDL_SYS_HapticName(int index) if (fd >= 0) { name = SDL_SYS_HapticNameFromFD(fd); - if (name == NULL) { + if (!name) { /* No name found, return device character device */ name = item->fname; } @@ -383,7 +383,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_OutOfMemory(); goto open_err; } @@ -403,7 +403,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto open_err; } @@ -416,7 +416,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd) /* Error handling */ open_err: close(fd); - if (haptic->hwdata != NULL) { + if (haptic->hwdata) { SDL_free(haptic->hwdata); haptic->hwdata = NULL; } @@ -608,7 +608,7 @@ void SDL_SYS_HapticQuit(void) SDL_free(item); } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV SDL_UDEV_DelCallback(haptic_udev_callback); SDL_UDEV_Quit(); #endif /* SDL_USE_LIBUDEV */ @@ -647,17 +647,6 @@ static int SDL_SYS_ToDirection(Uint16 *dest, SDL_HapticDirection *src) switch (src->type) { case SDL_HAPTIC_POLAR: - /* Linux directions start from south. - (and range from 0 to 0xFFFF) - Quoting include/linux/input.h, line 926: - Direction of the effect is encoded as follows: - 0 deg -> 0x0000 (down) - 90 deg -> 0x4000 (left) - 180 deg -> 0x8000 (up) - 270 deg -> 0xC000 (right) - The force pulls into the direction specified by Linux directions, - i.e. the opposite convention of SDL directions. - */ tmp = ((src->dir[0] % 36000) * 0x8000) / 18000; /* convert to range [0,0xFFFF] */ *dest = (Uint16)tmp; break; @@ -922,7 +911,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Allocate the hardware effect */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/haptic/windows/SDL_dinputhaptic.c b/vs/sdl2/src/haptic/windows/SDL_dinputhaptic.c index 5a096be9db..22149151f9 100644 --- a/vs/sdl2/src/haptic/windows/SDL_dinputhaptic.c +++ b/vs/sdl2/src/haptic/windows/SDL_dinputhaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "SDL_haptic.h" #include "../SDL_syshaptic.h" -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT #include "SDL_hints.h" #include "SDL_stdinc.h" @@ -98,7 +98,7 @@ int SDL_DINPUT_HapticInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); - if (instance == NULL) { + if (!instance) { SDL_SYS_HapticQuit(); return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); @@ -139,7 +139,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) DIDEVCAPS capabilities; SDL_hapticlist_item *item = NULL; - if (dinput == NULL) { + if (!dinput) { return -1; /* not initialized. We'll pick these up on enumeration if we init later. */ } @@ -172,7 +172,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance) } item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -194,11 +194,11 @@ int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance) SDL_hapticlist_item *item; SDL_hapticlist_item *prev = NULL; - if (dinput == NULL) { + if (!dinput) { return -1; /* not initialized, ignore this. */ } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (!item->bXInputHaptic && SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); @@ -293,7 +293,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { return SDL_OutOfMemory(); } SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata)); @@ -407,7 +407,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { SDL_OutOfMemory(); goto acquire_err; } @@ -480,7 +480,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick } /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) { haptic->index = index; return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE); @@ -546,7 +546,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int /* Has axes. */ rglDir = SDL_malloc(sizeof(LONG) * naxes); - if (rglDir == NULL) { + if (!rglDir) { return SDL_OutOfMemory(); } SDL_memset(rglDir, 0, sizeof(LONG) * naxes); @@ -620,7 +620,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, /* Envelope. */ envelope = SDL_malloc(sizeof(DIENVELOPE)); - if (envelope == NULL) { + if (!envelope) { return SDL_OutOfMemory(); } SDL_memset(envelope, 0, sizeof(DIENVELOPE)); @@ -635,7 +635,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, } if (dest->cAxes > 0) { axes = SDL_malloc(sizeof(DWORD) * dest->cAxes); - if (axes == NULL) { + if (!axes) { return SDL_OutOfMemory(); } axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */ @@ -653,7 +653,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_CONSTANT: hap_constant = &src->constant; constant = SDL_malloc(sizeof(DICONSTANTFORCE)); - if (constant == NULL) { + if (!constant) { return SDL_OutOfMemory(); } SDL_memset(constant, 0, sizeof(DICONSTANTFORCE)); @@ -695,7 +695,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_SAWTOOTHDOWN: hap_periodic = &src->periodic; periodic = SDL_malloc(sizeof(DIPERIODIC)); - if (periodic == NULL) { + if (!periodic) { return SDL_OutOfMemory(); } SDL_memset(periodic, 0, sizeof(DIPERIODIC)); @@ -739,7 +739,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_FRICTION: hap_condition = &src->condition; condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes); - if (condition == NULL) { + if (!condition) { return SDL_OutOfMemory(); } SDL_memset(condition, 0, sizeof(DICONDITION)); @@ -780,7 +780,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_RAMP: hap_ramp = &src->ramp; ramp = SDL_malloc(sizeof(DIRAMPFORCE)); - if (ramp == NULL) { + if (!ramp) { return SDL_OutOfMemory(); } SDL_memset(ramp, 0, sizeof(DIRAMPFORCE)); @@ -818,7 +818,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest, case SDL_HAPTIC_CUSTOM: hap_custom = &src->custom; custom = SDL_malloc(sizeof(DICUSTOMFORCE)); - if (custom == NULL) { + if (!custom) { return SDL_OutOfMemory(); } SDL_memset(custom, 0, sizeof(DICUSTOMFORCE)); @@ -877,7 +877,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type) effect->lpEnvelope = NULL; SDL_free(effect->rgdwAxes); effect->rgdwAxes = NULL; - if (effect->lpvTypeSpecificParams != NULL) { + if (effect->lpvTypeSpecificParams) { if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */ custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams; SDL_free(custom->rglForceData); @@ -943,7 +943,7 @@ int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, HRESULT ret; REFGUID type = SDL_SYS_HapticEffectType(base); - if (type == NULL) { + if (!type) { return SDL_SetError("Haptic: Unknown effect type."); } diff --git a/vs/sdl2/src/haptic/windows/SDL_dinputhaptic_c.h b/vs/sdl2/src/haptic/windows/SDL_dinputhaptic_c.h index fa61a0d55a..b84fd71912 100644 --- a/vs/sdl2/src/haptic/windows/SDL_dinputhaptic_c.h +++ b/vs/sdl2/src/haptic/windows/SDL_dinputhaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/haptic/windows/SDL_windowshaptic.c b/vs/sdl2/src/haptic/windows/SDL_windowshaptic.c index 01a4a7ec9a..1992a0630b 100644 --- a/vs/sdl2/src/haptic/windows/SDL_windowshaptic.c +++ b/vs/sdl2/src/haptic/windows/SDL_windowshaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT +#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT) #include "SDL_thread.h" #include "SDL_mutex.h" @@ -81,7 +81,7 @@ int SDL_SYS_HapticInit(void) int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) { - if (SDL_hapticlist_tail == NULL) { + if (!SDL_hapticlist_tail) { SDL_hapticlist = SDL_hapticlist_tail = item; } else { SDL_hapticlist_tail->next = item; @@ -97,7 +97,7 @@ int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item) int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item) { const int retval = item->haptic ? item->haptic->index : -1; - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_hapticlist == item); @@ -160,12 +160,12 @@ int SDL_SYS_HapticOpen(SDL_Haptic *haptic) */ int SDL_SYS_HapticMouse(void) { -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT SDL_hapticlist_item *item; int index = 0; /* Grab the first mouse haptic device we find. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) { return index; } @@ -183,12 +183,12 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick) if (joystick->driver != &SDL_WINDOWS_JoystickDriver) { return 0; } -#if SDL_HAPTIC_XINPUT +#ifdef SDL_HAPTIC_XINPUT if (joystick->hwdata->bXInputHaptic) { return 1; } #endif -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT if (joystick->hwdata->Capabilities.dwFlags & DIDC_FORCEFEEDBACK) { return 1; } @@ -299,7 +299,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect, /* Alloc the effect. */ effect->hweffect = (struct haptic_hweffect *) SDL_malloc(sizeof(struct haptic_hweffect)); - if (effect->hweffect == NULL) { + if (!effect->hweffect) { SDL_OutOfMemory(); return -1; } diff --git a/vs/sdl2/src/haptic/windows/SDL_windowshaptic_c.h b/vs/sdl2/src/haptic/windows/SDL_windowshaptic_c.h index 9ed62dd42f..e5d45d5263 100644 --- a/vs/sdl2/src/haptic/windows/SDL_windowshaptic_c.h +++ b/vs/sdl2/src/haptic/windows/SDL_windowshaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ extern "C" { */ struct haptic_hwdata { -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT LPDIRECTINPUTDEVICE8 device; #endif DWORD axes[3]; /* Axes to use. */ @@ -54,14 +54,14 @@ struct haptic_hwdata /* * Haptic system effect data. */ -#if SDL_HAPTIC_DINPUT || SDL_HAPTIC_XINPUT +#if defined(SDL_HAPTIC_DINPUT) || defined(SDL_HAPTIC_XINPUT) struct haptic_hweffect { -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT DIEFFECT effect; LPDIRECTINPUTEFFECT ref; #endif -#if SDL_HAPTIC_XINPUT +#ifdef SDL_HAPTIC_XINPUT XINPUT_VIBRATION vibration; #endif }; @@ -74,7 +74,7 @@ typedef struct SDL_hapticlist_item { char *name; SDL_Haptic *haptic; -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT DIDEVICEINSTANCE instance; DIDEVCAPS capabilities; #endif diff --git a/vs/sdl2/src/haptic/windows/SDL_xinputhaptic.c b/vs/sdl2/src/haptic/windows/SDL_xinputhaptic.c index 6c77163e16..0066412f4d 100644 --- a/vs/sdl2/src/haptic/windows/SDL_xinputhaptic.c +++ b/vs/sdl2/src/haptic/windows/SDL_xinputhaptic.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "SDL_haptic.h" #include "../SDL_syshaptic.h" -#if SDL_HAPTIC_XINPUT +#ifdef SDL_HAPTIC_XINPUT #include "SDL_hints.h" #include "SDL_timer.h" @@ -84,7 +84,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) } item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -119,7 +119,7 @@ int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) return -1; } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); @@ -178,7 +178,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { return SDL_OutOfMemory(); } /* Clear the memory */ @@ -186,7 +186,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us sizeof(struct haptic_effect) * haptic->neffects); haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_free(haptic->effects); haptic->effects = NULL; return SDL_OutOfMemory(); @@ -197,7 +197,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us haptic->hwdata->userid = userid; haptic->hwdata->mutex = SDL_CreateMutex(); - if (haptic->hwdata->mutex == NULL) { + if (!haptic->hwdata->mutex) { SDL_free(haptic->effects); SDL_free(haptic->hwdata); haptic->effects = NULL; @@ -207,7 +207,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us (void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", userid); haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata); - if (haptic->hwdata->thread == NULL) { + if (!haptic->hwdata->thread) { SDL_DestroyMutex(haptic->hwdata->mutex); SDL_free(haptic->effects); SDL_free(haptic->hwdata); @@ -234,7 +234,7 @@ int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick int index = 0; /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == joystick->hwdata->userid) { haptic->index = index; return SDL_XINPUT_HapticOpenFromUserIndex(haptic, joystick->hwdata->userid); diff --git a/vs/sdl2/src/haptic/windows/SDL_xinputhaptic_c.h b/vs/sdl2/src/haptic/windows/SDL_xinputhaptic_c.h index 3a6fbd3a1c..071d3e4761 100644 --- a/vs/sdl2/src/haptic/windows/SDL_xinputhaptic_c.h +++ b/vs/sdl2/src/haptic/windows/SDL_xinputhaptic_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/hidapi/SDL_hidapi.c b/vs/sdl2/src/hidapi/SDL_hidapi.c index 6c3e43fb61..ef9597782f 100644 --- a/vs/sdl2/src/hidapi/SDL_hidapi.c +++ b/vs/sdl2/src/hidapi/SDL_hidapi.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,25 +29,25 @@ */ #include "../SDL_internal.h" -#include "SDL_loadso.h" #include "SDL_hidapi.h" +#include "SDL_hidapi_c.h" +#include "SDL_loadso.h" #include "SDL_thread.h" #include "SDL_timer.h" -#include "SDL_hidapi_c.h" -#if !SDL_HIDAPI_DISABLED +#ifndef SDL_HIDAPI_DISABLED #if defined(__WIN32__) || defined(__WINGDK__) #include "../core/windows/SDL_windows.h" #endif #if defined(__MACOSX__) +#include #include -#include #include #include #include -#include +#include /* Things named "Master" were renamed to "Main" in macOS 12.0's SDK. */ #if MAC_OS_X_VERSION_MIN_REQUIRED < 120000 #define kIOMainPortDefault kIOMasterPortDefault @@ -56,16 +56,16 @@ #include "../core/linux/SDL_udev.h" #ifdef SDL_USE_LIBUDEV -#include #include "../core/linux/SDL_sandbox.h" +#include #endif #ifdef HAVE_INOTIFY -#include /* just in case we didn't use that SDL_USE_LIBUDEV block... */ -#include /* errno, strerror */ +#include /* errno, strerror */ #include #include /* For the definition of NAME_MAX */ #include +#include /* just in case we didn't use that SDL_USE_LIBUDEV block... */ #endif #if defined(SDL_USE_LIBUDEV) || defined(HAVE_INOTIFY) @@ -166,7 +166,6 @@ static LRESULT CALLBACK ControllerWndProc(HWND hwnd, UINT message, WPARAM wParam } #endif /* defined(__WIN32__) || defined(__WINGDK__) */ - #if defined(__MACOSX__) static void CallbackIOServiceFunc(void *context, io_iterator_t portIterator) { @@ -221,7 +220,7 @@ static int StrIsInteger(const char *string) } #endif /* HAVE_INOTIFY */ -static void HIDAPI_InitializeDiscovery() +static void HIDAPI_InitializeDiscovery(void) { SDL_HIDAPI_discovery.m_bInitialized = SDL_TRUE; SDL_HIDAPI_discovery.m_unDeviceChangeCounter = 1; @@ -360,7 +359,7 @@ static void HIDAPI_InitializeDiscovery() } } -static void HIDAPI_UpdateDiscovery() +static void HIDAPI_UpdateDiscovery(void) { if (!SDL_HIDAPI_discovery.m_bInitialized) { HIDAPI_InitializeDiscovery(); @@ -477,7 +476,7 @@ static void HIDAPI_UpdateDiscovery() } } -static void HIDAPI_ShutdownDiscovery() +static void HIDAPI_ShutdownDiscovery(void) { if (!SDL_HIDAPI_discovery.m_bInitialized) { return; @@ -557,9 +556,9 @@ static void HIDAPI_ShutdownDiscovery() #define read_thread PLATFORM_read_thread #undef HIDAPI_H__ -#if __LINUX__ +#ifdef __LINUX__ -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static const SDL_UDEV_Symbols *udev_ctx = NULL; #define udev_device_get_sysattr_value udev_ctx->udev_device_get_sysattr_value @@ -579,23 +578,23 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; #define udev_enumerate_unref udev_ctx->udev_enumerate_unref #include "linux/hid.c" -#define HAVE_PLATFORM_BACKEND 1 +#define HAVE_PLATFORM_BACKEND #endif /* SDL_USE_LIBUDEV */ -#elif __MACOSX__ +#elif defined(__MACOSX__) #include "mac/hid.c" -#define HAVE_PLATFORM_BACKEND 1 +#define HAVE_PLATFORM_BACKEND #define udev_ctx 1 -#elif __WINDOWS__ || __WINGDK__ +#elif defined(__WINDOWS__) || defined(__WINGDK__) #include "windows/hid.c" -#define HAVE_PLATFORM_BACKEND 1 +#define HAVE_PLATFORM_BACKEND #define udev_ctx 1 -#elif __ANDROID__ +#elif defined(__ANDROID__) /* The implementation for Android is in a separate .cpp file */ #include "hidapi/hidapi.h" #define HAVE_PLATFORM_BACKEND 1 -#define udev_ctx 1 -#elif __IPHONEOS__ || __TVOS__ +#define udev_ctx 1 +#elif defined(__IPHONEOS__) || defined(__TVOS__) /* The implementation for iOS and tvOS is in a separate .m file */ #include "hidapi/hidapi.h" #define HAVE_PLATFORM_BACKEND 1 @@ -631,9 +630,11 @@ static const SDL_UDEV_Symbols *udev_ctx = NULL; #ifdef SDL_JOYSTICK_HIDAPI_STEAMXBOX #define HAVE_DRIVER_BACKEND 1 +#else +#define HAVE_DRIVER_BACKEND 0 #endif -#ifdef HAVE_DRIVER_BACKEND +#if HAVE_DRIVER_BACKEND /* DRIVER HIDAPI Implementation */ @@ -809,8 +810,8 @@ static struct /* this is awkwardly inlined, so we need to re-implement it here * so we can override the libusb_control_transfer call */ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, - uint8_t descriptor_index, uint16_t lang_id, - unsigned char *data, int length) + uint8_t descriptor_index, uint16_t lang_id, + unsigned char *data, int length) { return libusb_control_transfer(dev, LIBUSB_ENDPOINT_IN | 0x0, LIBUSB_REQUEST_GET_DESCRIPTOR, (LIBUSB_DT_STRING << 8) | descriptor_index, lang_id, data, (uint16_t)length, 1000); /* Endpoint 0 IN */ @@ -876,6 +877,41 @@ static int SDL_libusb_get_string_descriptor(libusb_device_handle *dev, #undef make_path #undef read_thread +/* If the platform has any backend other than libusb, try to avoid using + * libusb as the main backend for devices, since it detaches drivers and + * therefore makes devices inaccessible to the rest of the OS. + * + * We do this by whitelisting devices we know to be accessible _exclusively_ + * via libusb; these are typically devices that look like HIDs but have a + * quirk that requires direct access to the hardware. + */ +static const struct { + Uint16 vendor; + Uint16 product; +} SDL_libusb_whitelist[] = { + { 0x057e, 0x0337 } /* Nintendo WUP-028, Wii U/Switch GameCube Adapter */ +}; + +static SDL_bool +IsInWhitelist(Uint16 vendor, Uint16 product) +{ + int i; + for (i = 0; i < SDL_arraysize(SDL_libusb_whitelist); i += 1) { + if (vendor == SDL_libusb_whitelist[i].vendor && + product == SDL_libusb_whitelist[i].product) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND +static const SDL_bool use_libusb_whitelist_default = SDL_TRUE; +#else +static const SDL_bool use_libusb_whitelist_default = SDL_FALSE; +#endif /* HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND */ +static SDL_bool use_libusb_whitelist = use_libusb_whitelist_default; + #endif /* HAVE_LIBUSB */ #endif /* !SDL_HIDAPI_DISABLED */ @@ -898,7 +934,7 @@ struct hidapi_backend const wchar_t *(*hid_error)(void *device); }; -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND static const struct hidapi_backend PLATFORM_Backend = { (void *)PLATFORM_hid_write, (void *)PLATFORM_hid_read_timeout, @@ -957,7 +993,7 @@ struct SDL_hid_device_ }; static char device_magic; -#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) static SDL_hid_device *CreateHIDDeviceWrapper(void *device, const struct hidapi_backend *backend) { @@ -982,8 +1018,8 @@ static void DeleteHIDDeviceWrapper(SDL_hid_device *device) return retval; \ } -#if !SDL_HIDAPI_DISABLED -#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) +#ifndef SDL_HIDAPI_DISABLED +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) #define COPY_IF_EXISTS(var) \ if (pSrc->var != NULL) { \ @@ -1061,6 +1097,8 @@ int SDL_hid_init(void) #endif #ifdef HAVE_LIBUSB + use_libusb_whitelist = SDL_GetHintBoolean("SDL_HIDAPI_LIBUSB_WHITELIST", + use_libusb_whitelist_default); if (SDL_getenv("SDL_HIDAPI_DISABLE_LIBUSB") != NULL) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, "libusb disabled by SDL_HIDAPI_DISABLE_LIBUSB"); @@ -1130,9 +1168,9 @@ int SDL_hid_init(void) } #endif /* HAVE_LIBUSB */ -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND ++attempts; -#if __LINUX__ +#ifdef __LINUX__ udev_ctx = SDL_UDEV_GetUdevSyms(); #endif /* __LINUX __ */ if (udev_ctx && PLATFORM_hid_init() == 0) { @@ -1161,15 +1199,15 @@ int SDL_hid_exit(void) } SDL_hidapi_refcount = 0; -#if !SDL_HIDAPI_DISABLED +#ifndef SDL_HIDAPI_DISABLED HIDAPI_ShutdownDiscovery(); #endif -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND if (udev_ctx) { result |= PLATFORM_hid_exit(); } -#if __LINUX__ +#ifdef __LINUX__ SDL_UDEV_ReleaseUdevSyms(); #endif /* __LINUX __ */ #endif /* HAVE_PLATFORM_BACKEND */ @@ -1191,7 +1229,7 @@ Uint32 SDL_hid_device_change_count(void) { Uint32 counter = 0; -#if !SDL_HIDAPI_DISABLED +#ifndef SDL_HIDAPI_DISABLED if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) { return 0; } @@ -1211,7 +1249,7 @@ Uint32 SDL_hid_device_change_count(void) struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned short product_id) { -#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) #ifdef HAVE_LIBUSB struct SDL_hid_device_info *usb_devs = NULL; struct SDL_hid_device_info *usb_dev; @@ -1220,7 +1258,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned struct SDL_hid_device_info *driver_devs = NULL; struct SDL_hid_device_info *driver_dev; #endif -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND struct SDL_hid_device_info *raw_devs = NULL; struct SDL_hid_device_info *raw_dev; #endif @@ -1237,6 +1275,16 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned SDL_Log("libusb devices found:"); #endif for (usb_dev = usb_devs; usb_dev; usb_dev = usb_dev->next) { + if (use_libusb_whitelist) { + if (!IsInWhitelist(usb_dev->vendor_id, usb_dev->product_id)) { +#ifdef DEBUG_HIDAPI + SDL_Log("Device was not in libusb whitelist: %ls %ls 0x%.4hx 0x%.4hx", + usb_dev->manufacturer_string, usb_dev->product_string, + usb_dev->vendor_id, usb_dev->product_id); +#endif /* DEBUG_HIDAPI */ + continue; + } + } new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); if (new_dev == NULL) { LIBUSB_hid_free_enumeration(usb_devs); @@ -1261,7 +1309,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned } #endif /* HAVE_LIBUSB */ -#ifdef HAVE_DRIVER_BACKEND +#if HAVE_DRIVER_BACKEND driver_devs = DRIVER_hid_enumerate(vendor_id, product_id); for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) { new_dev = (struct SDL_hid_device_info *)SDL_malloc(sizeof(struct SDL_hid_device_info)); @@ -1276,7 +1324,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned } #endif /* HAVE_DRIVER_BACKEND */ -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND if (udev_ctx) { raw_devs = PLATFORM_hid_enumerate(vendor_id, product_id); #ifdef DEBUG_HIDAPI @@ -1299,7 +1347,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned } } #endif -#ifdef HAVE_DRIVER_BACKEND +#if HAVE_DRIVER_BACKEND for (driver_dev = driver_devs; driver_dev; driver_dev = driver_dev->next) { if (raw_dev->vendor_id == driver_dev->vendor_id && raw_dev->product_id == driver_dev->product_id && @@ -1364,14 +1412,14 @@ void SDL_hid_free_enumeration(struct SDL_hid_device_info *devs) SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number) { -#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) void *pDevice = NULL; if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) { return NULL; } -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND if (udev_ctx) { pDevice = PLATFORM_hid_open(vendor_id, product_id, serial_number); if (pDevice != NULL) { @@ -1403,14 +1451,14 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id SDL_hid_device *SDL_hid_open_path(const char *path, int bExclusive /* = false */) { -#if HAVE_PLATFORM_BACKEND || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) +#if defined(HAVE_PLATFORM_BACKEND) || HAVE_DRIVER_BACKEND || defined(HAVE_LIBUSB) void *pDevice = NULL; if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) { return NULL; } -#if HAVE_PLATFORM_BACKEND +#ifdef HAVE_PLATFORM_BACKEND if (udev_ctx) { pDevice = PLATFORM_hid_open_path(path, bExclusive); if (pDevice != NULL) { @@ -1580,7 +1628,7 @@ int SDL_hid_get_indexed_string(SDL_hid_device *device, int string_index, wchar_t void SDL_hid_ble_scan(SDL_bool active) { -#if !SDL_HIDAPI_DISABLED && (__IPHONEOS__ || __TVOS__) +#if !defined(SDL_HIDAPI_DISABLED) && (defined(__IPHONEOS__) || defined(__TVOS__)) hid_ble_scan(active); #endif } diff --git a/vs/sdl2/src/hidapi/SDL_hidapi_c.h b/vs/sdl2/src/hidapi/SDL_hidapi_c.h index 796b9ba723..51fe0135c6 100644 --- a/vs/sdl2/src/hidapi/SDL_hidapi_c.h +++ b/vs/sdl2/src/hidapi/SDL_hidapi_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/hidapi/android/hid.cpp b/vs/sdl2/src/hidapi/android/hid.cpp index 34fda42d3d..3b050a6728 100644 --- a/vs/sdl2/src/hidapi/android/hid.cpp +++ b/vs/sdl2/src/hidapi/android/hid.cpp @@ -48,7 +48,7 @@ #define HID_DEVICE_MANAGER_JAVA_INTERFACE(function) CONCAT1(SDL_JAVA_PREFIX, HIDDeviceManager, function) -#if !SDL_HIDAPI_DISABLED +#ifndef SDL_HIDAPI_DISABLED #include "SDL_hints.h" #include "../../core/android/SDL_android.h" @@ -744,7 +744,7 @@ class CHIDDevice env->CallVoidMethod( g_HIDDeviceManagerCallbackHandler, g_midHIDDeviceManagerClose, m_nId ); ExceptionCheck( env, "Close" ); } - + hid_mutex_guard dataLock( &m_dataLock ); m_vecData.clear(); @@ -1139,7 +1139,7 @@ HID_API_EXPORT hid_device * HID_API_CALL hid_open_path(const char *path, int bEx hid_mutex_guard l( &g_DevicesMutex ); for ( hid_device_ref pCurr = g_Devices; pCurr; pCurr = pCurr->next ) { - if ( SDL_strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 ) + if ( SDL_strcmp( pCurr->GetDeviceInfo()->path, path ) == 0 ) { hid_device *pValue = pCurr->GetDevice(); if ( pValue ) diff --git a/vs/sdl2/src/hidapi/hidapi/hidapi.h b/vs/sdl2/src/hidapi/hidapi/hidapi.h index 3fddfa885e..1114aefc9c 100644 --- a/vs/sdl2/src/hidapi/hidapi/hidapi.h +++ b/vs/sdl2/src/hidapi/hidapi/hidapi.h @@ -406,7 +406,7 @@ namespace NAMESPACE { */ HID_API_EXPORT const wchar_t* HID_API_CALL hid_error(hid_device *dev); -#if __IPHONEOS__ || __TVOS__ +#if defined(__IPHONEOS__) || defined(__TVOS__) HID_API_EXPORT void HID_API_CALL hid_ble_scan(int active); #endif diff --git a/vs/sdl2/src/hidapi/ios/hid.m b/vs/sdl2/src/hidapi/ios/hid.m index 8ebfdbe72b..636d0f0769 100644 --- a/vs/sdl2/src/hidapi/ios/hid.m +++ b/vs/sdl2/src/hidapi/ios/hid.m @@ -20,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if !SDL_HIDAPI_DISABLED +#ifndef SDL_HIDAPI_DISABLED #include "SDL_hints.h" @@ -131,7 +131,7 @@ static void RingBuffer_init( RingBuffer *this ) this->_last = 0; pthread_mutex_init( &this->accessLock, 0 ); } - + static bool RingBuffer_write( RingBuffer *this, const uint8_t *src ) { pthread_mutex_lock( &this->accessLock ); @@ -290,7 +290,7 @@ - (int)updateConnectedSteamControllers:(BOOL) bForce { static uint64_t s_unLastUpdateTick = 0; static mach_timebase_info_data_t s_timebase_info; - + if ( self.centralManager == nil ) { return 0; @@ -300,11 +300,11 @@ - (int)updateConnectedSteamControllers:(BOOL) bForce { mach_timebase_info( &s_timebase_info ); } - + uint64_t ticksNow = mach_approximate_time(); if ( !bForce && ( ( (ticksNow - s_unLastUpdateTick) * s_timebase_info.numer ) / s_timebase_info.denom ) < (5ull * NSEC_PER_SEC) ) return (int)self.deviceMap.count; - + // we can see previously connected BLE peripherals but can't connect until the CBCentralManager // is fully powered up - only do work when we are in that state if ( self.centralManager.state != CBManagerStatePoweredOn ) @@ -312,7 +312,7 @@ - (int)updateConnectedSteamControllers:(BOOL) bForce // only update our last-check-time if we actually did work, otherwise there can be a long delay during initial power-up s_unLastUpdateTick = mach_approximate_time(); - + // if a pair is in-flight, the central manager may still give it back via retrieveConnected... and // cause the SDL layer to attempt to initialize it while some of its endpoints haven't yet been established if ( self.nPendingPairs > 0 ) @@ -324,7 +324,7 @@ - (int)updateConnectedSteamControllers:(BOOL) bForce // we already know this peripheral if ( [self.deviceMap objectForKey: peripheral] != nil ) continue; - + NSLog( @"connected peripheral: %@", peripheral ); if ( [peripheral.name isEqualToString:@"SteamController"] ) { @@ -392,7 +392,7 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central case CBCentralManagerStatePoweredOn: { NSLog( @"CoreBluetooth BLE hardware is powered on and ready" ); - + // at startup, if we have no already attached peripherals, do a 20s scan for new unpaired devices, // otherwise callers should occaisionally do additional scans. we don't want to continuously be // scanning because it drains battery, causes other nearby people to have a hard time pairing their @@ -408,23 +408,23 @@ - (void)centralManagerDidUpdateState:(CBCentralManager *)central } break; } - + case CBCentralManagerStatePoweredOff: NSLog( @"CoreBluetooth BLE hardware is powered off" ); break; - + case CBCentralManagerStateUnauthorized: NSLog( @"CoreBluetooth BLE state is unauthorized" ); break; - + case CBCentralManagerStateUnknown: NSLog( @"CoreBluetooth BLE state is unknown" ); break; - + case CBCentralManagerStateUnsupported: NSLog( @"CoreBluetooth BLE hardware is unsupported on this platform" ); break; - + case CBCentralManagerStateResetting: NSLog( @"CoreBluetooth BLE manager is resetting" ); break; @@ -449,7 +449,7 @@ - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeri { NSString *localName = [advertisementData objectForKey:CBAdvertisementDataLocalNameKey]; NSString *log = [NSString stringWithFormat:@"Found '%@'", localName]; - + if ( [localName isEqualToString:@"SteamController"] ) { NSLog( @"%@ : %@ - %@", log, peripheral, advertisementData ); @@ -475,7 +475,7 @@ - (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPe // Core Bluetooth devices calling back on event boundaries of their run-loops. so annoying. -static void process_pending_events() +static void process_pending_events(void) { CFRunLoopRunResult res; do @@ -552,7 +552,7 @@ - (int)send_feature_report:(hidFeatureReport *)report { #if FEATURE_REPORT_LOGGING uint8_t *reportBytes = (uint8_t *)report; - + NSLog( @"HIDBLE:send_feature_report (%02zu/19) [%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]", GetBluetoothSegmentSize( report->segment ), reportBytes[1], reportBytes[2], reportBytes[3], reportBytes[4], reportBytes[5], reportBytes[6], reportBytes[7], reportBytes[8], reportBytes[9], reportBytes[10], reportBytes[11], reportBytes[12], @@ -568,7 +568,7 @@ - (int)send_feature_report:(hidFeatureReport *)report // fire-and-forget - we are going to not wait for the response here because all Steam Controller BLE send_feature_report's are ignored, // except errors. [_bleSteamController writeValue:[NSData dataWithBytes:&report->segment length:sendSize] forCharacteristic:_bleCharacteristicReport type:CBCharacteristicWriteWithResponse]; - + // pretend we received a result anybody cares about return 19; @@ -578,18 +578,18 @@ - (int)send_feature_report:(hidFeatureReport *)report _waitStateForWriteFeatureReport = BLEDeviceWaitState_Waiting; [_bleSteamController writeValue:[NSData dataWithBytes:&report->segment length:sendSize ] forCharacteristic:_bleCharacteristicReport type:CBCharacteristicWriteWithResponse]; - + while ( _waitStateForWriteFeatureReport == BLEDeviceWaitState_Waiting ) { process_pending_events(); } - + if ( _waitStateForWriteFeatureReport == BLEDeviceWaitState_Error ) { _waitStateForWriteFeatureReport = BLEDeviceWaitState_None; return -1; } - + _waitStateForWriteFeatureReport = BLEDeviceWaitState_None; return 19; #endif @@ -599,20 +599,20 @@ - (int)get_feature_report:(uint8_t)feature into:(uint8_t *)buffer { _waitStateForReadFeatureReport = BLEDeviceWaitState_Waiting; [_bleSteamController readValueForCharacteristic:_bleCharacteristicReport]; - + while ( _waitStateForReadFeatureReport == BLEDeviceWaitState_Waiting ) process_pending_events(); - + if ( _waitStateForReadFeatureReport == BLEDeviceWaitState_Error ) { _waitStateForReadFeatureReport = BLEDeviceWaitState_None; return -1; } - + memcpy( buffer, _featureReport, sizeof(_featureReport) ); - + _waitStateForReadFeatureReport = BLEDeviceWaitState_None; - + #if FEATURE_REPORT_LOGGING NSLog( @"HIDBLE:get_feature_report (19) [%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x]", buffer[1], buffer[2], buffer[3], buffer[4], buffer[5], buffer[6], @@ -657,7 +657,7 @@ - (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForServi for (CBCharacteristic *aChar in service.characteristics) { NSLog( @"Found Characteristic %@", aChar ); - + if ( [aChar.UUID isEqual:[CBUUID UUIDWithString:VALVE_INPUT_CHAR]] ) { self.bleCharacteristicInput = aChar; @@ -704,7 +704,7 @@ - (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(C else if ( [characteristic.UUID isEqual:_bleCharacteristicReport.UUID] ) { memset( _featureReport, 0, sizeof(_featureReport) ); - + if ( error != nil ) { NSLog( @"HIDBLE: get_feature_report error: %@", error ); @@ -789,13 +789,13 @@ void HID_API_EXPORT HID_API_CALL hid_ble_scan( int bStart ) NSString *nssPath = [NSString stringWithUTF8String:path]; HIDBLEManager *bleManager = HIDBLEManager.sharedInstance; NSEnumerator *devices = [bleManager.deviceMap objectEnumerator]; - + for ( HIDBLEDevice *device in devices ) { // we have the device but it hasn't found its service or characteristics until it is connected if ( !device.ready || !device.connected || !device.bleCharacteristicInput ) continue; - + if ( [device.bleSteamController.identifier.UUIDString isEqualToString:nssPath] ) { result = (hid_device *)malloc( sizeof( hid_device ) ); @@ -829,7 +829,7 @@ int HID_API_EXPORT hid_set_nonblocking(hid_device *dev, int nonblock) { /* All Nonblocking operation is handled by the library. */ dev->blocking = !nonblock; - + return 0; } @@ -953,7 +953,7 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, return -1; size_t written = [device_handle get_feature_report:data[0] into:data]; - + return written == length-1 ? (int)length : (int)written; } @@ -973,7 +973,7 @@ int HID_API_EXPORT hid_read_timeout(hid_device *dev, unsigned char *data, size_t if ( !device_handle.connected ) return -1; - + if ( milliseconds != 0 ) { NSLog( @"hid_read_timeout with non-zero wait" ); diff --git a/vs/sdl2/src/hidapi/libusb/hid.c b/vs/sdl2/src/hidapi/libusb/hid.c index 98eaa0e69b..008131bd9d 100644 --- a/vs/sdl2/src/hidapi/libusb/hid.c +++ b/vs/sdl2/src/hidapi/libusb/hid.c @@ -711,6 +711,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de static const int XB1_IFACE_SUBCLASS = 71; static const int XB1_IFACE_PROTOCOL = 208; static const int SUPPORTED_VENDORS[] = { + 0x03f0, /* HP */ 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ @@ -722,6 +723,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de 0x24c6, /* PowerA */ 0x2dc8, /* 8BitDo */ 0x2e24, /* Hyperkin */ + 0x3537, /* GameSir */ }; if (intf_desc->bInterfaceNumber == 0 && diff --git a/vs/sdl2/src/hidapi/linux/hid.c b/vs/sdl2/src/hidapi/linux/hid.c index 063ba37c32..8c3aeaed68 100644 --- a/vs/sdl2/src/hidapi/linux/hid.c +++ b/vs/sdl2/src/hidapi/linux/hid.c @@ -884,9 +884,9 @@ int HID_API_EXPORT hid_get_feature_report(hid_device *dev, unsigned char *data, unsigned char report = data[0]; res = ioctl(dev->device_handle, HIDIOCGFEATURE(length), data); - if (res < 0) - perror("ioctl (GFEATURE)"); - else if (dev->needs_ble_hack) { + if (res < 0) { + /* perror("ioctl (GFEATURE)"); */ + } else if (dev->needs_ble_hack) { /* Versions of BlueZ before 5.56 don't include the report in the data, * and versions of BlueZ >= 5.56 include 2 copies of the report. * We'll fix it so that there is a single copy of the report in both cases diff --git a/vs/sdl2/src/hidapi/mac/hid.c b/vs/sdl2/src/hidapi/mac/hid.c index c6541682c5..bbb5c625da 100644 --- a/vs/sdl2/src/hidapi/mac/hid.c +++ b/vs/sdl2/src/hidapi/mac/hid.c @@ -957,7 +957,9 @@ static int return_data(hid_device *dev, unsigned char *data, size_t length) size_t len = 0; if (rpt != NULL) { len = (length < rpt->len)? length: rpt->len; - memcpy(data, rpt->data, len); + if (data != NULL) { + memcpy(data, rpt->data, len); + } dev->input_reports = rpt->next; free(rpt->data); free(rpt); diff --git a/vs/sdl2/src/joystick/SDL_gamecontroller.c b/vs/sdl2/src/joystick/SDL_gamecontroller.c index 035176b37f..a7d3303b31 100644 --- a/vs/sdl2/src/joystick/SDL_gamecontroller.c +++ b/vs/sdl2/src/joystick/SDL_gamecontroller.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 +27,13 @@ #include "SDL_timer.h" #include "SDL_sysjoystick.h" #include "SDL_joystick_c.h" +#include "SDL_steam_virtual_gamepad.h" #include "SDL_gamecontrollerdb.h" #include "controller_type.h" #include "usb_ids.h" #include "hidapi/SDL_hidapi_nintendo.h" -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif @@ -45,6 +46,8 @@ #define SDL_CONTROLLER_CRC_FIELD "crc:" #define SDL_CONTROLLER_CRC_FIELD_SIZE 4 /* hard-coded for speed */ +#define SDL_CONTROLLER_TYPE_FIELD "type:" +#define SDL_CONTROLLER_TYPE_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_TYPE_FIELD) #define SDL_CONTROLLER_PLATFORM_FIELD "platform:" #define SDL_CONTROLLER_PLATFORM_FIELD_SIZE SDL_strlen(SDL_CONTROLLER_PLATFORM_FIELD) #define SDL_CONTROLLER_HINT_FIELD "hint:" @@ -133,6 +136,7 @@ struct _SDL_GameController int ref_count _guarded; const char *name _guarded; + SDL_GameControllerType type _guarded; ControllerMapping_t *mapping _guarded; int num_bindings _guarded; SDL_ExtendedGameControllerBind *bindings _guarded; @@ -153,70 +157,18 @@ struct _SDL_GameController return retval; \ } -typedef struct -{ - int num_entries; - int max_entries; - Uint32 *entries; -} SDL_vidpid_list; - -static SDL_vidpid_list SDL_allowed_controllers; -static SDL_vidpid_list SDL_ignored_controllers; - -static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) -{ - Uint32 entry; - char *spot; - char *file = NULL; - - list->num_entries = 0; - - if (hint && *hint == '@') { - spot = file = (char *)SDL_LoadFile(hint + 1, NULL); - } else { - spot = (char *)hint; - } - - if (spot == NULL) { - return; - } - - while ((spot = SDL_strstr(spot, "0x")) != NULL) { - entry = (Uint16)SDL_strtol(spot, &spot, 0); - entry <<= 16; - spot = SDL_strstr(spot, "0x"); - if (spot == NULL) { - break; - } - entry |= (Uint16)SDL_strtol(spot, &spot, 0); - - if (list->num_entries == list->max_entries) { - int max_entries = list->max_entries + 16; - Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries * sizeof(*list->entries)); - if (entries == NULL) { - /* Out of memory, go with what we have already */ - break; - } - list->entries = entries; - list->max_entries = max_entries; - } - list->entries[list->num_entries++] = entry; - } - - if (file) { - SDL_free(file); - } -} - -static void SDLCALL SDL_GameControllerIgnoreDevicesChanged(void *userdata, const char *name, const char *oldValue, const char *hint) -{ - SDL_LoadVIDPIDListFromHint(hint, &SDL_ignored_controllers); -} - -static void SDLCALL SDL_GameControllerIgnoreDevicesExceptChanged(void *userdata, const char *name, const char *oldValue, const char *hint) -{ - SDL_LoadVIDPIDListFromHint(hint, &SDL_allowed_controllers); -} +static SDL_vidpid_list SDL_allowed_controllers = { + SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, 0, 0, NULL, + NULL, 0, 0, NULL, + 0, NULL, + SDL_FALSE +}; +static SDL_vidpid_list SDL_ignored_controllers = { + SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, 0, 0, NULL, + NULL, 0, 0, NULL, + 0, NULL, + SDL_FALSE +}; static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_ControllerMappingPriority priority); static int SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis, Sint16 value); @@ -273,7 +225,7 @@ static void HandleJoystickAxis(SDL_GameController *gamecontroller, int axis, int } } - if (last_match && (match == NULL || !HasSameOutput(last_match, match))) { + if (last_match && (!match || !HasSameOutput(last_match, match))) { /* Clear the last input that this axis generated */ ResetOutput(gamecontroller, last_match); } @@ -568,9 +520,11 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); if ((vendor == USB_VENDOR_NINTENDO && product == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) || - (vendor == USB_VENDOR_DRAGONRISE && product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER)) { + (vendor == USB_VENDOR_DRAGONRISE && + (product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 || + product == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2))) { /* 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)); + 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 if (vendor == USB_VENDOR_NINTENDO && (guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCLeft || guid.data[15] == k_eSwitchDeviceInfoControllerType_HVCRight || @@ -601,7 +555,7 @@ static ControllerMapping_t *SDL_CreateMappingForHIDAPIController(SDL_JoystickGUI 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,righttrigger:a5,start:b6,x:b2,y:b3,misc1:b15,", sizeof(mapping_string)); break; case k_eSwitchDeviceInfoControllerType_SEGA_Genesis: - SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,rightshoulder:b10,righttrigger:a5,start:b6,misc1:b15,", sizeof(mapping_string)); + SDL_strlcat(mapping_string, "a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b9,rightshoulder:b10,righttrigger:a5,start:b6,x:b2,y:b3,misc1:b15,", sizeof(mapping_string)); break; case k_eWiiExtensionControllerType_None: SDL_strlcat(mapping_string, "a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,start:b6,x:b2,y:b3,", sizeof(mapping_string)); @@ -811,7 +765,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG /* Try harder to get the best match, or create a mapping */ - if (vendor && product) { + if (SDL_JoystickGUIDUsesVersion(guid)) { /* Try again, ignoring the version */ if (crc) { mapping = SDL_PrivateMatchControllerMappingForGUID(guid, SDL_TRUE, SDL_FALSE); @@ -826,7 +780,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG } } -#if SDL_JOYSTICK_XINPUT +#ifdef SDL_JOYSTICK_XINPUT if (SDL_IsJoystickXInput(guid)) { /* This is an XInput device */ return s_pXInputMapping; @@ -848,6 +802,47 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG return mapping; } +static const char *map_StringForGameControllerType[] = { + "unknown", + "xbox360", + "xboxone", + "ps3", + "ps4", + "switchpro", + "virtual", + "ps5", + "amazonluna", + "googlestadia", + "nvidiashield", + "joyconleft", + "joyconright", + "joyconpair" +}; +SDL_COMPILE_TIME_ASSERT(map_StringForGameControllerType, SDL_arraysize(map_StringForGameControllerType) == SDL_CONTROLLER_TYPE_MAX); + +/* + * convert a string to its enum equivalent + */ +SDL_GameControllerType SDL_GetGameControllerTypeFromString(const char *str) +{ + int i; + + if (!str || str[0] == '\0') { + return SDL_CONTROLLER_TYPE_UNKNOWN; + } + + if (*str == '+' || *str == '-') { + ++str; + } + + for (i = 0; i < SDL_arraysize(map_StringForGameControllerType); ++i) { + if (SDL_strcasecmp(str, map_StringForGameControllerType[i]) == 0) { + return (SDL_GameControllerType)i; + } + } + return SDL_CONTROLLER_TYPE_UNKNOWN; +} + static const char *map_StringForControllerAxis[] = { "leftx", "lefty", @@ -1071,6 +1066,7 @@ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameControl } else if (bGameButton) { if (i >= sizeof(szGameButton)) { + szGameButton[sizeof(szGameButton) - 1] = '\0'; SDL_SetError("Button name too large: %s", szGameButton); return; } @@ -1078,6 +1074,7 @@ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameControl i++; } else { if (i >= sizeof(szJoystickButton)) { + szJoystickButton[sizeof(szJoystickButton) - 1] = '\0'; SDL_SetError("Joystick button name too large: %s", szJoystickButton); return; } @@ -1093,6 +1090,31 @@ static void SDL_PrivateGameControllerParseControllerConfigString(SDL_GameControl } } +static void SDL_UpdateGameControllerType(SDL_GameController *gamecontroller) +{ + char *type_string, *comma; + + SDL_AssertJoysticksLocked(); + + gamecontroller->type = SDL_CONTROLLER_TYPE_UNKNOWN; + + type_string = SDL_strstr(gamecontroller->mapping->mapping, SDL_CONTROLLER_TYPE_FIELD); + if (type_string) { + type_string += SDL_CONTROLLER_TYPE_FIELD_SIZE; + comma = SDL_strchr(type_string, ','); + if (comma) { + *comma = '\0'; + gamecontroller->type = SDL_GetGameControllerTypeFromString(type_string); + *comma = ','; + } else { + gamecontroller->type = SDL_GetGameControllerTypeFromString(type_string); + } + } + if (gamecontroller->type == SDL_CONTROLLER_TYPE_UNKNOWN) { + gamecontroller->type = SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(gamecontroller->joystick), SDL_JoystickName(gamecontroller->joystick)); + } +} + /* * Make a new button mapping struct */ @@ -1105,12 +1127,14 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con gamecontroller->name = pControllerMapping->name; gamecontroller->num_bindings = 0; gamecontroller->mapping = pControllerMapping; - if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis != NULL) { + if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis) { SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); } SDL_PrivateGameControllerParseControllerConfigString(gamecontroller, pControllerMapping->mapping); + SDL_UpdateGameControllerType(gamecontroller); + /* Set the zero point for triggers */ for (i = 0; i < gamecontroller->num_bindings; ++i) { SDL_ExtendedGameControllerBind *binding = &gamecontroller->bindings[i]; @@ -1134,7 +1158,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) const char *pFirstComma = SDL_strchr(pMapping, ','); if (pFirstComma) { char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1); - if (pchGUID == NULL) { + if (!pchGUID) { SDL_OutOfMemory(); return NULL; } @@ -1150,7 +1174,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(const char *pMapping) SDL_memcpy(&pchGUID[8], &pchGUID[0], 4); SDL_memcpy(&pchGUID[0], "03000000", 8); } -#elif __MACOSX__ +#elif defined(__MACOSX__) if (SDL_strlen(pchGUID) == 32 && SDL_memcmp(&pchGUID[4], "000000000000", 12) == 0 && SDL_memcmp(&pchGUID[20], "000000000000", 12) == 0) { @@ -1173,17 +1197,17 @@ static char *SDL_PrivateGetControllerNameFromMappingString(const char *pMapping) char *pchName; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } pchName = SDL_malloc(pSecondComma - pFirstComma); - if (pchName == NULL) { + if (!pchName) { SDL_OutOfMemory(); return NULL; } @@ -1200,12 +1224,12 @@ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMappi const char *pFirstComma, *pSecondComma; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } @@ -1248,13 +1272,13 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, SDL_AssertJoysticksLocked(); pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString); - if (pchName == NULL) { + if (!pchName) { SDL_SetError("Couldn't parse name from %s", mappingString); return NULL; } pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString); - if (pchMapping == NULL) { + if (!pchMapping) { SDL_free(pchName); SDL_SetError("Couldn't parse %s", mappingString); return NULL; @@ -1311,7 +1335,7 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, *existing = SDL_TRUE; } else { pControllerMapping = SDL_malloc(sizeof(*pControllerMapping)); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { SDL_free(pchName); SDL_free(pchMapping); SDL_OutOfMemory(); @@ -1356,7 +1380,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const mapping = SDL_PrivateGetControllerMappingForGUID(guid, SDL_FALSE); #ifdef __LINUX__ - if (mapping == NULL && name) { + if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ SDL_bool existing; @@ -1367,7 +1391,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const } #endif /* __LINUX__ */ - if (mapping == NULL) { + if (!mapping) { mapping = s_pDefaultMapping; } return mapping; @@ -1390,7 +1414,11 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string, (void)SDL_snprintf(buffer, sizeof(buffer), "b%i", mapping->target); break; case EMappingKind_Axis: - (void)SDL_snprintf(buffer, sizeof(buffer), "a%i", mapping->target); + (void)SDL_snprintf(buffer, sizeof(buffer), "%sa%i%s", + mapping->half_axis_positive ? "+" : + mapping->half_axis_negative ? "-" : "", + mapping->target, + mapping->axis_reversed ? "~" : ""); break; case EMappingKind_Hat: (void)SDL_snprintf(buffer, sizeof(buffer), "h%i.%i", mapping->target >> 4, mapping->target & 0x0F); @@ -1448,6 +1476,7 @@ static ControllerMapping_t *SDL_PrivateGenerateAutomaticControllerMapping(const SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "righty", &raw_map->righty); SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "lefttrigger", &raw_map->lefttrigger); SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "righttrigger", &raw_map->righttrigger); + SDL_PrivateAppendToMappingString(mapping, sizeof(mapping), "touchpad", &raw_map->touchpad); return SDL_PrivateAddMappingForGUID(guid, mapping, &existing, SDL_CONTROLLER_MAPPING_PRIORITY_DEFAULT); } @@ -1468,7 +1497,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) name = SDL_JoystickNameForIndex(device_index); guid = SDL_JoystickGetDeviceGUID(device_index); mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); - if (mapping == NULL) { + if (!mapping) { SDL_GamepadMapping raw_map; SDL_zero(raw_map); @@ -1490,13 +1519,13 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) char *buf, *line, *line_end, *tmp, *comma, line_platform[64]; size_t db_size, platform_len; - if (rw == NULL) { + if (!rw) { return SDL_SetError("Invalid RWops"); } db_size = (size_t)SDL_RWsize(rw); buf = (char *)SDL_malloc(db_size + 1); - if (buf == NULL) { + if (!buf) { if (freerw) { SDL_RWclose(rw); } @@ -1520,7 +1549,7 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) while (line < buf + db_size) { line_end = SDL_strchr(line, '\n'); - if (line_end != NULL) { + if (line_end) { *line_end = '\0'; } else { line_end = buf + db_size; @@ -1528,10 +1557,10 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_CONTROLLER_PLATFORM_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_PLATFORM_FIELD_SIZE; comma = SDL_strchr(tmp, ','); - if (comma != NULL) { + if (comma) { platform_len = comma - tmp + 1; if (platform_len + 1 < SDL_arraysize(line_platform)) { SDL_strlcpy(line_platform, tmp, platform_len); @@ -1564,7 +1593,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_AssertJoysticksLocked(); - if (mappingString == NULL) { + if (!mappingString) { return SDL_InvalidParamError("mappingString"); } @@ -1572,7 +1601,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_HINT_FIELD); - if (tmp != NULL) { + if (tmp) { SDL_bool default_value, value, negate; int len; char hint[128]; @@ -1614,14 +1643,14 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_SDKGE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_SDKGE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() >= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d < minimum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); } } tmp = SDL_strstr(mappingString, SDL_CONTROLLER_SDKLE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_SDKLE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() <= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d > maximum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); @@ -1631,7 +1660,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co #endif pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString); - if (pchGUID == NULL) { + if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } if (!SDL_strcasecmp(pchGUID, "default")) { @@ -1643,7 +1672,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_free(pchGUID); pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { return -1; } @@ -1724,7 +1753,7 @@ static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID } pMappingString = SDL_malloc(needed); - if (pMappingString == NULL) { + if (!pMappingString) { SDL_OutOfMemory(); return NULL; } @@ -1774,7 +1803,7 @@ char *SDL_GameControllerMappingForIndex(int mapping_index) } SDL_UnlockJoysticks(); - if (retval == NULL) { + if (!retval) { SDL_SetError("Mapping not available"); } return retval; @@ -1820,7 +1849,7 @@ char *SDL_GameControllerMapping(SDL_GameController *gamecontroller) return retval; } -static void SDL_GameControllerLoadHints() +static void SDL_GameControllerLoadHints(void) { const char *hint = SDL_GetHint(SDL_HINT_GAMECONTROLLERCONFIG); if (hint && hint[0]) { @@ -1894,10 +1923,8 @@ int SDL_GameControllerInitMappings(void) /* load in any user supplied config */ SDL_GameControllerLoadHints(); - SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, - SDL_GameControllerIgnoreDevicesChanged, NULL); - SDL_AddHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, - SDL_GameControllerIgnoreDevicesExceptChanged, NULL); + SDL_LoadVIDPIDList(&SDL_allowed_controllers); + SDL_LoadVIDPIDList(&SDL_ignored_controllers); return 0; } @@ -1932,7 +1959,7 @@ const char *SDL_GameControllerNameForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { if (SDL_strcmp(mapping->name, "*") == 0) { retval = SDL_JoystickNameForIndex(joystick_index); } else { @@ -1955,7 +1982,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { retval = SDL_JoystickPathForIndex(joystick_index); } } @@ -1969,7 +1996,26 @@ const char *SDL_GameControllerPathForIndex(int joystick_index) */ SDL_GameControllerType SDL_GameControllerTypeForIndex(int joystick_index) { - return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetDeviceGUID(joystick_index), SDL_JoystickNameForIndex(joystick_index)); + SDL_JoystickGUID joystick_guid = SDL_JoystickGetDeviceGUID(joystick_index); + const char *mapping = SDL_GameControllerMappingForGUID(joystick_guid); + char *type_string, *comma; + SDL_GameControllerType type; + if (mapping) { + type_string = SDL_strstr(mapping, SDL_CONTROLLER_TYPE_FIELD); + if (type_string) { + type_string += SDL_CONTROLLER_TYPE_FIELD_SIZE; + comma = SDL_strchr(type_string, ','); + if (comma) { + *comma = '\0'; + type = SDL_GetGameControllerTypeFromString(type_string); + *comma = ','; + } else { + type = SDL_GetGameControllerTypeFromString(type_string); + } + return type; + } + } + return SDL_GetJoystickGameControllerTypeFromGUID(joystick_guid, SDL_JoystickNameForIndex(joystick_index)); } /** @@ -1984,7 +2030,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; @@ -1993,7 +2039,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; retval = (char *)SDL_malloc(needed); - if (retval != NULL) { + if (retval) { (void)SDL_snprintf(retval, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } else { SDL_OutOfMemory(); @@ -2064,11 +2110,9 @@ static SDL_bool SDL_endswith(const char *string, const char *suffix) */ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid) { - int i; Uint16 vendor; Uint16 product; Uint16 version; - Uint32 vidpid; #if defined(__LINUX__) if (SDL_endswith(name, " Motion Sensors")) { @@ -2093,8 +2137,8 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid) return SDL_TRUE; } - if (SDL_allowed_controllers.num_entries == 0 && - SDL_ignored_controllers.num_entries == 0) { + if (SDL_allowed_controllers.num_included_entries == 0 && + SDL_ignored_controllers.num_included_entries == 0) { return SDL_FALSE; } @@ -2117,20 +2161,14 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid) } } - vidpid = MAKE_VIDPID(vendor, product); - - if (SDL_allowed_controllers.num_entries > 0) { - for (i = 0; i < SDL_allowed_controllers.num_entries; ++i) { - if (vidpid == SDL_allowed_controllers.entries[i]) { - return SDL_FALSE; - } + if (SDL_allowed_controllers.num_included_entries > 0) { + if (SDL_VIDPIDInList(vendor, product, &SDL_allowed_controllers)) { + return SDL_FALSE; } return SDL_TRUE; } else { - for (i = 0; i < SDL_ignored_controllers.num_entries; ++i) { - if (vidpid == SDL_ignored_controllers.entries[i]) { - return SDL_TRUE; - } + if (SDL_VIDPIDInList(vendor, product, &SDL_ignored_controllers)) { + return SDL_TRUE; } return SDL_FALSE; } @@ -2155,7 +2193,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontrollerlist = SDL_gamecontrollers; /* If the controller is already open, return it */ instance_id = SDL_JoystickGetDeviceInstanceID(joystick_index); - while (gamecontrollerlist != NULL) { + while (gamecontrollerlist) { if (instance_id == gamecontrollerlist->joystick->instance_id) { gamecontroller = gamecontrollerlist; ++gamecontroller->ref_count; @@ -2167,7 +2205,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Find a controller mapping */ pSupportedController = SDL_PrivateGetControllerMapping(joystick_index); - if (pSupportedController == NULL) { + if (!pSupportedController) { SDL_SetError("Couldn't find mapping for device (%d)", joystick_index); SDL_UnlockJoysticks(); return NULL; @@ -2175,7 +2213,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Create and initialize the controller */ gamecontroller = (SDL_GameController *)SDL_calloc(1, sizeof(*gamecontroller)); - if (gamecontroller == NULL) { + if (!gamecontroller) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -2183,7 +2221,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontroller->magic = &gamecontroller_magic; gamecontroller->joystick = SDL_JoystickOpen(joystick_index); - if (gamecontroller->joystick == NULL) { + if (!gamecontroller->joystick) { SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; @@ -2640,7 +2678,8 @@ const char *SDL_GameControllerName(SDL_GameController *gamecontroller) { CHECK_GAMECONTROLLER_MAGIC(gamecontroller, NULL); - if (SDL_strcmp(gamecontroller->name, "*") == 0) { + if (SDL_strcmp(gamecontroller->name, "*") == 0 || + gamecontroller->joystick->steam_handle != 0) { retval = SDL_JoystickName(gamecontroller->joystick); } else { retval = gamecontroller->name; @@ -2655,7 +2694,7 @@ const char *SDL_GameControllerPath(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickPath(joystick); @@ -2663,19 +2702,34 @@ const char *SDL_GameControllerPath(SDL_GameController *gamecontroller) SDL_GameControllerType SDL_GameControllerGetType(SDL_GameController *gamecontroller) { - SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); + SDL_GameControllerType type = SDL_CONTROLLER_TYPE_UNKNOWN; + SDL_Joystick *joystick; + const SDL_SteamVirtualGamepadInfo *info; - if (joystick == NULL) { - return SDL_CONTROLLER_TYPE_UNKNOWN; + SDL_LockJoysticks(); + { + CHECK_GAMECONTROLLER_MAGIC(gamecontroller, SDL_CONTROLLER_TYPE_UNKNOWN); + + joystick = gamecontroller->joystick; + info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id); + if (info) { + type = info->type; + } else if (gamecontroller->type != SDL_CONTROLLER_TYPE_UNKNOWN) { + type = gamecontroller->type; + } else { + type = SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick)); + } } - return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick)); + SDL_UnlockJoysticks(); + + return type; } int SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickGetPlayerIndex(joystick); @@ -2688,7 +2742,7 @@ void SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int pl { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return; } SDL_JoystickSetPlayerIndex(joystick, player_index); @@ -2698,7 +2752,7 @@ Uint16 SDL_GameControllerGetVendor(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetVendor(joystick); @@ -2708,7 +2762,7 @@ Uint16 SDL_GameControllerGetProduct(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProduct(joystick); @@ -2718,7 +2772,7 @@ Uint16 SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProductVersion(joystick); @@ -2728,7 +2782,7 @@ Uint16 SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetFirmwareVersion(joystick); @@ -2738,12 +2792,27 @@ const char * SDL_GameControllerGetSerial(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickGetSerial(joystick); } +Uint64 SDL_GameControllerGetSteamHandle(SDL_GameController *gamecontroller) +{ + Uint64 handle = 0; + + SDL_LockJoysticks(); + { + CHECK_GAMECONTROLLER_MAGIC(gamecontroller, 0); + + handle = gamecontroller->joystick->steam_handle; + } + SDL_UnlockJoysticks(); + + return handle; +} + /* * Return if the controller in question is currently attached to the system, * \return 0 if not plugged in, 1 if still present. @@ -2752,7 +2821,7 @@ SDL_bool SDL_GameControllerGetAttached(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickGetAttached(joystick); @@ -2894,7 +2963,7 @@ int SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_freq { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); @@ -2904,7 +2973,7 @@ int SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumbleTriggers(joystick, left_rumble, right_rumble, duration_ms); @@ -2914,7 +2983,7 @@ SDL_bool SDL_GameControllerHasLED(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasLED(joystick); @@ -2924,7 +2993,7 @@ SDL_bool SDL_GameControllerHasRumble(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumble(joystick); @@ -2934,7 +3003,7 @@ SDL_bool SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumbleTriggers(joystick); @@ -2944,7 +3013,7 @@ int SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSetLED(joystick, red, green, blue); @@ -2954,7 +3023,7 @@ int SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSendEffect(joystick, data, size); @@ -2966,7 +3035,7 @@ void SDL_GameControllerClose(SDL_GameController *gamecontroller) SDL_LockJoysticks(); - if (gamecontroller == NULL || gamecontroller->magic != &gamecontroller_magic) { + if (!gamecontroller || gamecontroller->magic != &gamecontroller_magic) { SDL_UnlockJoysticks(); return; } @@ -3033,19 +3102,8 @@ void SDL_GameControllerQuitMappings(void) SDL_DelEventWatch(SDL_GameControllerEventWatcher, NULL); - SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, - SDL_GameControllerIgnoreDevicesChanged, NULL); - SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, - SDL_GameControllerIgnoreDevicesExceptChanged, NULL); - - if (SDL_allowed_controllers.entries) { - SDL_free(SDL_allowed_controllers.entries); - SDL_zero(SDL_allowed_controllers); - } - if (SDL_ignored_controllers.entries) { - SDL_free(SDL_ignored_controllers.entries); - SDL_zero(SDL_ignored_controllers); - } + SDL_FreeVIDPIDList(&SDL_allowed_controllers); + SDL_FreeVIDPIDList(&SDL_ignored_controllers); } /* @@ -3059,7 +3117,7 @@ static int SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL /* translate the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_CONTROLLERAXISMOTION) == SDL_ENABLE) { SDL_Event event; event.type = SDL_CONTROLLERAXISMOTION; @@ -3078,7 +3136,7 @@ static int SDL_PrivateGameControllerAxis(SDL_GameController *gamecontroller, SDL static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button, Uint8 state) { int posted; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_Event event; SDL_AssertJoysticksLocked(); @@ -3120,7 +3178,7 @@ static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, S /* translate the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.cbutton.which = gamecontroller->joystick->instance_id; event.cbutton.button = button; @@ -3136,7 +3194,7 @@ static int SDL_PrivateGameControllerButton(SDL_GameController *gamecontroller, S */ int SDL_GameControllerEventState(int state) { -#if SDL_EVENTS_DISABLED +#ifdef SDL_EVENTS_DISABLED return SDL_IGNORE; #else const Uint32 event_list[] = { @@ -3201,10 +3259,11 @@ const char *SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController } SDL_UnlockJoysticks(); - return retval; -#else - return NULL; + if (retval && *retval) { + return retval; + } #endif + return NULL; } const char *SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis) @@ -3221,10 +3280,11 @@ const char *SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *g } SDL_UnlockJoysticks(); - return retval; -#else - return NULL; + if (retval && *retval) { + return retval; + } #endif + return NULL; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/joystick/SDL_gamecontrollerdb.h b/vs/sdl2/src/joystick/SDL_gamecontrollerdb.h index 97b4078179..22979210f1 100644 --- a/vs/sdl2/src/joystick/SDL_gamecontrollerdb.h +++ b/vs/sdl2/src/joystick/SDL_gamecontrollerdb.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +29,10 @@ Alternatively, you can use the app located in test/controllermap */ static const char *s_ControllerMappings[] = { -#if SDL_JOYSTICK_XINPUT - "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", +#ifdef SDL_JOYSTICK_XINPUT + "xinput,*,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", #endif -#if SDL_JOYSTICK_WGI +#ifdef SDL_JOYSTICK_WGI "03000000491900001904000000007700,Amazon Luna Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,misc1:b9,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b7,x:b2,y:b3,", "03000000d11800000094000000007700,Google Stadia 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:a5,leftx:a0,lefty:a1,misc1:b12,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,", "030000007e0500000920000000007701,Nintendo Switch Pro Controller,a:b1,b:b0,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:b3,y:b2,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -42,7 +42,7 @@ static const char *s_ControllerMappings[] = { "0300000032150000000a000000007703,Razer Atrox Arcade Stick,a:b0,b:b1,dpdown:b12,dpleft:b13,dpright:b11,dpup:b10,leftshoulder:b4,lefttrigger:b8,rightshoulder:b5,righttrigger:b9,x:b2,y:b3,", "03000000de280000ff11000000007701,Steam Virtual Gamepad,a:b0,b:b1,back:b6,dpdown:b12,dpleft:b13,dpright:b11,dpup:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a4,leftx:a1,lefty:a0~,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a2~,start:b7,x:b2,y:b3,", #endif -#if SDL_JOYSTICK_DINPUT +#ifdef SDL_JOYSTICK_DINPUT "03000000fa2d00000100000000000000,3DRUDDER,leftx:a0,lefty:a1,rightx:a5,righty:a2,", "03000000c82d00000090000000000000,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:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000c82d00000090000000000000,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:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -125,6 +125,7 @@ static const char *s_ControllerMappings[] = { "03000000260900008888000000000000,Cyber Gadget GameCube Controller,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b6,righttrigger:a4,rightx:a2,righty:a3~,start:b7,x:b2,y:b3,", "03000000a306000022f6000000000000,Cyborg V.3 Rumble Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:+a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000451300000830000000000000,Defender Game Racer X7,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,", + "03000000790000000600000000000000,Defender Joystick Cobra R4,crc:c77a,a:b2,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:b3,y:b0,", "03000000791d00000103000000000000,Dual Box WII,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,rightx:a2,righty:a3,start:b9,x:b3,y:b0,", "03000000bd12000002e0000000000000,Dual USB Vibration Joystick,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a3,righty:a2,start:b11,x:b3,y:b0,", "030000006f0e00003001000000000000,EA SPORTS PS3 Controller,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", @@ -134,9 +135,7 @@ static const char *s_ControllerMappings[] = { "03000000b80500000610000000000000,Elecom Gamepad,a:b2,b:b3,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:b0,y:b1,", "03000000852100000201000000000000,FF-GP1,a:b1,b:b2,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:b0,y:b3,", "030000000d0f00002700000000000000,FIGHTING STICK V3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,", - "03000000151900004000000000000000,Flydigi Vader 2,a:b27,b:b26,back:b19,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b23,leftstick:b17,lefttrigger:b21,leftx:a0,lefty:a1,misc1:b15,paddle1:b11,paddle2:b10,paddle3:b13,paddle4:b12,rightshoulder:b22,rightstick:b16,righttrigger:b20,rightx:a3,righty:a4,start:b18,x:b25,y:b24,", /* Bluetooth */ - "03000000b40400001124000000000000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b14,paddle1:b4,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b2,y:b3,", /* Dongle */ - "03000000b40400001224000000000000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b2,paddle1:b16,paddle2:b17,paddle3:b14,paddle4:b15,rightshoulder:b7,rightstick:b13,righttrigger:b9,rightx:a3,righty:a4,start:b11,x:b3,y:b4,", /* Wired */ + "03000000790000000600000000000000,G-Shark GS-GP702,crc:8e4f,a:b2,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:b3,y:b0,", "030000008f0e00000d31000000000000,GAMEPAD 3 TURBO,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000300f00000b01000000000000,GGE909 Recoil Pad,a:b2,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:a3,righty:a2,start:b9,x:b3,y:b0,", "03000000790000002201000000000000,Game Controller for PC,a:b2,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:b3,y:b0,", @@ -280,6 +279,7 @@ static const char *s_ControllerMappings[] = { "03000000050b00001c1a000000000000,ROG Chakram X,a:b1,b:b0,leftx:a0,lefty:a1,x:b2,y:b3,", "03000000050b0000e318000000000000,ROG Chakram,a:b1,b:b0,leftx:a0,lefty:a1,x:b2,y:b3,", "03000000050b0000e518000000000000,ROG Chakram,a:b1,b:b0,leftx:a0,lefty:a1,x:b2,y:b3,", + "030000000d0f0000ad00000000000000,RX Gamepad,a:b0,b:b4,back:b11,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b3,rightshoulder:b6,start:b9,x:b2,y:b1,", "03000000321500000003000000000000,Razer Hydra,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a2,rightx:a3,righty:a4,start:b7,x:b2,y:b3,", "03000000321500000204000000000000,Razer Panthera (PS3),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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000321500000104000000000000,Razer Panthera (PS4),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,", @@ -304,6 +304,7 @@ static const char *s_ControllerMappings[] = { "030000006f0e00002f01000000000000,Rock Candy PS3 Controller,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000341a00000208000000000000,SL-6555-SBK,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b8,lefttrigger:-a4,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a4,rightx:a3,righty:a2,start:b7,x:b2,y:b3,", "03000000341a00000908000000000000,SL-6566,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,", + "03000000790000000600000000000000,SPEEDLINK STRIKE Gamepad,crc:5811,a:b2,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:a4,start:b9,x:b3,y:b0,", "03000000790000001c18000000000000,STK-7024X,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:a3,righty:a4,start:b11,x:b3,y:b4,", "03000000ff1100003133000000000000,SVEN X-PAD,a:b2,b:b3,back:b4,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b9,rightx:a2,righty:a4,start:b5,x:b0,y:b1,", "03000000457500002211000000000000,SZMY-POWER PC Gamepad,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", @@ -318,6 +319,7 @@ static const char *s_ControllerMappings[] = { "03000000a30600002106000000000000,Saitek PS1000,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000a306000020f6000000000000,Saitek PS2700,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "03000000300f00001101000000000000,Saitek Rumble Pad,a:b2,b:b3,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,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,", + "03000000790000000600000000000000,Sanwa Supply JY-P76USV,crc:20f0,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,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a4,start:b9,x:b2,y:b3,", "0300000000050000289b000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,", "030000009b2800000500000000000000,Saturn_Adapter_2.0,a:b1,b:b2,leftshoulder:b6,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b5,start:b9,x:b0,y:b3,", "030000008f0e00000800000000000000,SpeedLink Strike FX,a:b2,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:b3,y:b0,", @@ -416,9 +418,6 @@ static const char *s_ControllerMappings[] = { "03000000a306000022f6000001030000,Cyborg V.3 Rumble Pad,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:-a3,rightx:a2,righty:a4,start:b9,x:b0,y:b3,", "030000000d0f00008400000000010000,Fighting Commander,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,", "030000000d0f00008500000000010000,Fighting Commander,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", - "03000000151900004000000001000000,Flydigi Vader 2,a:b14,b:b15,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b0,y:b1,", /* Bluetooth */ - "03000000b40400001124000001040000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b14,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Dongle */ - "03000000b40400001224000003030000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b2,paddle1:b16,paddle2:b17,paddle3:b14,paddle4:b15,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Wired */ "03000000ac0500001a06000002020000,GameSir-T3 2.02,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,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,", "0500000047532047616d657061640000,GameStop Gamepad,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,", "03000000c01100000140000000010000,GameStop PS4 Fun Controller,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,", @@ -598,6 +597,7 @@ static const char *s_ControllerMappings[] = { "05000000503200000110000000000000,Atari Classic Controller,a:b0,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b4,start:b3,x:b1,", "03000000503200000210000000000000,Atari Game Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b6,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a4,rightx:a2,righty:a3,start:b8,x:b2,y:b3,", "05000000503200000210000000000000,Atari Game 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:b3,y:b2,", + "05000000503200000210000000000000128804098,Atari Game 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:b3,y:b2,", "030000005e0400008e02000047010000,Atari Xbox 360 Game 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,", "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,", @@ -610,9 +610,6 @@ static const char *s_ControllerMappings[] = { "050000004c050000f20d000000010000,DualSense Edge Wireless Controller,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,", "030000006f0e00003001000001010000,EA Sports PS3 Controller,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000790000001100000010010000,Elecom Gamepad,crc:e86c,a:b2,b:b3,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b0,y:b1,", - "03000000b40400001124000011010000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b14,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Dongle */ - "03000000b40400001224000011010000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b2,paddle1:b16,paddle2:b17,paddle3:b14,paddle4:b15,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Wired */ - "05000000151900004000000001000000,Flydigi Vader 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b21,leftshoulder:b6,leftstick:b12,lefttrigger:a5,leftx:a0,lefty:a1,misc1:b14,paddle1:b2,paddle2:b5,paddle3:b16,paddle4:b17,rightshoulder:b7,rightstick:b13,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,", /* Bluetooth */ "0300000079000000d418000000010000,GPD Win 2 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,", "0500000047532067616d657061640000,GS Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,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,", "03000000341a000005f7000010010000,GameCube {HuiJia USB box},a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,", @@ -706,7 +703,6 @@ static const char *s_ControllerMappings[] = { "03000000451300000830000010010000,NYKO CORE,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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000790000004318000010010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000790000004318000010010000,Nintendo GameCube Controller,a:b1,b:b0,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b2,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", - "030000007e0500003703000000016800,Nintendo GameCube Controller,a:b0,b:b2,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:b1,y:b3,", "050000007e0500000620000001800000,Nintendo Switch Joy-Con (L),a:b15,b:b16,guide:b4,leftshoulder:b6,leftstick:b12,leftx:a1,lefty:a0~,rightshoulder:b8,start:b9,x:b17,y:b14,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "050000007e0500000620000001800000,Nintendo Switch Joy-Con (L),a:b16,b:b15,guide:b4,leftshoulder:b6,leftstick:b12,leftx:a1,lefty:a0~,rightshoulder:b8,start:b9,x:b14,y:b17,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "060000007e0500000620000000000000,Nintendo Switch Joy-Con (L/R),a:b1,b:b0,back:b9,dpdown:b15,dpleft:b16,dpright:b17,dpup:b14,leftshoulder:b5,leftstick:b12,lefttrigger:b7,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b13,righttrigger:b8,rightx:a2,righty:a3,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", @@ -776,6 +772,8 @@ static const char *s_ControllerMappings[] = { "03000000300f00001211000011010000,QanBa Arcade JoyStick,a:b2,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b5,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:b6,start:b9,x:b1,y:b3,", "03000000222c00000225000011010000,Qanba Dragon Arcade Joystick (PS3),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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000025000011010000,Qanba Dragon Arcade Joystick (PS4),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,", + "03000000222c00001020000011010000,Qanba Drone 2 Arcade Joystick (PS5),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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", + "03000000222c00001220000011010000,Qanba Drone 2 Arcade Joystick (PS4),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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,", "03000000222c00000020000011010000,Qanba Drone Arcade Joystick (PS4),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,rightshoulder:b5,righttrigger:a4,start:b9,x:b0,y:b3,", "03000000222c00000223000011010000,Qanba Obsidian Arcade Joystick (PS3),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:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", "03000000222c00000023000011010000,Qanba Obsidian Arcade Joystick (PS4),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,", @@ -825,6 +823,7 @@ static const char *s_ControllerMappings[] = { "05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "05000000de2800000611000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,paddle1:b11,paddle2:b10,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,", "03000000de2800000512000011010000,Steam Deck,a:b3,b:b4,back:b11,dpdown:b17,dpleft:b18,dpright:b19,dpup:b16,guide:b13,leftshoulder:b7,leftstick:b14,lefttrigger:a9,leftx:a0,lefty:a1,misc1:b2,paddle1:b21,paddle2:b20,paddle3:b23,paddle4:b22,rightshoulder:b8,rightstick:b15,righttrigger:a8,rightx:a2,righty:a3,start:b12,x:b5,y:b6,", + "03000000de2800000512000000016800,Steam Deck,a:b0,b:b1,x:b2,y:b3,back:b4,guide:b5,start:b6,leftstick:b7,rightstick:b8,leftshoulder:b9,rightshoulder:b10,dpup:b11,dpdown:b12,dpleft:b13,dpright:b14,misc1:b15,paddle1:b16,paddle2:b17,paddle3:b18,paddle4:b19,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", "03000000de280000ff11000001000000,Steam Virtual Gamepad,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,", "0500000011010000311400001b010000,SteelSeries Stratus Duo,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b32,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,", "05000000110100001914000009010000,SteelSeries Stratus XL,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b18,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,", @@ -864,7 +863,6 @@ static const char *s_ControllerMappings[] = { "03000000120c0000100e000011010000,ZEROPLUS P4 Gamepad,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,", "03000000120c0000101e000011010000,ZEROPLUS P4 Wired Gamepad,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,", "03000000666600006706000000010000,boom PSX to PC Converter,a:b2,b:b1,back:b8,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b10,righttrigger:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,", - "030000000d0f00000d00000000010000,hori,a:b0,b:b6,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftx:b4,lefty:b5,rightshoulder:b7,start:b9,x:b1,y:b2,", "03000000830500006020000010010000,iBuffalo SNES Controller,a:b0,b:b1,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "03000000830500006020000010010000,iBuffalo SNES Controller,a:b1,b:b0,back:b6,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b5,start:b7,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "050000006964726f69643a636f6e0000,idroid:con,a:b1,b:b2,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:b0,y:b3,", @@ -910,7 +908,6 @@ static const char *s_ControllerMappings[] = { "05000000c82d000018900000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b0,b:b1,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "05000000c82d000030320000ffff0f00,8BitDo Zero 2,a:b1,b:b0,back:b4,leftshoulder:b9,leftx:a0,lefty:a1,rightshoulder:b10,start:b6,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", - "05000000b404000011240000dfff3f00,Flydigi Vader 2,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a4,leftx:a0,lefty:a1,paddle1:b17,paddle2:b18,rightshoulder:b10,rightstick:b8,righttrigger:a5,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "05000000d6020000e5890000dfff3f80,GPD XD Plus,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a3,rightx:a4,righty:a5,start:b6,x:b2,y:b3,", "0500000031366332860c44aadfff0f00,GS Gamepad,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:b15,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:b16,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", "05000000bc20000000550000ffff3f00,GameSir G3w,a:b0,b:b1,back:b4,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b9,leftstick:b7,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b10,rightstick:b8,righttrigger:a4,rightx:a2,righty:a3,start:b6,x:b2,y:b3,", @@ -922,7 +919,6 @@ 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,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", /* Extremely slow in Bluetooth mode on Android */ "050000007e05000009200000ffff0f00,Nintendo Switch Pro Controller,a:b1,b:b0,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:b2,y:b17,sdk<=:28,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", /* 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,", "050000004c050000c4050000fffe3f80,PS4 Controller,a:b1,b:b17,back:b15,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b5,leftshoulder:b3,leftstick:b4,lefttrigger:+a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b6,righttrigger:+a3,rightx:a4,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,", @@ -950,7 +946,7 @@ static const char *s_ControllerMappings[] = { "0500000083050000602000000ffe0000,iBuffalo SNES Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b15,rightshoulder:b16,start:b10,x:b2,y:b3,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", "0500000083050000602000000ffe0000,iBuffalo SNES Controller,a:b1,b:b0,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b15,rightshoulder:b16,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,", #endif -#if SDL_JOYSTICK_MFI +#ifdef SDL_JOYSTICK_MFI "05000000ac050000010000004f066d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,", "05000000ac05000001000000cf076d01,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,x:b2,y:b3,", "05000000ac05000001000000df076d01,*,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,", @@ -986,19 +982,19 @@ static const char *s_ControllerMappings[] = { "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,", #endif -#if SDL_JOYSTICK_EMSCRIPTEN +#ifdef 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 SDL_JOYSTICK_PS2 +#ifdef SDL_JOYSTICK_PS2 "0000000050533220436f6e74726f6c00,PS2 Controller,crc:ed87,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,", #endif -#if SDL_JOYSTICK_PSP +#ifdef SDL_JOYSTICK_PSP "00000000505350206275696c74696e00,PSP builtin joypad,crc:bb86,a:b2,b:b1,back:b10,dpdown:b6,dpleft:b7,dpright:b9,dpup:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,rightx:a2,righty:a3,start:b11,x:b3,y:b0,", #endif -#if SDL_JOYSTICK_VITA +#ifdef SDL_JOYSTICK_VITA "0000000050535669746120436f6e7400,PSVita Controller,crc:d598,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 -#if SDL_JOYSTICK_N3DS +#ifdef SDL_JOYSTICK_N3DS "000000004e696e74656e646f20334400,Nintendo 3DS,crc:3210,a:b0,b:b1,back:b2,dpdown:b7,dpleft:b5,dpright:b4,dpup:b6,leftshoulder:b9,lefttrigger:b14,leftx:a0,lefty:a1,rightshoulder:b8,righttrigger:b15,rightx:a2,righty:a3,start:b3,x:b10,y:b11,", #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,", diff --git a/vs/sdl2/src/joystick/SDL_joystick.c b/vs/sdl2/src/joystick/SDL_joystick.c index 3818cab963..05c9807c26 100644 --- a/vs/sdl2/src/joystick/SDL_joystick.c +++ b/vs/sdl2/src/joystick/SDL_joystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +28,9 @@ #include "SDL_sysjoystick.h" #include "SDL_hints.h" #include "../SDL_hints_c.h" +#include "SDL_steam_virtual_gamepad.h" -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif #include "../video/SDL_sysvideo.h" @@ -46,7 +47,7 @@ #include #endif -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL #include "./virtual/SDL_virtualjoystick_c.h" #endif @@ -125,6 +126,299 @@ static SDL_JoystickID *SDL_joystick_players SDL_GUARDED_BY(SDL_joystick_lock) = static SDL_bool SDL_joystick_allows_background_events = SDL_FALSE; char SDL_joystick_magic; +static Uint32 initial_arcadestick_devices[] = { + MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */ + MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */ + MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */ + MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */ + MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */ + MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */ + MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */ + MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */ + MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */ + MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */ + MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */ + MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */ + MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */ + MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */ + MAKE_VIDPID(0x146b, 0x0604), /* NACON Daija Arcade Stick */ + MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */ + MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */ + MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */ + MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */ + MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */ + MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */ + MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */ + MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */ + MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */ + MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */ + MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */ + MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */ + MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */ + MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */ + MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */ +}; +static SDL_vidpid_list arcadestick_devices = { + SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_ARCADESTICK_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_arcadestick_devices), initial_arcadestick_devices, + SDL_FALSE +}; + +/* This list is taken from: + https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py + */ +static Uint32 initial_blacklist_devices[] = { + /* Microsoft Microsoft Wireless Optical Desktop 2.10 */ + /* Microsoft Wireless Desktop - Comfort Edition */ + MAKE_VIDPID(0x045e, 0x009d), + + /* Microsoft Microsoft Digital Media Pro Keyboard */ + /* Microsoft Corp. Digital Media Pro Keyboard */ + MAKE_VIDPID(0x045e, 0x00b0), + + /* Microsoft Microsoft Digital Media Keyboard */ + /* Microsoft Corp. Digital Media Keyboard 1.0A */ + MAKE_VIDPID(0x045e, 0x00b4), + + /* Microsoft Microsoft Digital Media Keyboard 3000 */ + MAKE_VIDPID(0x045e, 0x0730), + + /* Microsoft Microsoft 2.4GHz Transceiver v6.0 */ + /* Microsoft Microsoft 2.4GHz Transceiver v8.0 */ + /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */ + /* Microsoft Wireless Mobile Mouse 1000 */ + /* Microsoft Wireless Desktop 3000 */ + MAKE_VIDPID(0x045e, 0x0745), + + /* Microsoft SideWinder(TM) 2.4GHz Transceiver */ + MAKE_VIDPID(0x045e, 0x0748), + + /* Microsoft Corp. Wired Keyboard 600 */ + MAKE_VIDPID(0x045e, 0x0750), + + /* Microsoft Corp. Sidewinder X4 keyboard */ + MAKE_VIDPID(0x045e, 0x0768), + + /* Microsoft Corp. Arc Touch Mouse Transceiver */ + MAKE_VIDPID(0x045e, 0x0773), + + /* Microsoft 2.4GHz Transceiver v9.0 */ + /* Microsoft Nano Transceiver v2.1 */ + /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */ + MAKE_VIDPID(0x045e, 0x07a5), + + /* Microsoft Nano Transceiver v1.0 */ + /* Microsoft Wireless Keyboard 800 */ + MAKE_VIDPID(0x045e, 0x07b2), + + /* Microsoft Nano Transceiver v2.0 */ + MAKE_VIDPID(0x045e, 0x0800), + + MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */ + + MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */ + + /* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */ + MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */ + MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */ + MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */ + MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */ + MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */ + MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */ + MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */ + MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */ + MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */ + MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */ + MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */ + MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */ + + MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */ + MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */ + MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */ + MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */ + MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */ + MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */ + MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */ + MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */ + MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */ + MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */ + MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */ + MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */ + MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */ + MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */ + MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */ + MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */ + + MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */ + + MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */ + + MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */ + + MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */ + + MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */ + MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */ + + /*****************************************************************/ + /* Additional entries */ + /*****************************************************************/ + + MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */ + MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntsman V2 Analog, non-functional DInput device */ + MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntsman Mini Analog, non-functional DInput device */ + MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */ + MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */ +}; +static SDL_vidpid_list blacklist_devices = { + SDL_HINT_JOYSTICK_BLACKLIST_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_BLACKLIST_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_blacklist_devices), initial_blacklist_devices, + SDL_FALSE +}; + +static Uint32 initial_flightstick_devices[] = { + MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */ + MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */ + MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */ + MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */ + MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */ + MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */ + MAKE_VIDPID(0x362c, 0x0001), /* Yawman Arrow */ +}; +static SDL_vidpid_list flightstick_devices = { + SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_FLIGHTSTICK_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_flightstick_devices), initial_flightstick_devices, + SDL_FALSE +}; + +static Uint32 initial_gamecube_devices[] = { + MAKE_VIDPID(0x0e6f, 0x0185), /* PDP Wired Fight Pad Pro for Nintendo Switch */ + MAKE_VIDPID(0x20d6, 0xa711), /* PowerA Wired Controller Nintendo GameCube Style */ +}; +static SDL_vidpid_list gamecube_devices = { + SDL_HINT_JOYSTICK_GAMECUBE_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_GAMECUBE_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_gamecube_devices), initial_gamecube_devices, + SDL_FALSE +}; + +static Uint32 initial_rog_gamepad_mice[] = { + MAKE_VIDPID(0x0b05, 0x1906), /* ROG Pugio II */ + MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */ + MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */ + MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */ + MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */ +}; +static SDL_vidpid_list rog_gamepad_mice = { + SDL_HINT_ROG_GAMEPAD_MICE, 0, 0, NULL, + SDL_HINT_ROG_GAMEPAD_MICE_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_rog_gamepad_mice), initial_rog_gamepad_mice, + SDL_FALSE +}; + +static Uint32 initial_throttle_devices[] = { + MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */ + MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */ +}; +static SDL_vidpid_list throttle_devices = { + SDL_HINT_JOYSTICK_THROTTLE_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_THROTTLE_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_throttle_devices), initial_throttle_devices, + SDL_FALSE +}; + +static Uint32 initial_wheel_devices[] = { + MAKE_VIDPID(0x0079, 0x1864), /* DragonRise Inc. Wired Wheel (active mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ + MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */ + MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */ + MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */ + 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 (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(0x046d, 0xc268), /* Logitech PRO Racing Wheel (PC mode) */ + MAKE_VIDPID(0x046d, 0xc269), /* Logitech PRO Racing Wheel (PS4/PS5 mode) */ + MAKE_VIDPID(0x046d, 0xc272), /* Logitech PRO Racing Wheel for Xbox (PC mode) */ + MAKE_VIDPID(0x046d, 0xc26d), /* Logitech G923 (Xbox) */ + MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */ + MAKE_VIDPID(0x046d, 0xc266), /* Logitech G923 for Playstation 4 and PC (PC mode) */ + MAKE_VIDPID(0x046d, 0xc267), /* Logitech G923 for Playstation 4 and PC (PS4 mode)*/ + MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */ + MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ + MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */ + MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */ + MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */ + MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */ + MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */ + MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */ + MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */ + MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ + MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ + MAKE_VIDPID(0x044f, 0xb691), /* Thrustmaster TS-XW (initial mode) */ + MAKE_VIDPID(0x044f, 0xb692), /* Thrustmaster TS-XW (active mode) */ + MAKE_VIDPID(0x0483, 0x0522), /* Simagic Wheelbase (including M10, Alpha Mini, Alpha, Alpha U) */ + MAKE_VIDPID(0x0483, 0xa355), /* VRS DirectForce Pro Wheel Base */ + MAKE_VIDPID(0x0eb7, 0x0001), /* Fanatec ClubSport Wheel Base V2 */ + MAKE_VIDPID(0x0eb7, 0x0004), /* Fanatec ClubSport Wheel Base V2.5 */ + MAKE_VIDPID(0x0eb7, 0x0005), /* Fanatec CSL Elite Wheel Base+ (PS4) */ + MAKE_VIDPID(0x0eb7, 0x0006), /* Fanatec Podium Wheel Base DD1 */ + MAKE_VIDPID(0x0eb7, 0x0007), /* Fanatec Podium Wheel Base DD2 */ + MAKE_VIDPID(0x0eb7, 0x0011), /* Fanatec Forza Motorsport (CSR Wheel / CSR Elite Wheel) */ + MAKE_VIDPID(0x0eb7, 0x0020), /* Fanatec generic wheel / CSL DD / GT DD Pro */ + MAKE_VIDPID(0x0eb7, 0x0197), /* Fanatec Porsche Wheel (Turbo / GT3 RS / Turbo S / GT3 V2 / GT2) */ + MAKE_VIDPID(0x0eb7, 0x038e), /* Fanatec ClubSport Wheel Base V1 */ + MAKE_VIDPID(0x0eb7, 0x0e03), /* Fanatec CSL Elite Wheel Base */ + MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ + MAKE_VIDPID(0x1209, 0xffb0), /* Generic FFBoard OpenFFBoard universal forcefeedback wheel */ + MAKE_VIDPID(0x16d0, 0x0d5a), /* Simucube 1 Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d5f), /* Simucube 2 Ultimate Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d60), /* Simucube 2 Pro Wheelbase */ + MAKE_VIDPID(0x16d0, 0x0d61), /* Simucube 2 Sport Wheelbase */ + MAKE_VIDPID(0x2433, 0xf300), /* Asetek SimSports Invicta Wheelbase */ + MAKE_VIDPID(0x2433, 0xf301), /* Asetek SimSports Forte Wheelbase */ + MAKE_VIDPID(0x2433, 0xf303), /* Asetek SimSports La Prima Wheelbase */ + MAKE_VIDPID(0x2433, 0xf306), /* Asetek SimSports Tony Kannan Wheelbase */ + MAKE_VIDPID(0x3416, 0x0301), /* Cammus C5 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0000), /* Moza R16/R21 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0002), /* Moza R9 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0004), /* Moza R5 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0005), /* Moza R3 Wheelbase */ + MAKE_VIDPID(0x346e, 0x0006), /* Moza R12 Wheelbase */ +}; +static SDL_vidpid_list wheel_devices = { + SDL_HINT_JOYSTICK_WHEEL_DEVICES, 0, 0, NULL, + SDL_HINT_JOYSTICK_WHEEL_DEVICES_EXCLUDED, 0, 0, NULL, + SDL_arraysize(initial_wheel_devices), initial_wheel_devices, + SDL_FALSE +}; + +static Uint32 initial_zero_centered_devices[] = { + MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */ + MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */ +}; +static SDL_vidpid_list zero_centered_devices = { + SDL_HINT_JOYSTICK_ZERO_CENTERED_DEVICES, 0, 0, NULL, + NULL, 0, 0, NULL, + SDL_arraysize(initial_zero_centered_devices), initial_zero_centered_devices, + SDL_FALSE +}; + #define CHECK_JOYSTICK_MAGIC(joystick, retval) \ if (!joystick || joystick->magic != &SDL_joystick_magic) { \ SDL_InvalidParamError("joystick"); \ @@ -213,7 +507,7 @@ static SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, SDL_JoystickDriv return SDL_FALSE; } -static int SDL_FindFreePlayerIndex() +static int SDL_FindFreePlayerIndex(void) { int player_index; @@ -265,7 +559,7 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID 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 == NULL) { + if (!new_players) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -319,7 +613,7 @@ int SDL_JoystickInit(void) SDL_joystick_lock = SDL_CreateMutex(); } -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { return -1; } @@ -331,10 +625,21 @@ int SDL_JoystickInit(void) SDL_GameControllerInitMappings(); + SDL_LoadVIDPIDList(&arcadestick_devices); + SDL_LoadVIDPIDList(&blacklist_devices); + SDL_LoadVIDPIDList(&flightstick_devices); + SDL_LoadVIDPIDList(&gamecube_devices); + SDL_LoadVIDPIDList(&rog_gamepad_mice); + SDL_LoadVIDPIDList(&throttle_devices); + SDL_LoadVIDPIDList(&wheel_devices); + SDL_LoadVIDPIDList(&zero_centered_devices); + /* See if we should allow joystick events while in the background */ SDL_AddHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); + SDL_InitSteamVirtualGamepadInfo(); + status = -1; for (i = 0; i < SDL_arraysize(SDL_joystick_drivers); ++i) { if (SDL_joystick_drivers[i]->Init() >= 0) { @@ -368,11 +673,24 @@ int SDL_NumJoysticks(void) * Return the next available joystick instance ID * This may be called by drivers from multiple threads, unprotected by any locks */ -SDL_JoystickID SDL_GetNextJoystickInstanceID() +SDL_JoystickID SDL_GetNextJoystickInstanceID(void) { return SDL_AtomicIncRef(&SDL_next_joystick_instance_id); } +const SDL_SteamVirtualGamepadInfo *SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickID instance_id) +{ + SDL_JoystickDriver *driver; + int device_index; + const SDL_SteamVirtualGamepadInfo *info = NULL; + + if (SDL_SteamVirtualGamepadEnabled() && + SDL_GetDriverAndJoystickIndex(SDL_JoystickGetDeviceIndexFromInstanceID(instance_id), &driver, &device_index)) { + info = SDL_GetSteamVirtualGamepadInfo(driver->GetDeviceSteamVirtualGamepadSlot(device_index)); + } + return info; +} + /* * Get the implementation dependent name of a joystick */ @@ -380,9 +698,13 @@ const char *SDL_JoystickNameForIndex(int device_index) { SDL_JoystickDriver *driver; const char *name = NULL; + const SDL_SteamVirtualGamepadInfo *info; SDL_LockJoysticks(); - if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { + info = SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickGetDeviceInstanceID(device_index)); + if (info) { + name = info->name; + } else if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &device_index)) { name = driver->GetDeviceName(device_index); } SDL_UnlockJoysticks(); @@ -406,7 +728,7 @@ const char *SDL_JoystickPathForIndex(int device_index) SDL_UnlockJoysticks(); /* FIXME: Really we should reference count this path so it doesn't go away after unlock */ - if (path == NULL) { + if (!path) { SDL_Unsupported(); } return path; @@ -436,35 +758,14 @@ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick) #ifdef __WINRT__ return SDL_TRUE; #else - static Uint32 zero_centered_joysticks[] = { - MAKE_VIDPID(0x0e8f, 0x3013), /* HuiJia SNES USB adapter */ - MAKE_VIDPID(0x05a0, 0x3232), /* 8Bitdo Zero Gamepad */ - }; - - SDL_bool retval = SDL_FALSE; - int i; - 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);*/ - SDL_LockJoysticks(); - { - if (joystick->naxes == 2) { - /* Assume D-pad or thumbstick style axes are centered at 0 */ - retval = SDL_TRUE; - } - - for (i = 0; i < SDL_arraysize(zero_centered_joysticks); ++i) { - if (id == zero_centered_joysticks[i]) { - retval = SDL_TRUE; - break; - } - } + if (joystick->naxes == 2) { + /* Assume D-pad or thumbstick style axes are centered at 0 */ + return SDL_TRUE; } - SDL_UnlockJoysticks(); - return retval; + return SDL_VIDPIDInList(SDL_JoystickGetVendor(joystick), SDL_JoystickGetProduct(joystick), &zero_centered_devices); #endif /* __WINRT__ */ } @@ -484,6 +785,7 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) const char *joystickname = NULL; const char *joystickpath = NULL; SDL_JoystickPowerLevel initial_power_level; + const SDL_SteamVirtualGamepadInfo *info; SDL_LockJoysticks(); @@ -509,7 +811,7 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) /* Create and initialize the joystick */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -573,6 +875,12 @@ SDL_Joystick *SDL_JoystickOpen(int device_index) joystick->is_game_controller = SDL_IsGameController(device_index); + /* Get the Steam Input API handle */ + info = SDL_GetJoystickInstanceVirtualGamepadInfo(instance_id); + if (info) { + joystick->steam_handle = info->handle; + } + /* Add joystick to list */ ++joystick->ref_count; /* Link the joystick in the list */ @@ -606,7 +914,7 @@ int SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nbuttons, in int SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc) { -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL int retval; SDL_LockJoysticks(); @@ -620,7 +928,7 @@ int SDL_JoystickAttachVirtualEx(const SDL_VirtualJoystickDesc *desc) int SDL_JoystickDetachVirtual(int device_index) { -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL SDL_JoystickDriver *driver; SDL_LockJoysticks(); @@ -641,7 +949,7 @@ int SDL_JoystickDetachVirtual(int device_index) SDL_bool SDL_JoystickIsVirtual(int device_index) { -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL SDL_JoystickDriver *driver; int driver_device_index; SDL_bool is_virtual = SDL_FALSE; @@ -668,7 +976,7 @@ int SDL_JoystickSetVirtualAxis(SDL_Joystick *joystick, int axis, Sint16 value) { CHECK_JOYSTICK_MAGIC(joystick, -1); -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL retval = SDL_JoystickSetVirtualAxisInner(joystick, axis, value); #else retval = SDL_SetError("SDL not built with virtual-joystick support"); @@ -687,7 +995,7 @@ int SDL_JoystickSetVirtualButton(SDL_Joystick *joystick, int button, Uint8 value { CHECK_JOYSTICK_MAGIC(joystick, -1); -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL retval = SDL_JoystickSetVirtualButtonInner(joystick, button, value); #else retval = SDL_SetError("SDL not built with virtual-joystick support"); @@ -706,7 +1014,7 @@ int SDL_JoystickSetVirtualHat(SDL_Joystick *joystick, int hat, Uint8 value) { CHECK_JOYSTICK_MAGIC(joystick, -1); -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL retval = SDL_JoystickSetVirtualHatInner(joystick, hat, value); #else retval = SDL_SetError("SDL not built with virtual-joystick support"); @@ -1016,15 +1324,22 @@ SDL_Joystick *SDL_JoystickFromPlayerIndex(int player_index) const char *SDL_JoystickName(SDL_Joystick *joystick) { const char *retval; + const SDL_SteamVirtualGamepadInfo *info; SDL_LockJoysticks(); { CHECK_JOYSTICK_MAGIC(joystick, NULL); - retval = joystick->name; + info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id); + if (info) { + retval = info->name; + } else { + retval = joystick->name; + } } SDL_UnlockJoysticks(); + /* FIXME: Really we should reference count this name so it doesn't go away after unlock */ return retval; } @@ -1339,13 +1654,24 @@ void SDL_JoystickQuit(void) SDL_joystick_player_count = 0; } -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_QuitSubSystem(SDL_INIT_EVENTS); #endif + SDL_QuitSteamVirtualGamepadInfo(); + SDL_DelHintCallback(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_JoystickAllowBackgroundEventsChanged, NULL); + SDL_FreeVIDPIDList(&arcadestick_devices); + SDL_FreeVIDPIDList(&blacklist_devices); + SDL_FreeVIDPIDList(&flightstick_devices); + SDL_FreeVIDPIDList(&gamecube_devices); + SDL_FreeVIDPIDList(&rog_gamepad_mice); + SDL_FreeVIDPIDList(&throttle_devices); + SDL_FreeVIDPIDList(&wheel_devices); + SDL_FreeVIDPIDList(&zero_centered_devices); + SDL_GameControllerQuitMappings(); SDL_joysticks_quitting = SDL_FALSE; @@ -1354,7 +1680,7 @@ void SDL_JoystickQuit(void) SDL_UnlockJoysticks(); } -static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent() +static SDL_bool SDL_PrivateJoystickShouldIgnoreEvent(void) { if (SDL_joystick_allows_background_events) { return SDL_FALSE; @@ -1434,7 +1760,10 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance) } if (SDL_GetDriverAndJoystickIndex(device_index, &driver, &driver_device_index)) { - player_index = driver->GetDevicePlayerIndex(driver_device_index); + player_index = driver->GetDeviceSteamVirtualGamepadSlot(driver_device_index); + if (player_index < 0) { + player_index = driver->GetDevicePlayerIndex(driver_device_index); + } } if (player_index < 0 && SDL_IsGameController(device_index)) { player_index = SDL_FindFreePlayerIndex(); @@ -1443,7 +1772,7 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance) SDL_SetJoystickIDForPlayerIndex(player_index, device_instance); } -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED { SDL_Event event; @@ -1457,6 +1786,7 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance) #endif /* !SDL_EVENTS_DISABLED */ } +#ifndef SDL_EVENTS_DISABLED /* * If there is an existing add event in the queue, it needs to be modified * to have the right value for which, because the number of controllers in @@ -1474,7 +1804,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type) } events = SDL_small_alloc(SDL_Event, num_events, &isstack); - if (events == NULL) { + if (!events) { return; } @@ -1516,6 +1846,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type) SDL_small_free(events, isstack); } +#endif void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick) { @@ -1552,7 +1883,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance) SDL_Joystick *joystick = NULL; int player_index; int device_index; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_Event event; #endif @@ -1570,7 +1901,7 @@ void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance) ++device_index; } -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_zero(event); event.type = SDL_JOYDEVICEREMOVED; @@ -1642,7 +1973,7 @@ int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value) /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) { SDL_Event event; event.type = SDL_JOYAXISMOTION; @@ -1683,7 +2014,7 @@ int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value) /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) { SDL_Event event; event.jhat.type = SDL_JOYHATMOTION; @@ -1718,7 +2049,7 @@ int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sin /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYBALLMOTION) == SDL_ENABLE) { SDL_Event event; event.jball.type = SDL_JOYBALLMOTION; @@ -1735,7 +2066,7 @@ int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sin int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) { int posted; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_Event event; SDL_AssertJoysticksLocked(); @@ -1776,7 +2107,7 @@ int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(event.type) == SDL_ENABLE) { event.jbutton.which = joystick->instance_id; event.jbutton.button = button; @@ -1787,6 +2118,43 @@ int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state) return posted; } +static void SendSteamHandleUpdateEvents(void) +{ + SDL_Joystick *joystick; + const SDL_SteamVirtualGamepadInfo *info; + + /* Check to see if any Steam handles changed */ + for (joystick = SDL_joysticks; joystick; joystick = joystick->next) { + SDL_bool changed = SDL_FALSE; + + if (!joystick->is_game_controller) { + continue; + } + + info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id); + if (info) { + if (joystick->steam_handle != info->handle) { + joystick->steam_handle = info->handle; + changed = SDL_TRUE; + } + } else { + if (joystick->steam_handle != 0) { + joystick->steam_handle = 0; + changed = SDL_TRUE; + } + } + if (changed) { + SDL_Event event; + + SDL_zero(event); + event.type = SDL_CONTROLLERSTEAMHANDLEUPDATED; + event.common.timestamp = 0; + event.cdevice.which = joystick->instance_id; + SDL_PushEvent(&event); + } + } +} + void SDL_JoystickUpdate(void) { int i; @@ -1799,6 +2167,10 @@ void SDL_JoystickUpdate(void) SDL_LockJoysticks(); + if (SDL_UpdateSteamVirtualGamepadInfo()) { + SendSteamHandleUpdateEvents(); + } + #ifdef SDL_JOYSTICK_HIDAPI /* Special function for HIDAPI devices, as a single device can provide multiple SDL_Joysticks */ HIDAPI_UpdateDevices(); @@ -1847,7 +2219,7 @@ void SDL_JoystickUpdate(void) int SDL_JoystickEventState(int state) { -#if SDL_EVENTS_DISABLED +#ifdef SDL_EVENTS_DISABLED return SDL_DISABLE; #else const Uint32 event_list[] = { @@ -1962,11 +2334,13 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n } replacements[] = { { "ASTRO Gaming", "ASTRO" }, { "Bensussen Deutsch & Associates,Inc.(BDA)", "BDA" }, - { "NVIDIA Corporation ", "" }, - { "Performance Designed Products", "PDP" }, - { "HORI CO.,LTD.", "HORI" }, + { "Guangzhou Chicken Run Network Technology Co., Ltd.", "GameSir" }, { "HORI CO.,LTD", "HORI" }, + { "HORI CO.,LTD.", "HORI" }, { "Mad Catz Inc.", "Mad Catz" }, + { "Nintendo Co., Ltd.", "Nintendo" }, + { "NVIDIA Corporation ", "" }, + { "Performance Designed Products", "PDP" }, { "QANBA USA, LLC", "Qanba" }, { "QANBA USA,LLC", "Qanba" }, { "Unknown ", "" }, @@ -1980,10 +2354,10 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n return SDL_strdup(custom_name); } - if (vendor_name == NULL) { + if (!vendor_name) { vendor_name = ""; } - if (product_name == NULL) { + if (!product_name) { product_name = ""; } @@ -2026,7 +2400,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n default: len = (6 + 1 + 6 + 1); name = (char *)SDL_malloc(len); - if (name != NULL) { + if (name) { (void)SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product); } break; @@ -2035,7 +2409,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n name = SDL_strdup("Controller"); } - if (name == NULL) { + if (!name) { return NULL; } @@ -2077,7 +2451,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n for (i = 1; i < (len - 1); ++i) { int matchlen = PrefixMatch(name, &name[i]); while (matchlen > 0) { - if (name[matchlen] == ' ') { + if (name[matchlen] == ' ' || name[matchlen] == '-') { SDL_memmove(name, name + matchlen + 1, len - matchlen); break; } @@ -2092,21 +2466,26 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n return name; } -SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *name, Uint8 driver_signature, Uint8 driver_data) +SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data) { SDL_JoystickGUID guid; Uint16 *guid16 = (Uint16 *)guid.data; + Uint16 crc = 0; SDL_zero(guid); - if (name == NULL) { - name = ""; + if (vendor_name && *vendor_name && product_name && *product_name) { + crc = SDL_crc16(crc, vendor_name, SDL_strlen(vendor_name)); + crc = SDL_crc16(crc, " ", 1); + crc = SDL_crc16(crc, product_name, SDL_strlen(product_name)); + } else if (product_name) { + crc = SDL_crc16(crc, product_name, SDL_strlen(product_name)); } /* We only need 16 bits for each of these; space them out to fill 128. */ /* Byteswap so devices get same GUID on little/big endian platforms. */ *guid16++ = SDL_SwapLE16(bus); - *guid16++ = SDL_SwapLE16(SDL_crc16(0, name, SDL_strlen(name))); + *guid16++ = SDL_SwapLE16(crc); if (vendor && product) { *guid16++ = SDL_SwapLE16(vendor); @@ -2124,14 +2503,14 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc guid.data[14] = driver_signature; guid.data[15] = driver_data; } - SDL_strlcpy((char *)guid16, name, available_space); + SDL_strlcpy((char *)guid16, product_name, available_space); } return guid; } SDL_JoystickGUID SDL_CreateJoystickGUIDForName(const char *name) { - return SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_UNKNOWN, 0, 0, 0, name, 0, 0); + return SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_UNKNOWN, 0, 0, 0, NULL, name, 0, 0); } void SDL_SetJoystickGUIDVendor(SDL_JoystickGUID *guid, Uint16 vendor) @@ -2179,9 +2558,6 @@ SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromVIDPID(Uint16 vendor } else if (vendor == 0x0001 && product == 0x0001) { type = SDL_CONTROLLER_TYPE_UNKNOWN; - } else if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER) { - type = SDL_CONTROLLER_TYPE_XBOXONE; - } else if ((vendor == USB_VENDOR_AMAZON && product == USB_PRODUCT_AMAZON_LUNA_CONTROLLER) || (vendor == BLUETOOTH_VENDOR_AMAZON && product == BLUETOOTH_PRODUCT_LUNA_CONTROLLER)) { type = SDL_CONTROLLER_TYPE_AMAZON_LUNA; @@ -2281,6 +2657,22 @@ SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUI return type; } +SDL_bool SDL_JoystickGUIDUsesVersion(SDL_JoystickGUID guid) +{ + Uint16 vendor, product; + + if (SDL_IsJoystickMFI(guid)) { + /* The version bits are used as button capability mask */ + return SDL_FALSE; + } + + SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); + if (vendor && product) { + return SDL_TRUE; + } + return SDL_FALSE; +} + SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id) { EControllerType eType = GuessControllerType(vendor_id, product_id); @@ -2346,7 +2738,13 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) } } if (vendor_id == USB_VENDOR_8BITDO) { - if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER) { + if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 || + product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER2) { + return SDL_TRUE; + } + } + if (vendor_id == USB_VENDOR_GAMESIR) { + if (product_id == USB_PRODUCT_GAMESIR_G7) { return SDL_TRUE; } } @@ -2438,6 +2836,12 @@ SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id) return eType == k_eControllerType_SteamController || eType == k_eControllerType_SteamControllerV2; } +SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id) +{ + EControllerType eType = GuessControllerType(vendor_id, product_id); + return eType == k_eControllerType_SteamDeck; +} + SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid) { return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE; @@ -2453,6 +2857,11 @@ SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid) return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE; } +SDL_bool SDL_IsJoystickMFI(SDL_JoystickGUID guid) +{ + return (guid.data[14] == 'm') ? SDL_TRUE : SDL_FALSE; +} + SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid) { return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE; @@ -2463,134 +2872,48 @@ SDL_bool SDL_IsJoystickVirtual(SDL_JoystickGUID guid) return (guid.data[14] == 'v') ? SDL_TRUE : SDL_FALSE; } -static SDL_bool SDL_IsJoystickProductWheel(Uint32 vidpid) -{ - static Uint32 wheel_joysticks[] = { - MAKE_VIDPID(0x0079, 0x1864), /* DragonRise Inc. Wired Wheel (active mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ - MAKE_VIDPID(0x046d, 0xc294), /* Logitech generic wheel */ - MAKE_VIDPID(0x046d, 0xc295), /* Logitech Momo Force */ - MAKE_VIDPID(0x046d, 0xc298), /* Logitech Driving Force Pro */ - 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 (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(0x046d, 0xc268), /* Logitech PRO Racing Wheel (PC mode) */ - MAKE_VIDPID(0x046d, 0xc269), /* Logitech PRO Racing Wheel (PS4/PS5 mode) */ - MAKE_VIDPID(0x046d, 0xc26d), /* Logitech G923 (Xbox) */ - MAKE_VIDPID(0x046d, 0xc26e), /* Logitech G923 */ - MAKE_VIDPID(0x046d, 0xca03), /* Logitech Momo Racing */ - MAKE_VIDPID(0x044f, 0xb65d), /* Thrustmaster Wheel FFB */ - MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster Wheel FFB */ - MAKE_VIDPID(0x044f, 0xb677), /* Thrustmaster T150 */ - MAKE_VIDPID(0x044f, 0xb696), /* Thrustmaster T248 */ - MAKE_VIDPID(0x044f, 0xb66e), /* Thrustmaster T300RS (normal mode) */ - MAKE_VIDPID(0x044f, 0xb66f), /* Thrustmaster T300RS (advanced mode) */ - MAKE_VIDPID(0x044f, 0xb66d), /* Thrustmaster T300RS (PS4 mode) */ - MAKE_VIDPID(0x044f, 0xb65e), /* Thrustmaster T500RS */ - MAKE_VIDPID(0x044f, 0xb664), /* Thrustmaster TX (initial mode) */ - MAKE_VIDPID(0x044f, 0xb669), /* Thrustmaster TX (active mode) */ - MAKE_VIDPID(0x11ff, 0x0511), /* DragonRise Inc. Wired Wheel (initial mode) (also known as PXN V900 (PS3), Superdrive SV-750, or a Genesis Seaborg 400) */ - }; - int i; - - for (i = 0; i < SDL_arraysize(wheel_joysticks); ++i) { - if (vidpid == wheel_joysticks[i]) { - return SDL_TRUE; - } - } - return SDL_FALSE; +static SDL_bool SDL_IsJoystickWheel(Uint16 vendor_id, Uint16 product_id) +{ + return SDL_VIDPIDInList(vendor_id, product_id, &wheel_devices); } -static SDL_bool SDL_IsJoystickProductArcadeStick(Uint32 vidpid) -{ - static Uint32 arcadestick_joysticks[] = { - MAKE_VIDPID(0x0079, 0x181a), /* Venom Arcade Stick */ - MAKE_VIDPID(0x0079, 0x181b), /* Venom Arcade Stick */ - MAKE_VIDPID(0x0c12, 0x0ef6), /* Hitbox Arcade Stick */ - MAKE_VIDPID(0x0e6f, 0x0109), /* PDP Versus Fighting Pad */ - MAKE_VIDPID(0x0f0d, 0x0016), /* Hori Real Arcade Pro.EX */ - MAKE_VIDPID(0x0f0d, 0x001b), /* Hori Real Arcade Pro VX */ - MAKE_VIDPID(0x0f0d, 0x0063), /* Hori Real Arcade Pro Hayabusa (USA) Xbox One */ - MAKE_VIDPID(0x0f0d, 0x006a), /* Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x0078), /* Hori Real Arcade Pro V Kai Xbox One */ - MAKE_VIDPID(0x0f0d, 0x008a), /* HORI Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x008c), /* Hori Real Arcade Pro 4 */ - MAKE_VIDPID(0x0f0d, 0x00aa), /* HORI Real Arcade Pro V Hayabusa in Switch Mode */ - MAKE_VIDPID(0x0f0d, 0x00ed), /* Hori Fighting Stick mini 4 kai */ - MAKE_VIDPID(0x0f0d, 0x011c), /* Hori Fighting Stick α in PS4 Mode */ - MAKE_VIDPID(0x0f0d, 0x011e), /* Hori Fighting Stick α in PC Mode */ - MAKE_VIDPID(0x0f0d, 0x0184), /* Hori Fighting Stick α in PS5 Mode */ - MAKE_VIDPID(0x146b, 0x0604), /* NACON Daija Arcade Stick */ - MAKE_VIDPID(0x1532, 0x0a00), /* Razer Atrox Arcade Stick */ - MAKE_VIDPID(0x1bad, 0xf03d), /* Street Fighter IV Arcade Stick TE - Chun Li */ - MAKE_VIDPID(0x1bad, 0xf502), /* Hori Real Arcade Pro.VX SA */ - MAKE_VIDPID(0x1bad, 0xf504), /* Hori Real Arcade Pro. EX */ - MAKE_VIDPID(0x1bad, 0xf506), /* Hori Real Arcade Pro.EX Premium VLX */ - MAKE_VIDPID(0x20d6, 0xa715), /* PowerA Nintendo Switch Fusion Arcade Stick */ - MAKE_VIDPID(0x24c6, 0x5000), /* Razer Atrox Arcade Stick */ - MAKE_VIDPID(0x24c6, 0x5501), /* Hori Real Arcade Pro VX-SA */ - MAKE_VIDPID(0x24c6, 0x550e), /* Hori Real Arcade Pro V Kai 360 */ - MAKE_VIDPID(0x2c22, 0x2300), /* Qanba Obsidian Arcade Joystick in PS4 Mode */ - MAKE_VIDPID(0x2c22, 0x2302), /* Qanba Obsidian Arcade Joystick in PS3 Mode */ - MAKE_VIDPID(0x2c22, 0x2303), /* Qanba Obsidian Arcade Joystick in PC Mode */ - MAKE_VIDPID(0x2c22, 0x2500), /* Qanba Dragon Arcade Joystick in PS4 Mode */ - MAKE_VIDPID(0x2c22, 0x2502), /* Qanba Dragon Arcade Joystick in PS3 Mode */ - MAKE_VIDPID(0x2c22, 0x2503), /* Qanba Dragon Arcade Joystick in PC Mode */ - }; - int i; - - for (i = 0; i < SDL_arraysize(arcadestick_joysticks); ++i) { - if (vidpid == arcadestick_joysticks[i]) { - return SDL_TRUE; - } - } - return SDL_FALSE; +static SDL_bool SDL_IsJoystickArcadeStick(Uint16 vendor_id, Uint16 product_id) +{ + return SDL_VIDPIDInList(vendor_id, product_id, &arcadestick_devices); } -static SDL_bool SDL_IsJoystickProductFlightStick(Uint32 vidpid) +static SDL_bool SDL_IsJoystickFlightStick(Uint16 vendor_id, Uint16 product_id) { - static Uint32 flightstick_joysticks[] = { - MAKE_VIDPID(0x044f, 0x0402), /* HOTAS Warthog Joystick */ - MAKE_VIDPID(0x0738, 0x2221), /* Saitek Pro Flight X-56 Rhino Stick */ - MAKE_VIDPID(0x044f, 0xb10a), /* ThrustMaster, Inc. T.16000M Joystick */ - MAKE_VIDPID(0x046d, 0xc215), /* Logitech Extreme 3D */ - MAKE_VIDPID(0x231d, 0x0126), /* Gunfighter Mk.III ‘Space Combat Edition’ (right) */ - MAKE_VIDPID(0x231d, 0x0127), /* Gunfighter Mk.III ‘Space Combat Edition’ (left) */ - }; - int i; - - for (i = 0; i < SDL_arraysize(flightstick_joysticks); ++i) { - if (vidpid == flightstick_joysticks[i]) { - return SDL_TRUE; - } - } - return SDL_FALSE; + return SDL_VIDPIDInList(vendor_id, product_id, &flightstick_devices); } -static SDL_bool SDL_IsJoystickProductThrottle(Uint32 vidpid) +static SDL_bool SDL_IsJoystickThrottle(Uint16 vendor_id, Uint16 product_id) { - static Uint32 throttle_joysticks[] = { - MAKE_VIDPID(0x044f, 0x0404), /* HOTAS Warthog Throttle */ - MAKE_VIDPID(0x0738, 0xa221), /* Saitek Pro Flight X-56 Rhino Throttle */ - }; - int i; - - for (i = 0; i < SDL_arraysize(throttle_joysticks); ++i) { - if (vidpid == throttle_joysticks[i]) { - return SDL_TRUE; - } - } - return SDL_FALSE; + return SDL_VIDPIDInList(vendor_id, product_id, &throttle_devices); } static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) { Uint16 vendor; Uint16 product; - Uint32 vidpid; + + SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); + + if (SDL_IsJoystickWheel(vendor, product)) { + return SDL_JOYSTICK_TYPE_WHEEL; + } + + if (SDL_IsJoystickArcadeStick(vendor, product)) { + return SDL_JOYSTICK_TYPE_ARCADE_STICK; + } + + if (SDL_IsJoystickFlightStick(vendor, product)) { + return SDL_JOYSTICK_TYPE_FLIGHT_STICK; + } + + if (SDL_IsJoystickThrottle(vendor, product)) { + return SDL_JOYSTICK_TYPE_THROTTLE; + } if (SDL_IsJoystickXInput(guid)) { /* XInput GUID, get the type based on the XInput device subtype */ @@ -2626,25 +2949,6 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) return (SDL_JoystickType)guid.data[15]; } - SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); - vidpid = MAKE_VIDPID(vendor, product); - - if (SDL_IsJoystickProductWheel(vidpid)) { - return SDL_JOYSTICK_TYPE_WHEEL; - } - - if (SDL_IsJoystickProductArcadeStick(vidpid)) { - return SDL_JOYSTICK_TYPE_ARCADE_STICK; - } - - if (SDL_IsJoystickProductFlightStick(vidpid)) { - return SDL_JOYSTICK_TYPE_FLIGHT_STICK; - } - - if (SDL_IsJoystickProductThrottle(vidpid)) { - return SDL_JOYSTICK_TYPE_THROTTLE; - } - #ifdef SDL_JOYSTICK_HIDAPI if (SDL_IsJoystickHIDAPI(guid)) { return HIDAPI_GetJoystickTypeFromGUID(guid); @@ -2660,147 +2964,18 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid) { - /* This list is taken from: - https://raw.githubusercontent.com/denilsonsa/udev-joystick-blacklist/master/generate_rules.py - */ - static Uint32 joystick_blacklist[] = { - /* Microsoft Microsoft Wireless Optical Desktop 2.10 */ - /* Microsoft Wireless Desktop - Comfort Edition */ - MAKE_VIDPID(0x045e, 0x009d), - - /* Microsoft Microsoft Digital Media Pro Keyboard */ - /* Microsoft Corp. Digital Media Pro Keyboard */ - MAKE_VIDPID(0x045e, 0x00b0), - - /* Microsoft Microsoft Digital Media Keyboard */ - /* Microsoft Corp. Digital Media Keyboard 1.0A */ - MAKE_VIDPID(0x045e, 0x00b4), - - /* Microsoft Microsoft Digital Media Keyboard 3000 */ - MAKE_VIDPID(0x045e, 0x0730), - - /* Microsoft Microsoft 2.4GHz Transceiver v6.0 */ - /* Microsoft Microsoft 2.4GHz Transceiver v8.0 */ - /* Microsoft Corp. Nano Transceiver v1.0 for Bluetooth */ - /* Microsoft Wireless Mobile Mouse 1000 */ - /* Microsoft Wireless Desktop 3000 */ - MAKE_VIDPID(0x045e, 0x0745), - - /* Microsoft SideWinder(TM) 2.4GHz Transceiver */ - MAKE_VIDPID(0x045e, 0x0748), - - /* Microsoft Corp. Wired Keyboard 600 */ - MAKE_VIDPID(0x045e, 0x0750), - - /* Microsoft Corp. Sidewinder X4 keyboard */ - MAKE_VIDPID(0x045e, 0x0768), - - /* Microsoft Corp. Arc Touch Mouse Transceiver */ - MAKE_VIDPID(0x045e, 0x0773), - - /* Microsoft 2.4GHz Transceiver v9.0 */ - /* Microsoft Nano Transceiver v2.1 */ - /* Microsoft Sculpt Ergonomic Keyboard (5KV-00001) */ - MAKE_VIDPID(0x045e, 0x07a5), - - /* Microsoft Nano Transceiver v1.0 */ - /* Microsoft Wireless Keyboard 800 */ - MAKE_VIDPID(0x045e, 0x07b2), - - /* Microsoft Nano Transceiver v2.0 */ - MAKE_VIDPID(0x045e, 0x0800), - - MAKE_VIDPID(0x046d, 0xc30a), /* Logitech, Inc. iTouch Composite keboard */ - - MAKE_VIDPID(0x04d9, 0xa0df), /* Tek Syndicate Mouse (E-Signal USB Gaming Mouse) */ - - /* List of Wacom devices at: http://linuxwacom.sourceforge.net/wiki/index.php/Device_IDs */ - MAKE_VIDPID(0x056a, 0x0010), /* Wacom ET-0405 Graphire */ - MAKE_VIDPID(0x056a, 0x0011), /* Wacom ET-0405A Graphire2 (4x5) */ - MAKE_VIDPID(0x056a, 0x0012), /* Wacom ET-0507A Graphire2 (5x7) */ - MAKE_VIDPID(0x056a, 0x0013), /* Wacom CTE-430 Graphire3 (4x5) */ - MAKE_VIDPID(0x056a, 0x0014), /* Wacom CTE-630 Graphire3 (6x8) */ - MAKE_VIDPID(0x056a, 0x0015), /* Wacom CTE-440 Graphire4 (4x5) */ - MAKE_VIDPID(0x056a, 0x0016), /* Wacom CTE-640 Graphire4 (6x8) */ - MAKE_VIDPID(0x056a, 0x0017), /* Wacom CTE-450 Bamboo Fun (4x5) */ - MAKE_VIDPID(0x056a, 0x0018), /* Wacom CTE-650 Bamboo Fun 6x8 */ - MAKE_VIDPID(0x056a, 0x0019), /* Wacom CTE-631 Bamboo One */ - MAKE_VIDPID(0x056a, 0x00d1), /* Wacom Bamboo Pen and Touch CTH-460 */ - MAKE_VIDPID(0x056a, 0x030e), /* Wacom Intuos Pen (S) CTL-480 */ - - MAKE_VIDPID(0x09da, 0x054f), /* A4 Tech Co., G7 750 mouse */ - MAKE_VIDPID(0x09da, 0x1410), /* A4 Tech Co., Ltd Bloody AL9 mouse */ - MAKE_VIDPID(0x09da, 0x3043), /* A4 Tech Co., Ltd Bloody R8A Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x31b5), /* A4 Tech Co., Ltd Bloody TL80 Terminator Laser Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x3997), /* A4 Tech Co., Ltd Bloody RT7 Terminator Wireless */ - MAKE_VIDPID(0x09da, 0x3f8b), /* A4 Tech Co., Ltd Bloody V8 mouse */ - MAKE_VIDPID(0x09da, 0x51f4), /* Modecom MC-5006 Keyboard */ - MAKE_VIDPID(0x09da, 0x5589), /* A4 Tech Co., Ltd Terminator TL9 Laser Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x7b22), /* A4 Tech Co., Ltd Bloody V5 */ - MAKE_VIDPID(0x09da, 0x7f2d), /* A4 Tech Co., Ltd Bloody R3 mouse */ - MAKE_VIDPID(0x09da, 0x8090), /* A4 Tech Co., Ltd X-718BK Oscar Optical Gaming Mouse */ - MAKE_VIDPID(0x09da, 0x9033), /* A4 Tech Co., X7 X-705K */ - MAKE_VIDPID(0x09da, 0x9066), /* A4 Tech Co., Sharkoon Fireglider Optical */ - MAKE_VIDPID(0x09da, 0x9090), /* A4 Tech Co., Ltd XL-730K / XL-750BK / XL-755BK Laser Mouse */ - MAKE_VIDPID(0x09da, 0x90c0), /* A4 Tech Co., Ltd X7 G800V keyboard */ - MAKE_VIDPID(0x09da, 0xf012), /* A4 Tech Co., Ltd Bloody V7 mouse */ - MAKE_VIDPID(0x09da, 0xf32a), /* A4 Tech Co., Ltd Bloody B540 keyboard */ - MAKE_VIDPID(0x09da, 0xf613), /* A4 Tech Co., Ltd Bloody V2 mouse */ - MAKE_VIDPID(0x09da, 0xf624), /* A4 Tech Co., Ltd Bloody B120 Keyboard */ - - MAKE_VIDPID(0x1b1c, 0x1b3c), /* Corsair Harpoon RGB gaming mouse */ - - MAKE_VIDPID(0x1d57, 0xad03), /* [T3] 2.4GHz and IR Air Mouse Remote Control */ - - MAKE_VIDPID(0x1e7d, 0x2e4a), /* Roccat Tyon Mouse */ - - MAKE_VIDPID(0x20a0, 0x422d), /* Winkeyless.kr Keyboards */ - - MAKE_VIDPID(0x2516, 0x001f), /* Cooler Master Storm Mizar Mouse */ - MAKE_VIDPID(0x2516, 0x0028), /* Cooler Master Storm Alcor Mouse */ - - /*****************************************************************/ - /* Additional entries */ - /*****************************************************************/ - - MAKE_VIDPID(0x04d9, 0x8008), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0x8009), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0xa292), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x04d9, 0xa293), /* OBINLB USB-HID Keyboard (Anne Pro II) */ - MAKE_VIDPID(0x1532, 0x0266), /* Razer Huntsman V2 Analog, non-functional DInput device */ - MAKE_VIDPID(0x1532, 0x0282), /* Razer Huntsman Mini Analog, non-functional DInput device */ - MAKE_VIDPID(0x26ce, 0x01a2), /* ASRock LED Controller */ - MAKE_VIDPID(0x20d6, 0x0002), /* PowerA Enhanced Wireless Controller for Nintendo Switch (charging port only) */ - }; - - static Uint32 rog_chakram_list[] = { - MAKE_VIDPID(0x0b05, 0x1958), /* ROG Chakram Core Mouse */ - MAKE_VIDPID(0x0b05, 0x18e3), /* ROG Chakram (wired) Mouse */ - MAKE_VIDPID(0x0b05, 0x18e5), /* ROG Chakram (wireless) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a18), /* ROG Chakram X (wired) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a1a), /* ROG Chakram X (wireless) Mouse */ - MAKE_VIDPID(0x0b05, 0x1a1c), /* ROG Chakram X (Bluetooth) Mouse */ - }; - - unsigned int i; - Uint32 id; Uint16 vendor; Uint16 product; SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); /* Check the joystick blacklist */ - id = MAKE_VIDPID(vendor, product); - for (i = 0; i < SDL_arraysize(joystick_blacklist); ++i) { - if (id == joystick_blacklist[i]) { - return SDL_TRUE; - } + if (SDL_VIDPIDInList(vendor, product, &blacklist_devices)) { + return SDL_TRUE; } if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_ROG_CHAKRAM, SDL_FALSE)) { - for (i = 0; i < SDL_arraysize(rog_chakram_list); ++i) { - if (id == rog_chakram_list[i]) { - return SDL_TRUE; - } + if (SDL_VIDPIDInList(vendor, product, &rog_gamepad_mice)) { + return SDL_TRUE; } } @@ -2831,18 +3006,38 @@ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index) Uint16 SDL_JoystickGetDeviceVendor(int device_index) { Uint16 vendor; - SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); + const SDL_SteamVirtualGamepadInfo *info; + + SDL_LockJoysticks(); + info = SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickGetDeviceInstanceID(device_index)); + if (info) { + vendor = info->vendor_id; + } else { + SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); + + SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); + } + SDL_UnlockJoysticks(); - SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); return vendor; } Uint16 SDL_JoystickGetDeviceProduct(int device_index) { Uint16 product; - SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); + const SDL_SteamVirtualGamepadInfo *info; + + SDL_LockJoysticks(); + info = SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickGetDeviceInstanceID(device_index)); + if (info) { + product = info->product_id; + } else { + SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index); + + SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); + } + SDL_UnlockJoysticks(); - SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); return product; } @@ -2920,18 +3115,46 @@ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick *joystick) Uint16 SDL_JoystickGetVendor(SDL_Joystick *joystick) { Uint16 vendor; - SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); + const SDL_SteamVirtualGamepadInfo *info; + + SDL_LockJoysticks(); + { + CHECK_JOYSTICK_MAGIC(joystick, 0); + + info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id); + if (info) { + vendor = info->vendor_id; + } else { + SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); + + SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); + } + } + SDL_UnlockJoysticks(); - SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); return vendor; } Uint16 SDL_JoystickGetProduct(SDL_Joystick *joystick) { Uint16 product; - SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); + const SDL_SteamVirtualGamepadInfo *info; + + SDL_LockJoysticks(); + { + CHECK_JOYSTICK_MAGIC(joystick, 0); + + info = SDL_GetJoystickInstanceVirtualGamepadInfo(joystick->instance_id); + if (info) { + product = info->product_id; + } else { + SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick); + + SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); + } + } + SDL_UnlockJoysticks(); - SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); return product; } @@ -3013,7 +3236,7 @@ void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLe SDL_assert(joystick->ref_count); /* make sure we are calling this only for update, not for initialization */ if (ePowerLevel != joystick->epowerlevel) { -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_JOYBATTERYUPDATED) == SDL_ENABLE) { SDL_Event event; event.type = SDL_JOYBATTERYUPDATED; @@ -3116,7 +3339,7 @@ int SDL_PrivateJoystickTouchpad(SDL_Joystick *joystick, int touchpad, int finger /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(event_type) == SDL_ENABLE) { SDL_Event event; event.type = event_type; @@ -3156,7 +3379,7 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6 sensor->timestamp_us = timestamp_us; /* Post the event, if desired */ -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_CONTROLLERSENSORUPDATE) == SDL_ENABLE) { SDL_Event event; event.type = SDL_CONTROLLERSENSORUPDATE; @@ -3176,4 +3399,174 @@ int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, Uint6 return posted; } +static void SDL_LoadVIDPIDListFromHint(const char *hint, int *num_entries, int *max_entries, Uint32 **entries) +{ + Uint32 entry; + char *spot; + char *file = NULL; + + if (hint && *hint == '@') { + spot = file = (char *)SDL_LoadFile(hint + 1, NULL); + } else { + spot = (char *)hint; + } + + if (spot == NULL) { + return; + } + + while ((spot = SDL_strstr(spot, "0x")) != NULL) { + entry = (Uint16)SDL_strtol(spot, &spot, 0); + entry <<= 16; + spot = SDL_strstr(spot, "0x"); + if (spot == NULL) { + break; + } + entry |= (Uint16)SDL_strtol(spot, &spot, 0); + + if (*num_entries == *max_entries) { + int new_max_entries = *max_entries + 16; + Uint32 *new_entries = (Uint32 *)SDL_realloc(*entries, new_max_entries * sizeof(**entries)); + if (!new_entries) { + /* Out of memory, go with what we have already */ + break; + } + *entries = new_entries; + *max_entries = new_max_entries; + } + (*entries)[(*num_entries)++] = entry; + } + + if (file) { + SDL_free(file); + } +} + +void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list) +{ + /* Empty the list */ + list->num_included_entries = 0; + list->num_excluded_entries = 0; + + /* Add the initial entries */ + if (list->num_initial_entries > 0) { + if (list->num_included_entries < list->num_initial_entries) { + Uint32 *entries = (Uint32 *)SDL_malloc(list->num_initial_entries * sizeof(*entries)); + if (entries) { + SDL_memcpy(entries, list->initial_entries, list->num_initial_entries * sizeof(*entries)); + list->included_entries = entries; + list->num_included_entries = list->num_initial_entries; + list->max_included_entries = list->num_initial_entries; + } + } + } + + /* Add the included entries from the hint */ + SDL_LoadVIDPIDListFromHint(included_list, &list->num_included_entries, &list->max_included_entries, &list->included_entries); + + /* Add the excluded entries from the hint */ + SDL_LoadVIDPIDListFromHint(excluded_list, &list->num_excluded_entries, &list->max_excluded_entries, &list->excluded_entries); +} + +static void SDLCALL SDL_VIDPIDIncludedHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_vidpid_list *list = (SDL_vidpid_list *)userdata; + const char *included_list = hint; + const char *excluded_list = NULL; + + if (!list->initialized) { + return; + } + + if (list->excluded_hint_name) { + excluded_list = SDL_GetHint(list->excluded_hint_name); + } + SDL_LoadVIDPIDListFromHints(list, included_list, excluded_list); +} + +static void SDLCALL SDL_VIDPIDExcludedHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_vidpid_list *list = (SDL_vidpid_list *)userdata; + const char *included_list = NULL; + const char *excluded_list = hint; + + if (!list->initialized) { + return; + } + + if (list->included_hint_name) { + included_list = SDL_GetHint(list->included_hint_name); + } + SDL_LoadVIDPIDListFromHints(list, included_list, excluded_list); +} + +void SDL_LoadVIDPIDList(SDL_vidpid_list *list) +{ + const char *included_list = NULL; + const char *excluded_list = NULL; + + if (list->included_hint_name) { + SDL_AddHintCallback(list->included_hint_name, SDL_VIDPIDIncludedHintChanged, list); + } + + if (list->excluded_hint_name) { + SDL_AddHintCallback(list->excluded_hint_name, SDL_VIDPIDExcludedHintChanged, list); + } + + list->initialized = SDL_TRUE; + + if (list->included_hint_name) { + included_list = SDL_GetHint(list->included_hint_name); + } + if (list->excluded_hint_name) { + excluded_list = SDL_GetHint(list->excluded_hint_name); + } + SDL_LoadVIDPIDListFromHints(list, included_list, excluded_list); +} + +SDL_bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list) +{ + int i; + Uint32 vidpid = MAKE_VIDPID(vendor_id, product_id); + + for (i = 0; i < list->num_excluded_entries; ++i) { + if (vidpid == list->excluded_entries[i]) { + return SDL_FALSE; + } + } + for (i = 0; i < list->num_included_entries; ++i) { + if (vidpid == list->included_entries[i]) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +void SDL_FreeVIDPIDList(SDL_vidpid_list *list) +{ + if (list->included_hint_name) { + SDL_DelHintCallback(list->included_hint_name, SDL_VIDPIDIncludedHintChanged, list); + } + + if (list->excluded_hint_name) { + SDL_DelHintCallback(list->excluded_hint_name, SDL_VIDPIDExcludedHintChanged, list); + } + + if (list->included_entries) { + SDL_free(list->included_entries); + list->included_entries = NULL; + list->num_included_entries = 0; + list->max_included_entries = 0; + } + + if (list->excluded_entries) { + SDL_free(list->excluded_entries); + list->excluded_entries = NULL; + list->num_excluded_entries = 0; + list->max_excluded_entries = 0; + } + + list->initialized = SDL_FALSE; +} + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/joystick/SDL_joystick_c.h b/vs/sdl2/src/joystick/SDL_joystick_c.h index 484746d44a..44d8e8cc91 100644 --- a/vs/sdl2/src/joystick/SDL_joystick_c.h +++ b/vs/sdl2/src/joystick/SDL_joystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ extern "C" { #endif struct _SDL_JoystickDriver; +struct SDL_SteamVirtualGamepadInfo; extern char SDL_joystick_magic; /* Initialization and shutdown functions */ @@ -70,7 +71,7 @@ extern int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id); extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name); /* Function to create a GUID for a joystick based on the VID/PID and name */ -extern SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *name, Uint8 driver_signature, Uint8 driver_data); +extern SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data); /* Function to create a GUID for a joystick based on the name, with no VID/PID information */ extern SDL_JoystickGUID SDL_CreateJoystickGUIDForName(const char *name); @@ -91,6 +92,9 @@ extern void SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc); extern SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI); extern SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name); +/* Function to return whether a joystick GUID uses the version field */ +extern SDL_bool SDL_JoystickGUIDUsesVersion(SDL_JoystickGUID guid); + /* Function to return whether a joystick is an Xbox One controller */ extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); @@ -122,6 +126,9 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 /* Function to return whether a joystick is a Steam Controller */ extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); +/* Function to return whether a joystick is a Steam Deck */ +extern SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); + /* Function to return whether a joystick guid comes from the XInput driver */ extern SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid); @@ -131,6 +138,9 @@ extern SDL_bool SDL_IsJoystickWGI(SDL_JoystickGUID guid); /* Function to return whether a joystick guid comes from the HIDAPI driver */ extern SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid); +/* Function to return whether a joystick guid comes from the MFI driver */ +extern SDL_bool SDL_IsJoystickMFI(SDL_JoystickGUID guid); + /* Function to return whether a joystick guid comes from the RAWINPUT driver */ extern SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid); @@ -170,21 +180,27 @@ extern int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, extern void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel); +/* Function to get the Steam virtual gamepad info for a joystick */ +extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickID instance_id); + /* Internal sanity checking functions */ extern SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick); typedef enum { - EMappingKind_None = 0, - EMappingKind_Button = 1, - EMappingKind_Axis = 2, - EMappingKind_Hat = 3 + EMappingKind_None, + EMappingKind_Button, + EMappingKind_Axis, + EMappingKind_Hat, } EMappingKind; typedef struct _SDL_InputMapping { EMappingKind kind; Uint8 target; + SDL_bool axis_reversed; + SDL_bool half_axis_positive; + SDL_bool half_axis_negative; } SDL_InputMapping; typedef struct _SDL_GamepadMapping @@ -215,12 +231,40 @@ typedef struct _SDL_GamepadMapping SDL_InputMapping righty; SDL_InputMapping lefttrigger; SDL_InputMapping righttrigger; + SDL_InputMapping touchpad; } SDL_GamepadMapping; /* Function to get autodetected gamepad controller mapping from the driver */ extern SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out); + +typedef struct +{ + const char *included_hint_name; + int num_included_entries; + int max_included_entries; + Uint32 *included_entries; + + const char *excluded_hint_name; + int num_excluded_entries; + int max_excluded_entries; + Uint32 *excluded_entries; + + int num_initial_entries; + Uint32 *initial_entries; + + SDL_bool initialized; +} SDL_vidpid_list; + +extern void SDL_LoadVIDPIDList(SDL_vidpid_list *list); +extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list); +extern SDL_bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); +extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); + +/* This is in SDL_gamecontroller.c */ +extern SDL_GameControllerType SDL_GetGameControllerTypeFromString(const char *str); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus } diff --git a/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.c b/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.c new file mode 100644 index 0000000000..4e5255d05e --- /dev/null +++ b/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.c @@ -0,0 +1,251 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2024 Sam Lantinga + + 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_timer.h" +#include "SDL_joystick_c.h" +#include "SDL_steam_virtual_gamepad.h" + +#ifdef __WIN32__ +#include "../core/windows/SDL_windows.h" +#else +#include +#include +#endif + +#define SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE "SteamVirtualGamepadInfo" + +static char *SDL_steam_virtual_gamepad_info_file SDL_GUARDED_BY(SDL_joystick_lock) = NULL; +static Uint64 SDL_steam_virtual_gamepad_info_file_mtime SDL_GUARDED_BY(SDL_joystick_lock) = 0; +static Uint32 SDL_steam_virtual_gamepad_info_check_time SDL_GUARDED_BY(SDL_joystick_lock) = 0; +static SDL_SteamVirtualGamepadInfo **SDL_steam_virtual_gamepad_info SDL_GUARDED_BY(SDL_joystick_lock) = NULL; +static int SDL_steam_virtual_gamepad_info_count SDL_GUARDED_BY(SDL_joystick_lock) = 0; + + +static Uint64 GetFileModificationTime(const char *file) +{ + Uint64 modification_time = 0; + +#ifdef __WIN32__ + WCHAR *wFile = WIN_UTF8ToStringW(file); + if (wFile) { + HANDLE hFile = CreateFileW(wFile, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + if (hFile != INVALID_HANDLE_VALUE) { + FILETIME last_write_time; + if (GetFileTime(hFile, NULL, NULL, &last_write_time)) { + modification_time = last_write_time.dwHighDateTime; + modification_time <<= 32; + modification_time |= last_write_time.dwLowDateTime; + } + CloseHandle(hFile); + } + SDL_free(wFile); + } +#else + struct stat sb; + + if (stat(file, &sb) == 0) { + modification_time = (Uint64)sb.st_mtime; + } +#endif + return modification_time; +} + +static void SDL_FreeSteamVirtualGamepadInfo(void) +{ + int i; + + SDL_AssertJoysticksLocked(); + + for (i = 0; i < SDL_steam_virtual_gamepad_info_count; ++i) { + SDL_SteamVirtualGamepadInfo *entry = SDL_steam_virtual_gamepad_info[i]; + if (entry) { + SDL_free(entry->name); + SDL_free(entry); + } + } + SDL_free(SDL_steam_virtual_gamepad_info); + SDL_steam_virtual_gamepad_info = NULL; + SDL_steam_virtual_gamepad_info_count = 0; +} + +static void AddVirtualGamepadInfo(int slot, SDL_SteamVirtualGamepadInfo *info) +{ + SDL_SteamVirtualGamepadInfo *new_info; + + SDL_AssertJoysticksLocked(); + + if (slot < 0) { + return; + } + + if (slot >= SDL_steam_virtual_gamepad_info_count) { + SDL_SteamVirtualGamepadInfo **slots = (SDL_SteamVirtualGamepadInfo **)SDL_realloc(SDL_steam_virtual_gamepad_info, (slot + 1)*sizeof(*SDL_steam_virtual_gamepad_info)); + if (!slots) { + return; + } + while (SDL_steam_virtual_gamepad_info_count <= slot) { + slots[SDL_steam_virtual_gamepad_info_count++] = NULL; + } + SDL_steam_virtual_gamepad_info = slots; + } + + if (SDL_steam_virtual_gamepad_info[slot]) { + /* We already have this slot info */ + return; + } + + new_info = (SDL_SteamVirtualGamepadInfo *)SDL_malloc(sizeof(*new_info)); + if (!new_info) { + return; + } + SDL_copyp(new_info, info); + SDL_steam_virtual_gamepad_info[slot] = new_info; + SDL_zerop(info); +} + +void SDL_InitSteamVirtualGamepadInfo(void) +{ + const char *file; + + SDL_AssertJoysticksLocked(); + + file = SDL_GetHint(SDL_HINT_STEAM_VIRTUAL_GAMEPAD_INFO_FILE); + if (file && *file) { + SDL_steam_virtual_gamepad_info_file = SDL_strdup(file); + } + SDL_UpdateSteamVirtualGamepadInfo(); +} + +SDL_bool SDL_SteamVirtualGamepadEnabled(void) +{ + SDL_AssertJoysticksLocked(); + + return (SDL_steam_virtual_gamepad_info != NULL); +} + +SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void) +{ + const int UPDATE_CHECK_INTERVAL_MS = 3000; + Uint32 now; + Uint64 mtime; + char *data, *end, *next, *line, *value; + size_t size; + int slot, new_slot; + SDL_SteamVirtualGamepadInfo info; + + SDL_AssertJoysticksLocked(); + + if (!SDL_steam_virtual_gamepad_info_file) { + return SDL_FALSE; + } + + now = SDL_GetTicks(); + if (SDL_steam_virtual_gamepad_info_check_time && + !SDL_TICKS_PASSED(now, (SDL_steam_virtual_gamepad_info_check_time + UPDATE_CHECK_INTERVAL_MS))) { + return SDL_FALSE; + } + SDL_steam_virtual_gamepad_info_check_time = now; + + mtime = GetFileModificationTime(SDL_steam_virtual_gamepad_info_file); + if (mtime == 0 || mtime == SDL_steam_virtual_gamepad_info_file_mtime) { + return SDL_FALSE; + } + + data = (char *)SDL_LoadFile(SDL_steam_virtual_gamepad_info_file, &size); + if (!data) { + return SDL_FALSE; + } + + SDL_FreeSteamVirtualGamepadInfo(); + + slot = -1; + SDL_zero(info); + + for (next = data, end = data + size; next < end; ) { + while (next < end && (*next == '\0' || *next == '\r' || *next == '\n')) { + ++next; + } + + line = next; + + while (next < end && (*next != '\r' && *next != '\n')) { + ++next; + } + *next = '\0'; + + if (SDL_sscanf(line, "[slot %d]", &new_slot) == 1) { + if (slot >= 0) { + AddVirtualGamepadInfo(slot, &info); + } + slot = new_slot; + } else { + value = SDL_strchr(line, '='); + if (value) { + *value++ = '\0'; + + if (SDL_strcmp(line, "name") == 0) { + SDL_free(info.name); + info.name = SDL_strdup(value); + } else if (SDL_strcmp(line, "VID") == 0) { + info.vendor_id = (Uint16)SDL_strtoul(value, NULL, 0); + } else if (SDL_strcmp(line, "PID") == 0) { + info.product_id = (Uint16)SDL_strtoul(value, NULL, 0); + } else if (SDL_strcmp(line, "type") == 0) { + info.type = SDL_GetGameControllerTypeFromString(value); + } else if (SDL_strcmp(line, "handle") == 0) { + info.handle = SDL_strtoull(value, NULL, 0); + } + } + } + } + if (slot >= 0) { + AddVirtualGamepadInfo(slot, &info); + } + SDL_free(info.name); + SDL_free(data); + + SDL_steam_virtual_gamepad_info_file_mtime = mtime; + + return SDL_TRUE; +} + +const SDL_SteamVirtualGamepadInfo *SDL_GetSteamVirtualGamepadInfo(int slot) +{ + SDL_AssertJoysticksLocked(); + + if (slot < 0 || slot >= SDL_steam_virtual_gamepad_info_count) { + return NULL; + } + return SDL_steam_virtual_gamepad_info[slot]; +} + +void SDL_QuitSteamVirtualGamepadInfo(void) +{ + SDL_AssertJoysticksLocked(); + + if (SDL_steam_virtual_gamepad_info_file) { + SDL_FreeSteamVirtualGamepadInfo(); + SDL_free(SDL_steam_virtual_gamepad_info_file); + SDL_steam_virtual_gamepad_info_file = NULL; + } +} diff --git a/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.h b/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.h new file mode 100644 index 0000000000..415643b675 --- /dev/null +++ b/vs/sdl2/src/joystick/SDL_steam_virtual_gamepad.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2024 Sam Lantinga + + 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" + +typedef struct SDL_SteamVirtualGamepadInfo +{ + Uint64 handle; + char *name; + Uint16 vendor_id; + Uint16 product_id; + SDL_GameControllerType type; +} SDL_SteamVirtualGamepadInfo; + +void SDL_InitSteamVirtualGamepadInfo(void); +SDL_bool SDL_SteamVirtualGamepadEnabled(void); +SDL_bool SDL_UpdateSteamVirtualGamepadInfo(void); +const SDL_SteamVirtualGamepadInfo *SDL_GetSteamVirtualGamepadInfo(int slot); +void SDL_QuitSteamVirtualGamepadInfo(void); diff --git a/vs/sdl2/src/joystick/SDL_sysjoystick.h b/vs/sdl2/src/joystick/SDL_sysjoystick.h index a93fa662ca..173650e31f 100644 --- a/vs/sdl2/src/joystick/SDL_sysjoystick.h +++ b/vs/sdl2/src/joystick/SDL_sysjoystick.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +79,7 @@ struct _SDL_Joystick char *serial _guarded; /* Joystick serial */ SDL_JoystickGUID guid _guarded; /* Joystick guid */ Uint16 firmware_version _guarded; /* Firmware version, if available */ + Uint64 steam_handle _guarded; /* Steam controller API handle */ int naxes _guarded; /* Number of axis controls on the joystick */ SDL_JoystickAxisInfo *axes _guarded; @@ -167,6 +168,9 @@ typedef struct _SDL_JoystickDriver /* Function to get the device-dependent path of a joystick */ const char *(*GetDevicePath)(int device_index); + /* Function to get the Steam virtual gamepad slot of a joystick */ + int (*GetDeviceSteamVirtualGamepadSlot)(int device_index); + /* Function to get the player index of a joystick */ int (*GetDevicePlayerIndex)(int device_index); diff --git a/vs/sdl2/src/joystick/android/SDL_sysjoystick.c b/vs/sdl2/src/joystick/android/SDL_sysjoystick.c index 84822e4de9..c29f7387b8 100644 --- a/vs/sdl2/src/joystick/android/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/android/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -320,7 +320,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } } - if (JoystickByDeviceId(device_id) != NULL || name == NULL) { + if (JoystickByDeviceId(device_id) != NULL || !name) { goto done; } @@ -344,7 +344,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v nhats = 0; } - guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor_id, product_id, 0, desc, 0, 0); + guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor_id, product_id, 0, NULL, desc, 0, 0); /* Update the GUID with capability bits */ { @@ -354,7 +354,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { goto done; } @@ -362,7 +362,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->guid = guid; item->device_id = device_id; item->name = SDL_CreateJoystickName(vendor_id, product_id, NULL, name); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); goto done; } @@ -381,7 +381,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->nhats = nhats; item->nballs = nballs; item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -414,7 +414,7 @@ int Android_RemoveJoystick(int device_id) SDL_LockJoysticks(); /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ - while (item != NULL) { + while (item) { if (item->device_id == device_id) { break; } @@ -422,7 +422,7 @@ int Android_RemoveJoystick(int device_id) item = item->next; } - if (item == NULL) { + if (!item) { goto done; } @@ -430,7 +430,7 @@ int Android_RemoveJoystick(int device_id) item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -512,7 +512,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) { SDL_joylist_item *item = SDL_joylist; - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -522,7 +522,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) /* Joystick not found, try adding it */ ANDROID_JoystickDetect(); - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -542,6 +542,11 @@ static const char *ANDROID_JoystickGetDevicePath(int device_index) return NULL; } +static int ANDROID_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int ANDROID_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -565,11 +570,11 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDevIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } @@ -618,7 +623,7 @@ static void ANDROID_JoystickUpdate(SDL_Joystick *joystick) { SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; - if (item == NULL) { + if (!item) { return; } @@ -682,6 +687,7 @@ SDL_JoystickDriver SDL_ANDROID_JoystickDriver = { ANDROID_JoystickDetect, ANDROID_JoystickGetDeviceName, ANDROID_JoystickGetDevicePath, + ANDROID_JoystickGetDeviceSteamVirtualGamepadSlot, ANDROID_JoystickGetDevicePlayerIndex, ANDROID_JoystickSetDevicePlayerIndex, ANDROID_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/android/SDL_sysjoystick_c.h b/vs/sdl2/src/joystick/android/SDL_sysjoystick_c.h index aa96f87366..189bcf4b38 100644 --- a/vs/sdl2/src/joystick/android/SDL_sysjoystick_c.h +++ b/vs/sdl2/src/joystick/android/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/bsd/SDL_bsdjoystick.c b/vs/sdl2/src/joystick/bsd/SDL_bsdjoystick.c index 90a7f39591..3886fbfbb6 100644 --- a/vs/sdl2/src/joystick/bsd/SDL_bsdjoystick.c +++ b/vs/sdl2/src/joystick/bsd/SDL_bsdjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_HAVE_MACHINE_JOYSTICK_H +#ifdef SDL_HAVE_MACHINE_JOYSTICK_H #include #endif @@ -298,7 +298,7 @@ CreateHwData(const char *path) hw = (struct joystick_hwdata *) SDL_calloc(1, sizeof(struct joystick_hwdata)); - if (hw == NULL) { + if (!hw) { close(fd); SDL_OutOfMemory(); return NULL; @@ -321,7 +321,7 @@ CreateHwData(const char *path) } } hw->repdesc = hid_get_report_desc(fd); - if (hw->repdesc == NULL) { + if (!hw->repdesc) { SDL_SetError("%s: USB_GET_REPORT_DESC: %s", path, strerror(errno)); goto usberr; @@ -348,7 +348,7 @@ CreateHwData(const char *path) #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { SDL_SetError("%s: Cannot start HID parser", path); goto usberr; } @@ -428,7 +428,7 @@ static int MaybeAddDevice(const char *path) SDL_joylist_item *item; struct joystick_hwdata *hw; - if (path == NULL) { + if (!path) { return -1; } @@ -437,14 +437,14 @@ static int MaybeAddDevice(const char *path) } /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { return -1; /* already have this one */ } } hw = CreateHwData(path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -456,7 +456,7 @@ static int MaybeAddDevice(const char *path) struct usb_device_info di; if (ioctl(hw->fd, USB_GET_DEVICEINFO, &di) != -1) { name = SDL_CreateJoystickName(di.udi_vendorNo, di.udi_productNo, di.udi_vendor, di.udi_product); - guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name, 0, 0); + guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, di.udi_vendor, di.udi_product, 0, 0); #ifdef SDL_JOYSTICK_HIDAPI if (HIDAPI_IsDevicePresent(di.udi_vendorNo, di.udi_productNo, di.udi_releaseNo, name)) { @@ -474,14 +474,14 @@ static int MaybeAddDevice(const char *path) } #endif /* USB_GET_DEVICEINFO */ } - if (name == NULL) { + if (!name) { name = SDL_strdup(path); guid = SDL_CreateJoystickGUIDForName(name); } FreeHwData(hw); item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { SDL_free(name); return -1; } @@ -491,13 +491,13 @@ static int MaybeAddDevice(const char *path) item->name = name; item->guid = guid; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return -1; } item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -574,6 +574,11 @@ static const char *BSD_JoystickGetDevicePath(int device_index) return JoystickByDevIndex(device_index)->path; } +static int BSD_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int BSD_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -613,12 +618,12 @@ static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index) SDL_joylist_item *item = JoystickByDevIndex(device_index); struct joystick_hwdata *hw; - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } hw = CreateHwData(item->path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -693,7 +698,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ continue; } @@ -782,7 +787,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) #ifdef __DragonFly__ len = hid_report_size(rd, repinfo[repind].kind, r->rid); -#elif __FREEBSD__ +#elif defined(__FREEBSD__) #if (__FreeBSD_kernel_version >= 460000) || defined(__FreeBSD_kernel__) #if (__FreeBSD_kernel_version <= 500111) len = hid_report_size(rd, r->rid, repinfo[repind].kind); @@ -812,7 +817,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + r->size); #endif - if (r->buf == NULL) { + if (!r->buf) { return SDL_OutOfMemory(); } } else { @@ -870,6 +875,7 @@ SDL_JoystickDriver SDL_BSD_JoystickDriver = { BSD_JoystickDetect, BSD_JoystickGetDeviceName, BSD_JoystickGetDevicePath, + BSD_JoystickGetDeviceSteamVirtualGamepadSlot, BSD_JoystickGetDevicePlayerIndex, BSD_JoystickSetDevicePlayerIndex, BSD_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/controller_list.h b/vs/sdl2/src/joystick/controller_list.h index c7871c25e9..fd77b2a9d5 100644 --- a/vs/sdl2/src/joystick/controller_list.h +++ b/vs/sdl2/src/joystick/controller_list.h @@ -24,6 +24,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0079, 0x1844 ), k_eControllerType_PS3Controller, NULL }, // From SDL { MAKE_CONTROLLER_ID( 0x044f, 0xb315 ), k_eControllerType_PS3Controller, NULL }, // Firestorm Dual Analog 3 { MAKE_CONTROLLER_ID( 0x044f, 0xd007 ), k_eControllerType_PS3Controller, NULL }, // Thrustmaster wireless 3-1 + { MAKE_CONTROLLER_ID( 0x046d, 0xcad1 ), k_eControllerType_PS3Controller, NULL }, // Logitech Chillstream //{ MAKE_CONTROLLER_ID( 0x046d, 0xc24f ), k_eControllerType_PS3Controller, NULL }, // Logitech G29 (PS3) { MAKE_CONTROLLER_ID( 0x054c, 0x0268 ), k_eControllerType_PS3Controller, NULL }, // Sony PS3 Controller { MAKE_CONTROLLER_ID( 0x056e, 0x200f ), k_eControllerType_PS3Controller, NULL }, // From SDL @@ -44,7 +45,6 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0e6f, 0x0109 ), k_eControllerType_PS3Controller, NULL }, // PDP Versus Fighting Pad { MAKE_CONTROLLER_ID( 0x0e6f, 0x011e ), k_eControllerType_PS3Controller, NULL }, // Rock Candy PS4 { MAKE_CONTROLLER_ID( 0x0e6f, 0x0128 ), k_eControllerType_PS3Controller, NULL }, // Rock Candy PS3 - { MAKE_CONTROLLER_ID( 0x0e6f, 0x0203 ), k_eControllerType_PS3Controller, NULL }, // Victrix Pro FS (PS4 peripheral but no trackpad/lightbar) { MAKE_CONTROLLER_ID( 0x0e6f, 0x0214 ), k_eControllerType_PS3Controller, NULL }, // afterglow ps3 { MAKE_CONTROLLER_ID( 0x0e6f, 0x1314 ), k_eControllerType_PS3Controller, NULL }, // PDP Afterglow Wireless PS3 controller { MAKE_CONTROLLER_ID( 0x0e6f, 0x6302 ), k_eControllerType_PS3Controller, NULL }, // From SDL @@ -96,7 +96,9 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x0c12, 0x0ef6 ), k_eControllerType_PS4Controller, NULL }, // Hitbox Arcade Stick { MAKE_CONTROLLER_ID( 0x0c12, 0x1cf6 ), k_eControllerType_PS4Controller, NULL }, // EMIO PS4 Elite Controller { MAKE_CONTROLLER_ID( 0x0c12, 0x1e10 ), k_eControllerType_PS4Controller, NULL }, // P4 Wired Gamepad generic knock off - lightbar but not trackpad or gyro - { MAKE_CONTROLLER_ID( 0x0e6f, 0x0207 ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro Fightstick w/ Touchpad for PS4 + { MAKE_CONTROLLER_ID( 0x0e6f, 0x0203 ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS (PS4 peripheral but no trackpad/lightbar) + { MAKE_CONTROLLER_ID( 0x0e6f, 0x0207 ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS V2 w/ Touchpad for PS4 + { MAKE_CONTROLLER_ID( 0x0e6f, 0x020a ), k_eControllerType_PS4Controller, NULL }, // Victrix Pro FS PS4/PS5 (PS4 mode) { MAKE_CONTROLLER_ID( 0x0f0d, 0x0055 ), k_eControllerType_PS4Controller, NULL }, // HORIPAD 4 FPS { MAKE_CONTROLLER_ID( 0x0f0d, 0x005e ), k_eControllerType_PS4Controller, NULL }, // HORI Fighting Commander 4 PS4 { MAKE_CONTROLLER_ID( 0x0f0d, 0x0066 ), k_eControllerType_PS4Controller, NULL }, // HORIPAD 4 FPS Plus @@ -140,6 +142,8 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x2c22, 0x2303 ), k_eControllerType_XInputPS4Controller, NULL }, // Qanba Obsidian Arcade Joystick { MAKE_CONTROLLER_ID( 0x2c22, 0x2500 ), k_eControllerType_PS4Controller, NULL }, // Qanba Dragon { MAKE_CONTROLLER_ID( 0x2c22, 0x2503 ), k_eControllerType_XInputPS4Controller, NULL }, // Qanba Dragon Arcade Joystick + { MAKE_CONTROLLER_ID( 0x3285, 0x0d16 ), k_eControllerType_PS4Controller, NULL }, // NACON Revolution 5 Pro (PS4 mode with dongle) + { MAKE_CONTROLLER_ID( 0x3285, 0x0d17 ), k_eControllerType_PS4Controller, NULL }, // NACON Revolution 5 Pro (PS4 mode wired) { MAKE_CONTROLLER_ID( 0x7545, 0x0104 ), k_eControllerType_PS4Controller, NULL }, // Armor 3 or Level Up Cobra - At least one variant has gyro { MAKE_CONTROLLER_ID (0x9886, 0x0024 ), k_eControllerType_XInputPS4Controller, NULL }, // Astro C40 in Xbox 360 mode { MAKE_CONTROLLER_ID( 0x9886, 0x0025 ), k_eControllerType_PS4Controller, NULL }, // Astro C40 @@ -148,10 +152,15 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x054c, 0x0ce6 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Controller { MAKE_CONTROLLER_ID( 0x054c, 0x0df2 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Edge Controller + { MAKE_CONTROLLER_ID( 0x054c, 0x0e5f ), k_eControllerType_PS5Controller, NULL }, // Access Controller for PS5 + { MAKE_CONTROLLER_ID( 0x0e6f, 0x0209 ), k_eControllerType_PS5Controller, NULL }, // Victrix Pro FS PS4/PS5 (PS5 mode) { MAKE_CONTROLLER_ID( 0x0f0d, 0x0163 ), k_eControllerType_PS5Controller, NULL }, // HORI Fighting Commander OCTA { MAKE_CONTROLLER_ID( 0x0f0d, 0x0184 ), k_eControllerType_PS5Controller, NULL }, // Hori Fighting Stick α { MAKE_CONTROLLER_ID( 0x1532, 0x100b ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wired) { MAKE_CONTROLLER_ID( 0x1532, 0x100c ), k_eControllerType_PS5Controller, NULL }, // Razer Wolverine V2 Pro (Wireless) + { MAKE_CONTROLLER_ID( 0x1532, 0x1012 ), k_eControllerType_PS5Controller, NULL }, // Razer Kitsune + { MAKE_CONTROLLER_ID( 0x3285, 0x0d18 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode with dongle) + { MAKE_CONTROLLER_ID( 0x3285, 0x0d19 ), k_eControllerType_PS5Controller, NULL }, // NACON Revolution 5 Pro (PS5 mode wired) { MAKE_CONTROLLER_ID( 0x358a, 0x0104 ), k_eControllerType_PS5Controller, NULL }, // Backbone One PlayStation Edition for iOS { 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 @@ -163,7 +172,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x045e, 0x028f ), k_eControllerType_XBox360Controller, "Xbox 360 Controller" }, // Microsoft X-Box 360 pad v2 { MAKE_CONTROLLER_ID( 0x045e, 0x0291 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver (XBOX) { MAKE_CONTROLLER_ID( 0x045e, 0x02a0 ), k_eControllerType_XBox360Controller, NULL }, // Microsoft X-Box 360 Big Button IR - { MAKE_CONTROLLER_ID( 0x045e, 0x02a1 ), k_eControllerType_XBox360Controller, NULL }, // Microsoft X-Box 360 Wireless Controller with XUSB driver on Windows + { MAKE_CONTROLLER_ID( 0x045e, 0x02a1 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Controller with XUSB driver on Windows { MAKE_CONTROLLER_ID( 0x045e, 0x02a9 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver (third party knockoff) { MAKE_CONTROLLER_ID( 0x045e, 0x0719 ), k_eControllerType_XBox360Controller, "Xbox 360 Wireless Controller" }, // Xbox 360 Wireless Receiver { MAKE_CONTROLLER_ID( 0x046d, 0xc21d ), k_eControllerType_XBox360Controller, NULL }, // Logitech Gamepad F310 @@ -294,6 +303,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x24c6, 0xfafd ), k_eControllerType_XBox360Controller, NULL }, // Afterglow Gamepad 3 { MAKE_CONTROLLER_ID( 0x24c6, 0xfafe ), k_eControllerType_XBox360Controller, NULL }, // Rock Candy Gamepad for Xbox 360 + { MAKE_CONTROLLER_ID( 0x03f0, 0x0495 ), k_eControllerType_XBoxOneController, NULL }, // HP HyperX Clutch Gladiate { MAKE_CONTROLLER_ID( 0x044f, 0xd012 ), k_eControllerType_XBoxOneController, NULL }, // ThrustMaster eSwap PRO Controller Xbox { MAKE_CONTROLLER_ID( 0x045e, 0x02d1 ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad { MAKE_CONTROLLER_ID( 0x045e, 0x02dd ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad (Firmware 2015) @@ -301,7 +311,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x045e, 0x02e3 ), k_eControllerType_XBoxOneController, "Xbox One Elite Controller" }, // Microsoft X-Box One Elite pad { MAKE_CONTROLLER_ID( 0x045e, 0x02ea ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft X-Box One S pad { MAKE_CONTROLLER_ID( 0x045e, 0x02fd ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft X-Box One S pad (Bluetooth) - { MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController, NULL }, // Microsoft X-Box One controller with XBOXGIP driver on Windows + { MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One controller with XBOXGIP driver on Windows { MAKE_CONTROLLER_ID( 0x045e, 0x0b00 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft X-Box One Elite Series 2 pad // { MAKE_CONTROLLER_ID( 0x045e, 0x0b02 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // The virtual keyboard generated by XboxGip drivers for Xbox One Controllers (see https://github.com/libsdl-org/SDL/pull/5121 for details) { MAKE_CONTROLLER_ID( 0x045e, 0x0b05 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft X-Box One Elite Series 2 pad (Bluetooth) @@ -585,7 +595,9 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x28de, 0x1102 ), k_eControllerType_SteamController, NULL }, // Valve wired Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1105 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G) { MAKE_CONTROLLER_ID( 0x28de, 0x1106 ), k_eControllerType_SteamController, NULL }, // Valve Bluetooth Steam Controller (D0G) + { MAKE_CONTROLLER_ID( 0x28de, 0x11ff ), k_eControllerType_UnknownNonSteamController, NULL }, // Steam Virtual Gamepad { MAKE_CONTROLLER_ID( 0x28de, 0x1142 ), k_eControllerType_SteamController, NULL }, // Valve wireless Steam Controller { MAKE_CONTROLLER_ID( 0x28de, 0x1201 ), k_eControllerType_SteamControllerV2, NULL }, // Valve wired Steam Controller (HEADCRAB) { MAKE_CONTROLLER_ID( 0x28de, 0x1202 ), k_eControllerType_SteamControllerV2, NULL }, // Valve Bluetooth Steam Controller (HEADCRAB) + { MAKE_CONTROLLER_ID( 0x28de, 0x1205 ), k_eControllerType_SteamDeck, NULL }, // Valve Steam Deck Builtin Controller }; diff --git a/vs/sdl2/src/joystick/controller_type.h b/vs/sdl2/src/joystick/controller_type.h index 9ec6c57ee1..ead45f1096 100644 --- a/vs/sdl2/src/joystick/controller_type.h +++ b/vs/sdl2/src/joystick/controller_type.h @@ -37,6 +37,7 @@ typedef enum k_eControllerType_UnknownSteamController = 1, k_eControllerType_SteamController = 2, k_eControllerType_SteamControllerV2 = 3, + k_eControllerType_SteamDeck = 4, // Other Controllers k_eControllerType_UnknownNonSteamController = 30, diff --git a/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick.c b/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick.c index 0ac9b5061f..493f81640c 100644 --- a/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick.c +++ b/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +42,7 @@ static recDevice *gpDeviceList = NULL; void FreeRumbleEffectData(FFEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -58,7 +58,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -82,7 +82,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= FFEFF_CARTESIAN; periodic = (FFPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -237,7 +237,7 @@ static void JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *s device->ffdevice = NULL; device->ff_initialized = SDL_FALSE; } -#if SDL_HAPTIC_IOKIT +#ifdef SDL_HAPTIC_IOKIT MacHaptic_MaybeRemoveDevice(device->ffservice); #endif @@ -407,6 +407,19 @@ static void AddHIDElement(const void *value, void *parameter) } } +static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const char *product_string) +{ + int slot = -1; + + if (vendor_id == USB_VENDOR_MICROSOFT && product_id == USB_PRODUCT_XBOX360_WIRED_CONTROLLER) { + /* Gamepad name is "GamePad-N", where N is slot + 1 */ + if (SDL_sscanf(product_string, "GamePad-%d", &slot) == 1) { + slot -= 1; + } + } + return slot; +} + static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) { Sint32 vendor = 0; @@ -486,7 +499,8 @@ static SDL_bool GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice) } #endif - pDevice->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, (Uint16)vendor, (Uint16)product, (Uint16)version, pDevice->product, 0, 0); + pDevice->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, (Uint16)vendor, (Uint16)product, (Uint16)version, manufacturer_string, product_string, 0, 0); + pDevice->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot((Uint16)vendor, (Uint16)product, product_string); array = IOHIDDeviceCopyMatchingElements(hidDevice, NULL, kIOHIDOptionsTypeNone); if (array) { @@ -508,7 +522,7 @@ static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) } #endif - for (i = gpDeviceList; i != NULL; i = i->pNext) { + for (i = gpDeviceList; i; i = i->pNext) { if (i->deviceRef == ioHIDDeviceObject) { return SDL_TRUE; } @@ -530,7 +544,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } device = (recDevice *)SDL_calloc(1, sizeof(recDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return; } @@ -557,19 +571,19 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender ioservice = IOHIDDeviceGetService(ioHIDDeviceObject); if ((ioservice) && (FFIsForceFeedback(ioservice) == FF_OK)) { device->ffservice = ioservice; -#if SDL_HAPTIC_IOKIT +#ifdef SDL_HAPTIC_IOKIT MacHaptic_MaybeAddDevice(ioservice); #endif } /* Add device to the end of the list */ - if (gpDeviceList == NULL) { + if (!gpDeviceList) { gpDeviceList = device; } else { recDevice *curdevice; curdevice = gpDeviceList; - while (curdevice->pNext != NULL) { + while (curdevice->pNext) { curdevice = curdevice->pNext; } curdevice->pNext = device; @@ -657,8 +671,8 @@ static SDL_bool CreateHIDManager(void) static int DARWIN_JoystickInit(void) { - if (gpDeviceList) { - return SDL_SetError("Joystick: Device list already inited."); + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_IOKIT, SDL_TRUE)) { + return 0; } if (!CreateHIDManager()) { @@ -694,10 +708,12 @@ static void DARWIN_JoystickDetect(void) } } - /* run this after the checks above so we don't set device->removed and delete the device before - DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ - while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { - /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ + if (hidman) { + /* run this after the checks above so we don't set device->removed and delete the device before + DARWIN_JoystickUpdate can run to clean up the SDL_Joystick object that owns this device */ + while (CFRunLoopRunInMode(SDL_JOYSTICK_RUNLOOP_MODE, 0, TRUE) == kCFRunLoopRunHandledSource) { + /* no-op. Pending callbacks will fire in CFRunLoopRunInMode(). */ + } } } @@ -712,6 +728,12 @@ const char *DARWIN_JoystickGetDevicePath(int device_index) return NULL; } +static int DARWIN_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + recDevice *device = GetDeviceForIndex(device_index); + return device ? device->steam_virtual_gamepad_slot : -1; +} + static int DARWIN_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -854,7 +876,7 @@ static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ru /* Scale and average the two rumble strengths */ Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); - if (device == NULL) { + if (!device) { return SDL_SetError("Rumble failed, device disconnected"); } @@ -895,7 +917,7 @@ static Uint32 DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) recDevice *device = joystick->hwdata; Uint32 result = 0; - if (device == NULL) { + if (!device) { return 0; } @@ -928,7 +950,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick) SInt32 value, range; int i, goodRead = SDL_FALSE; - if (device == NULL) { + if (!device) { return; } @@ -1057,6 +1079,7 @@ SDL_JoystickDriver SDL_DARWIN_JoystickDriver = { DARWIN_JoystickDetect, DARWIN_JoystickGetDeviceName, DARWIN_JoystickGetDevicePath, + DARWIN_JoystickGetDeviceSteamVirtualGamepadSlot, DARWIN_JoystickGetDevicePlayerIndex, DARWIN_JoystickSetDevicePlayerIndex, DARWIN_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick_c.h b/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick_c.h index aec255072d..095c083221 100644 --- a/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick_c.h +++ b/vs/sdl2/src/joystick/darwin/SDL_iokitjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,6 +71,7 @@ struct joystick_hwdata int instance_id; SDL_JoystickGUID guid; + int steam_virtual_gamepad_slot; struct joystick_hwdata *pNext; /* next device */ }; diff --git a/vs/sdl2/src/joystick/dummy/SDL_sysjoystick.c b/vs/sdl2/src/joystick/dummy/SDL_sysjoystick.c index bf1284d616..1ade8e1b5b 100644 --- a/vs/sdl2/src/joystick/dummy/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/dummy/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +52,11 @@ static const char *DUMMY_JoystickGetDevicePath(int device_index) return NULL; } +static int DUMMY_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int DUMMY_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -131,6 +136,7 @@ SDL_JoystickDriver SDL_DUMMY_JoystickDriver = { DUMMY_JoystickDetect, DUMMY_JoystickGetDeviceName, DUMMY_JoystickGetDevicePath, + DUMMY_JoystickGetDeviceSteamVirtualGamepadSlot, DUMMY_JoystickGetDevicePlayerIndex, DUMMY_JoystickSetDevicePlayerIndex, DUMMY_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick.c b/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick.c index 81544fd4ec..a2db803ff7 100644 --- a/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 @@ static SDL_joylist_item *JoystickByIndex(int index); static SDL_joylist_item *SDL_joylist = NULL; static SDL_joylist_item *SDL_joylist_tail = NULL; static int numjoysticks = 0; -static int instance_counter = 0; static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamepadEvent *gamepadEvent, void *userData) { @@ -50,7 +49,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return 1; } @@ -58,13 +57,13 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->index = gamepadEvent->index; item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); return 1; } item->mapping = SDL_strdup(gamepadEvent->mapping); - if (item->mapping == NULL) { + if (!item->mapping) { SDL_free(item->name); SDL_free(item); return 1; @@ -72,7 +71,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->naxes = gamepadEvent->numAxes; item->nbuttons = gamepadEvent->numButtons; - item->device_instance = instance_counter++; + item->device_instance = SDL_GetNextJoystickInstanceID(); item->timestamp = gamepadEvent->timestamp; @@ -85,7 +84,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->digitalButton[i] = gamepadEvent->digitalButton[i]; } - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -112,7 +111,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; - while (item != NULL) { + while (item) { if (item->index == gamepadEvent->index) { break; } @@ -120,7 +119,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item = item->next; } - if (item == NULL) { + if (!item) { return 1; } @@ -128,7 +127,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -168,7 +167,6 @@ static void EMSCRIPTEN_JoystickQuit(void) SDL_joylist = SDL_joylist_tail = NULL; numjoysticks = 0; - instance_counter = 0; emscripten_set_gamepadconnected_callback(NULL, 0, NULL); emscripten_set_gamepaddisconnected_callback(NULL, 0, NULL); @@ -247,7 +245,7 @@ static SDL_joylist_item *JoystickByIndex(int index) return NULL; } - while (item != NULL) { + while (item) { if (item->index == index) { break; } @@ -276,6 +274,11 @@ static const char *EMSCRIPTEN_JoystickGetDevicePath(int device_index) return NULL; } +static int EMSCRIPTEN_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int EMSCRIPTEN_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -299,11 +302,11 @@ static int EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDeviceIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } @@ -423,6 +426,7 @@ SDL_JoystickDriver SDL_EMSCRIPTEN_JoystickDriver = { EMSCRIPTEN_JoystickDetect, EMSCRIPTEN_JoystickGetDeviceName, EMSCRIPTEN_JoystickGetDevicePath, + EMSCRIPTEN_JoystickGetDeviceSteamVirtualGamepadSlot, EMSCRIPTEN_JoystickGetDevicePlayerIndex, EMSCRIPTEN_JoystickSetDevicePlayerIndex, EMSCRIPTEN_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick_c.h b/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick_c.h index c9a2674cdf..6e9b64948c 100644 --- a/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick_c.h +++ b/vs/sdl2/src/joystick/emscripten/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/haiku/SDL_haikujoystick.cc b/vs/sdl2/src/joystick/haiku/SDL_haikujoystick.cc index 37e89c3345..5c313636fe 100644 --- a/vs/sdl2/src/joystick/haiku/SDL_haikujoystick.cc +++ b/vs/sdl2/src/joystick/haiku/SDL_haikujoystick.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -102,6 +102,11 @@ extern "C" return SDL_joyport[device_index]; } + static int HAIKU_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) + { + return -1; + } + static int HAIKU_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -299,6 +304,7 @@ extern "C" HAIKU_JoystickDetect, HAIKU_JoystickGetDeviceName, HAIKU_JoystickGetDevicePath, + HAIKU_JoystickGetDeviceSteamVirtualGamepadSlot, HAIKU_JoystickGetDevicePlayerIndex, HAIKU_JoystickSetDevicePlayerIndex, HAIKU_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_combined.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_combined.c index ccf1662a8a..94ab75c1d9 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_combined.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_combined.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_gamecube.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_gamecube.c index b4c7e694c7..53d40b92b9 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +78,9 @@ static SDL_bool HIDAPI_DriverGameCube_IsSupportedDevice(SDL_HIDAPI_Device *devic /* Nintendo Co., Ltd. Wii U GameCube Controller Adapter */ return SDL_TRUE; } - if (vendor_id == USB_VENDOR_DRAGONRISE && product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER) { + if (vendor_id == USB_VENDOR_DRAGONRISE && + (product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 || + product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2)) { /* EVORETRO GameCube Controller Adapter */ return SDL_TRUE; } @@ -140,7 +142,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) #endif ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -249,7 +251,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device } joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); - if (joystick == NULL) { + if (!joystick) { /* Hasn't been opened yet, skip */ return; } @@ -288,8 +290,8 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device 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(4, SDL_CONTROLLER_AXIS_LEFTY, 1) + READ_AXIS(6, SDL_CONTROLLER_AXIS_RIGHTX, 0) READ_AXIS(5, SDL_CONTROLLER_AXIS_RIGHTY, 1) READ_AXIS(7, SDL_CONTROLLER_AXIS_TRIGGERLEFT, 0) READ_AXIS(8, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, 0) @@ -323,7 +325,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); /* Hasn't been opened yet, skip */ - if (joystick == NULL) { + if (!joystick) { continue; } } else { @@ -340,8 +342,8 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device 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, 0x02, 1) /* B */ + READ_BUTTON(1, 0x04, 2) /* X */ READ_BUTTON(1, 0x08, 3) /* Y */ READ_BUTTON(1, 0x10, 4) /* DPAD_LEFT */ READ_BUTTON(1, 0x20, 5) /* DPAD_RIGHT */ @@ -385,7 +387,7 @@ static SDL_bool HIDAPI_DriverGameCube_UpdateDevice(SDL_HIDAPI_Device *device) /* Read input packet */ while ((size = SDL_hid_read_timeout(device->dev, packet, sizeof(packet), 0)) > 0) { #ifdef DEBUG_GAMECUBE_PROTOCOL - // HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); + HIDAPI_DumpPacket("Nintendo GameCube packet: size = %d", packet, size); #endif if (ctx->pc_mode) { HIDAPI_DriverGameCube_HandleJoystickPacket(device, ctx, packet, size); diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_luna.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_luna.c index 7eb44c72a9..e5557c5982 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_luna.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +75,7 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverLuna_Context *ctx; ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -393,7 +393,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_LUNA_PROTOCOL HIDAPI_DumpPacket("Amazon Luna packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_nintendo.h b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_nintendo.h index 9b9a667169..bd8459a420 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_nintendo.h +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_nintendo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps3.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps3.c index d5e00babc4..1b10e9ffba 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -139,7 +139,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) } ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -220,7 +220,7 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } @@ -494,7 +494,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } @@ -584,7 +584,13 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_IsSupportedDevice(SDL_HIDAPI_Device * Uint8 data[USB_PACKET_LENGTH]; int size; - if (HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { + if (vendor_id == USB_VENDOR_LOGITECH && + product_id == USB_PRODUCT_LOGITECH_CHILLSTREAM) { + return SDL_TRUE; + } + + if ((type == SDL_CONTROLLER_TYPE_PS3 && vendor_id != USB_VENDOR_SONY) || + HIDAPI_SupportsPlaystationDetection(vendor_id, product_id)) { if (device && device->dev) { size = ReadFeatureReport(device->dev, 0x03, data, sizeof(data)); if (size == 8 && data[2] == 0x26) { @@ -606,7 +612,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverPS3_Context *ctx; ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -768,7 +774,7 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket18(SDL_Joystick *joystic 0, /* SDL_GAMEPAD_BUTTON_LEFT_STICK */ 0, /* SDL_GAMEPAD_BUTTON_RIGHT_STICK */ 14, /* SDL_GAMEPAD_BUTTON_LEFT_SHOULDER */ - 16, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ + 15, /* SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER */ 8, /* SDL_GAMEPAD_BUTTON_DPAD_UP */ 9, /* SDL_GAMEPAD_BUTTON_DPAD_DOWN */ 7, /* SDL_GAMEPAD_BUTTON_DPAD_LEFT */ @@ -813,48 +819,56 @@ static void HIDAPI_DriverPS3ThirdParty_HandleStatePacket19(SDL_Joystick *joystic SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, (data[1] & 0x10) ? SDL_PRESSED : SDL_RELEASED); } - if (ctx->last_state[2] != data[2]) { - 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[2] & 0x0f) { - 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; + if (ctx->device->vendor_id == USB_VENDOR_SAITEK && ctx->device->product_id == USB_PRODUCT_SAITEK_CYBORG_V3) { + /* Cyborg V.3 Rumble Pad doesn't set the dpad bits as expected, so use the axes instead */ + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, data[10] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, data[9] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, data[7] ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, data[8] ? SDL_PRESSED : SDL_RELEASED); + } else { + if (ctx->last_state[2] != data[2]) { + 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[2] & 0x0f) { + 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); } - 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); } axis = ((int)data[17] * 257) - 32768; @@ -924,7 +938,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps4.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps4.c index 68dfc01646..565431d838 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +128,7 @@ typedef struct SDL_HIDAPI_Device *device; SDL_Joystick *joystick; SDL_bool is_dongle; + SDL_bool is_nacon_dongle; SDL_bool official_controller; SDL_bool sensors_supported; SDL_bool lightbar_supported; @@ -243,7 +244,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -401,8 +402,14 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) } ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported); + if (device->vendor_id == USB_VENDOR_NACON_ALT && + device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS4_WIRELESS) { + ctx->is_nacon_dongle = SDL_TRUE; + } + if (device->vendor_id == USB_VENDOR_PDP && - device->product_id == USB_PRODUCT_VICTRIX_FS_PRO_V2) { + (device->product_id == USB_PRODUCT_VICTRIX_FS_PRO || + device->product_id == USB_PRODUCT_VICTRIX_FS_PRO_V2)) { /* The Victrix FS Pro V2 reports that it has lightbar support, * but it doesn't respond to the effects packet, and will hang * on reboot if we send it. @@ -425,7 +432,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) } else { HIDAPI_DisconnectBluetoothDevice(device->serial); } - if (ctx->is_dongle && serial[0] == '\0') { + if ((ctx->is_dongle || ctx->is_nacon_dongle) && serial[0] == '\0') { /* Not yet connected */ return SDL_TRUE; } @@ -677,10 +684,14 @@ static void HIDAPI_DriverPS4_TickleBluetooth(SDL_HIDAPI_Device *device) SDL_HIDAPI_SendRumbleAndUnlock(device, data, sizeof(data)); } } else { +#if 0 /* The 8BitDo Zero 2 has perfect emulation of a PS4 controllers, except it + * only sends reports when the state changes, so we can't disconnect here. + */ /* We can't even send an invalid effects packet, or it will put the controller in enhanced mode */ if (device->num_joysticks > 0) { HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } +#endif } } @@ -1080,6 +1091,21 @@ static SDL_bool HIDAPI_DriverPS4_IsPacketValid(SDL_DriverPS4_Context *ctx, Uint8 return SDL_TRUE; } + if (ctx->is_nacon_dongle && size >= (1 + sizeof(PS4StatePacket_t))) { + /* The report timestamp doesn't change when the controller isn't connected */ + PS4StatePacket_t *packet = (PS4StatePacket_t *)&data[1]; + if (SDL_memcmp(packet->rgucTimestamp, ctx->last_state.rgucTimestamp, sizeof(packet->rgucTimestamp)) == 0) { + return SDL_FALSE; + } + if (ctx->last_state.rgucAccelX[0] == 0 && ctx->last_state.rgucAccelX[1] == 0 && + ctx->last_state.rgucAccelY[0] == 0 && ctx->last_state.rgucAccelY[1] == 0 && + ctx->last_state.rgucAccelZ[0] == 0 && ctx->last_state.rgucAccelZ[1] == 0) { + /* We don't have any state to compare yet, go ahead and copy it */ + SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS4StatePacket_t)); + return SDL_FALSE; + } + } + /* In the case of a DS4 USB dongle, bit[2] of byte 31 indicates if a DS4 is actually connected (indicated by '0'). * For non-dongle, this bit is always 0 (connected). * This is usually the ID over USB, but the DS4v2 that started shipping with the PS4 Slim will also send this @@ -1144,7 +1170,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } @@ -1192,7 +1218,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) } } - if (ctx->is_dongle) { + if (ctx->is_dongle || ctx->is_nacon_dongle) { if (packet_count == 0) { if (device->num_joysticks > 0) { /* Check to see if it looks like the device disconnected */ @@ -1214,7 +1240,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) } } - if (size < 0 && device->num_joysticks > 0) { + if (packet_count == 0 && size < 0 && device->num_joysticks > 0) { /* Read error, device is disconnected */ HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps5.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps5.c index 0716c62ece..dfdbc81201 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -102,7 +102,7 @@ typedef struct Uint8 rgucAccelX[2]; /* 21 */ Uint8 rgucAccelY[2]; /* 23 */ Uint8 rgucAccelZ[2]; /* 25 */ - Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ + Uint8 rgucSensorTimestamp[4]; /* 27 - 16/32 bit little endian */ } PS5StatePacketCommon_t; @@ -154,7 +154,9 @@ typedef struct Uint8 rgucAccelX[2]; /* 21 */ Uint8 rgucAccelY[2]; /* 23 */ Uint8 rgucAccelZ[2]; /* 25 */ - Uint8 rgucSensorTimestamp[4]; /* 27 - 32 bit little endian */ + Uint8 rgucSensorTimestamp[2]; /* 27 - 16 bit little endian */ + Uint8 ucBatteryLevel; /* 29 */ + Uint8 ucUnknown; /* 30 */ Uint8 ucTouchpadCounter1; /* 31 - high bit clear + counter */ Uint8 rgucTouchpadData1[3]; /* 32 - X/Y, 12 bits per axis */ Uint8 ucTouchpadCounter2; /* 35 - high bit clear + counter */ @@ -215,6 +217,7 @@ typedef struct { SDL_HIDAPI_Device *device; SDL_Joystick *joystick; + SDL_bool is_nacon_dongle; SDL_bool use_alternate_report; SDL_bool sensors_supported; SDL_bool lightbar_supported; @@ -244,6 +247,7 @@ typedef struct { PS5SimpleStatePacket_t simple; PS5StatePacketCommon_t state; + PS5StatePacketAlt_t alt_state; PS5StatePacket_t full_state; Uint8 data[64]; } last_state; @@ -331,7 +335,8 @@ static void SetLightsForPlayerIndex(DS5EffectsState_t *effects, int player_index 0x04, 0x0A, 0x15, - 0x1B + 0x1B, + 0x1F }; if (player_index >= 0) { @@ -352,7 +357,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -480,16 +485,35 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) } ctx->use_alternate_report = SDL_TRUE; + + if (device->vendor_id == USB_VENDOR_NACON_ALT && + (device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRED || + device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS)) { + /* This doesn't report vibration capability, but it can do rumble */ + ctx->vibration_supported = SDL_TRUE; + } } else if (device->vendor_id == USB_VENDOR_RAZER && (device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRED || device->product_id == USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS)) { - /* The Razer Wolverine V2 Pro doesn't respond to the detection protocol, but has a touchpad and sensors, but no vibration */ + /* The Razer Wolverine V2 Pro doesn't respond to the detection protocol, but has a touchpad and sensors and no vibration */ ctx->sensors_supported = SDL_TRUE; ctx->touchpad_supported = SDL_TRUE; + ctx->use_alternate_report = SDL_TRUE; + } else if (device->vendor_id == USB_VENDOR_RAZER && + device->product_id == USB_PRODUCT_RAZER_KITSUNE) { + /* The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad */ + joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK; + ctx->touchpad_supported = SDL_TRUE; + ctx->use_alternate_report = SDL_TRUE; } } ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported || ctx->playerled_supported); + if (device->vendor_id == USB_VENDOR_NACON_ALT && + device->product_id == USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS) { + ctx->is_nacon_dongle = SDL_TRUE; + } + device->joystick_type = joystick_type; device->type = SDL_CONTROLLER_TYPE_PS5; if (device->vendor_id == USB_VENDOR_SONY) { @@ -501,6 +525,11 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) } HIDAPI_SetDeviceSerial(device, serial); + if (ctx->is_nacon_dongle) { + /* We don't know if this is connected yet, wait for reports */ + return SDL_TRUE; + } + /* Prefer the USB device over the Bluetooth device */ if (device->is_bluetooth) { if (HIDAPI_HasConnectedUSBDevice(device->serial)) { @@ -720,7 +749,7 @@ static void HIDAPI_DriverPS5_CheckPendingLEDReset(SDL_HIDAPI_Device *device) SDL_DriverPS5_Context *ctx = (SDL_DriverPS5_Context *)device->context; SDL_bool led_reset_complete = SDL_FALSE; - if (ctx->sensors_supported) { + if (ctx->enhanced_mode && ctx->sensors_supported && !ctx->use_alternate_report) { const PS5StatePacketCommon_t *packet = &ctx->last_state.state; /* Check the timer to make sure the Bluetooth connection LED animation is complete */ @@ -1228,30 +1257,56 @@ static void HIDAPI_DriverPS5_HandleStatePacketCommon(SDL_Joystick *joystick, SDL SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, axis); if (ctx->report_sensors) { - Uint32 timestamp; - Uint64 timestamp_us; float data[3]; + Uint64 timestamp_us; + + if (ctx->use_alternate_report) { + /* 16-bit timestamp */ + Uint16 timestamp; - timestamp = LOAD32(packet->rgucSensorTimestamp[0], - packet->rgucSensorTimestamp[1], - packet->rgucSensorTimestamp[2], - packet->rgucSensorTimestamp[3]); - if (ctx->timestamp) { - Uint32 delta; + timestamp = LOAD16(packet->rgucSensorTimestamp[0], + packet->rgucSensorTimestamp[1]); + if (ctx->timestamp) { + Uint16 delta; - if (ctx->last_timestamp > timestamp) { - delta = (SDL_MAX_UINT32 - ctx->last_timestamp + timestamp + 1); + if (ctx->last_timestamp > timestamp) { + delta = (SDL_MAX_UINT16 - ctx->last_timestamp + timestamp + 1); + } else { + delta = (timestamp - ctx->last_timestamp); + } + ctx->timestamp += delta; } else { - delta = (timestamp - ctx->last_timestamp); + ctx->timestamp = timestamp; } - ctx->timestamp += delta; + ctx->last_timestamp = timestamp; + + /* Sensor timestamp is in 1us units */ + timestamp_us = ctx->timestamp; } else { - ctx->timestamp = timestamp; - } - ctx->last_timestamp = timestamp; + /* 32-bit timestamp */ + Uint32 timestamp; + + timestamp = LOAD32(packet->rgucSensorTimestamp[0], + packet->rgucSensorTimestamp[1], + packet->rgucSensorTimestamp[2], + packet->rgucSensorTimestamp[3]); + if (ctx->timestamp) { + Uint32 delta; + + if (ctx->last_timestamp > timestamp) { + delta = (SDL_MAX_UINT32 - ctx->last_timestamp + timestamp + 1); + } else { + delta = (timestamp - ctx->last_timestamp); + } + ctx->timestamp += delta; + } else { + ctx->timestamp = timestamp; + } + ctx->last_timestamp = timestamp; - /* Sensor timestamp is in 0.33us units */ - timestamp_us = ctx->timestamp / 3; + /* Sensor timestamp is in 0.33us units */ + timestamp_us = ctx->timestamp / 3; + } data[0] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 0, LOAD16(packet->rgucGyroX[0], packet->rgucGyroX[1])); data[1] = HIDAPI_DriverPS5_ApplyCalibrationData(ctx, 1, LOAD16(packet->rgucGyroY[0], packet->rgucGyroY[1])); @@ -1348,6 +1403,20 @@ static SDL_bool HIDAPI_DriverPS5_IsPacketValid(SDL_DriverPS5_Context *ctx, Uint8 { switch (data[0]) { case k_EPS5ReportIdState: + if (ctx->is_nacon_dongle && size >= (1 + sizeof(PS5StatePacketAlt_t))) { + /* The report timestamp doesn't change when the controller isn't connected */ + PS5StatePacketAlt_t *packet = (PS5StatePacketAlt_t *)&data[1]; + if (SDL_memcmp(packet->rgucPacketSequence, ctx->last_state.state.rgucPacketSequence, sizeof(packet->rgucPacketSequence)) == 0) { + return SDL_FALSE; + } + if (ctx->last_state.alt_state.rgucAccelX[0] == 0 && ctx->last_state.alt_state.rgucAccelX[1] == 0 && + ctx->last_state.alt_state.rgucAccelY[0] == 0 && ctx->last_state.alt_state.rgucAccelY[1] == 0 && + ctx->last_state.alt_state.rgucAccelZ[0] == 0 && ctx->last_state.alt_state.rgucAccelZ[1] == 0) { + /* We don't have any state to compare yet, go ahead and copy it */ + SDL_memcpy(&ctx->last_state, &data[1], sizeof(PS5StatePacketAlt_t)); + return SDL_FALSE; + } + } return SDL_TRUE; case k_EPS5ReportIdBluetoothState: @@ -1385,7 +1454,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } @@ -1441,7 +1510,22 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) } } - if (size < 0 && device->num_joysticks > 0) { + if (ctx->is_nacon_dongle) { + if (packet_count == 0) { + if (device->num_joysticks > 0) { + /* Check to see if it looks like the device disconnected */ + if (SDL_TICKS_PASSED(now, ctx->last_packet + BLUETOOTH_DISCONNECT_TIMEOUT_MS)) { + HIDAPI_JoystickDisconnected(device, device->joysticks[0]); + } + } + } else { + if (device->num_joysticks == 0) { + HIDAPI_JoystickConnected(device, NULL); + } + } + } + + if (packet_count == 0 && size < 0 && device->num_joysticks > 0) { /* Read error, device is disconnected */ HIDAPI_JoystickDisconnected(device, device->joysticks[0]); } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.c index d045079499..2bb166e130 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -216,7 +216,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const } request = (SDL_HIDAPI_RumbleRequest *)SDL_calloc(1, sizeof(*request)); - if (request == NULL) { + if (!request) { SDL_HIDAPI_UnlockRumble(); return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.h b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.h index 120d51f2da..918e08c91f 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.h +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_rumble.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_shield.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_shield.c index 33a2066275..63540e65eb 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_shield.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +118,7 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverShield_Context *ctx; ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -489,7 +489,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) /* Byte 0 is HID report ID */ switch (data[0]) { case k_ShieldReportIdControllerState: - if (joystick == NULL) { + if (!joystick) { break; } if (size == 16) { @@ -499,7 +499,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) } break; case k_ShieldReportIdControllerTouch: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size); diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_stadia.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_stadia.c index 0cdb4f41ca..0fc6d1486c 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +72,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverStadia_Context *ctx; ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -288,7 +288,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_STADIA_PROTOCOL HIDAPI_DumpPacket("Google Stadia packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steam.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steam.c index 046c0ce81c..9f9e0e3420 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steam.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,29 +33,24 @@ /*****************************************************************************************************/ -#include - #define bool SDL_bool #define true SDL_TRUE #define false SDL_FALSE -typedef uint32_t uint32; -typedef uint64_t uint64; - #include "steam/controller_constants.h" #include "steam/controller_structs.h" typedef struct SteamControllerStateInternal_t { // Controller Type for this Controller State - uint32 eControllerType; + Uint32 eControllerType; // If packet num matches that on your prior call, then the controller state hasn't been changed since // your last call and there is no need to process it - uint32 unPacketNum; + Uint32 unPacketNum; // bit flags for each of the buttons - uint64 ulButtons; + Uint64 ulButtons; // Left pad coordinates short sLeftPadX; @@ -977,7 +972,7 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSteam_Context *ctx; ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1074,9 +1069,9 @@ static int HIDAPI_DriverSteam_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_J SDL_memset(buf, 0, 65); buf[1] = ID_SET_SETTINGS_VALUES; if (enabled) { - ADD_SETTING(SETTING_GYRO_MODE, 0x18 /* SETTING_GYRO_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO */); + ADD_SETTING(SETTING_IMU_MODE, SETTING_GYRO_MODE_SEND_RAW_ACCEL | SETTING_GYRO_MODE_SEND_RAW_GYRO); } else { - ADD_SETTING(SETTING_GYRO_MODE, 0x00 /* SETTING_GYRO_MODE_OFF */); + ADD_SETTING(SETTING_IMU_MODE, SETTING_GYRO_MODE_OFF); } buf[2] = nSettings * 3; if (SetFeatureReport(device->dev, buf, 3 + nSettings * 3) < 0) { @@ -1109,7 +1104,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) break; } - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steamdeck.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steamdeck.c new file mode 100644 index 0000000000..c26b3e6db4 --- /dev/null +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_steamdeck.c @@ -0,0 +1,425 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2023 Max Maisel + + 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_sysjoystick.h" +#include "SDL_events.h" +#include "SDL_hidapijoystick_c.h" + +#ifdef SDL_JOYSTICK_HIDAPI_STEAMDECK + +/*****************************************************************************************************/ + +#include "steam/controller_constants.h" +#include "steam/controller_structs.h" + +typedef enum +{ + STEAMDECK_LBUTTON_R2 = 0x00000001, + STEAMDECK_LBUTTON_L2 = 0x00000002, + STEAMDECK_LBUTTON_R = 0x00000004, + STEAMDECK_LBUTTON_L = 0x00000008, + STEAMDECK_LBUTTON_Y = 0x00000010, + STEAMDECK_LBUTTON_B = 0x00000020, + STEAMDECK_LBUTTON_X = 0x00000040, + STEAMDECK_LBUTTON_A = 0x00000080, + STEAMDECK_LBUTTON_DPAD_UP = 0x00000100, + STEAMDECK_LBUTTON_DPAD_RIGHT = 0x00000200, + STEAMDECK_LBUTTON_DPAD_LEFT = 0x00000400, + STEAMDECK_LBUTTON_DPAD_DOWN = 0x00000800, + STEAMDECK_LBUTTON_VIEW = 0x00001000, + STEAMDECK_LBUTTON_STEAM = 0x00002000, + STEAMDECK_LBUTTON_MENU = 0x00004000, + STEAMDECK_LBUTTON_L5 = 0x00008000, + STEAMDECK_LBUTTON_R5 = 0x00010000, + STEAMDECK_LBUTTON_LEFT_PAD = 0x00020000, + STEAMDECK_LBUTTON_RIGHT_PAD = 0x00040000, + STEAMDECK_LBUTTON_L3 = 0x00400000, + STEAMDECK_LBUTTON_R3 = 0x04000000, + + STEAMDECK_HBUTTON_L4 = 0x00000200, + STEAMDECK_HBUTTON_R4 = 0x00000400, + STEAMDECK_HBUTTON_QAM = 0x00040000, +} SteamDeckButtons; + +typedef struct +{ + Uint32 update_rate_us; + Uint32 sensor_timestamp_us; + Uint64 last_button_state; + Uint8 watchdog_counter; +} SDL_DriverSteamDeck_Context; + +static SDL_bool DisableDeckLizardMode(SDL_hid_device *dev) +{ + int rc; + Uint8 buffer[HID_FEATURE_REPORT_BYTES + 1] = { 0 }; + FeatureReportMsg *msg = (FeatureReportMsg *)(buffer + 1); + + msg->header.type = ID_CLEAR_DIGITAL_MAPPINGS; + + rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); + if (rc != sizeof(buffer)) + return SDL_FALSE; + + msg->header.type = ID_SET_SETTINGS_VALUES; + msg->header.length = 5 * sizeof(ControllerSetting); + msg->payload.setSettingsValues.settings[0].settingNum = SETTING_SMOOTH_ABSOLUTE_MOUSE; + msg->payload.setSettingsValues.settings[0].settingValue = 0; + msg->payload.setSettingsValues.settings[1].settingNum = SETTING_LEFT_TRACKPAD_MODE; + msg->payload.setSettingsValues.settings[1].settingValue = TRACKPAD_NONE; + msg->payload.setSettingsValues.settings[2].settingNum = SETTING_RIGHT_TRACKPAD_MODE; // disable mouse + msg->payload.setSettingsValues.settings[2].settingValue = TRACKPAD_NONE; + msg->payload.setSettingsValues.settings[3].settingNum = SETTING_LEFT_TRACKPAD_CLICK_PRESSURE; // disable clicky pad + msg->payload.setSettingsValues.settings[3].settingValue = 0xFFFF; + msg->payload.setSettingsValues.settings[4].settingNum = SETTING_RIGHT_TRACKPAD_CLICK_PRESSURE; // disable clicky pad + msg->payload.setSettingsValues.settings[4].settingValue = 0xFFFF; + + rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); + if (rc != sizeof(buffer)) + return SDL_FALSE; + + // There may be a lingering report read back after changing settings. + // Discard it. + SDL_hid_get_feature_report(dev, buffer, sizeof(buffer)); + + return SDL_TRUE; +} + +static SDL_bool FeedDeckLizardWatchdog(SDL_hid_device *dev) +{ + int rc; + Uint8 buffer[HID_FEATURE_REPORT_BYTES + 1] = { 0 }; + FeatureReportMsg *msg = (FeatureReportMsg *)(buffer + 1); + + msg->header.type = ID_CLEAR_DIGITAL_MAPPINGS; + + rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); + if (rc != sizeof(buffer)) + return SDL_FALSE; + + msg->header.type = ID_SET_SETTINGS_VALUES; + msg->header.length = 1 * sizeof(ControllerSetting); + msg->payload.setSettingsValues.settings[0].settingNum = SETTING_RIGHT_TRACKPAD_MODE; + msg->payload.setSettingsValues.settings[0].settingValue = TRACKPAD_NONE; + + rc = SDL_hid_send_feature_report(dev, buffer, sizeof(buffer)); + if (rc != sizeof(buffer)) + return SDL_FALSE; + + // There may be a lingering report read back after changing settings. + // Discard it. + SDL_hid_get_feature_report(dev, buffer, sizeof(buffer)); + + return SDL_TRUE; +} + +/*****************************************************************************************************/ + +static void HIDAPI_DriverSteamDeck_RegisterHints(SDL_HintCallback callback, void *userdata) +{ + SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata); +} + +static void HIDAPI_DriverSteamDeck_UnregisterHints(SDL_HintCallback callback, void *userdata) +{ + SDL_DelHintCallback(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, callback, userdata); +} + +static SDL_bool HIDAPI_DriverSteamDeck_IsEnabled(void) +{ + return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, + SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_HIDAPI_DEFAULT)); +} + +static SDL_bool HIDAPI_DriverSteamDeck_IsSupportedDevice( + SDL_HIDAPI_Device *device, + 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) +{ + return SDL_IsJoystickSteamDeck(vendor_id, product_id); +} + +static SDL_bool HIDAPI_DriverSteamDeck_InitDevice(SDL_HIDAPI_Device *device) +{ + int size; + Uint8 data[64]; + SDL_DriverSteamDeck_Context *ctx; + + ctx = (SDL_DriverSteamDeck_Context *)SDL_calloc(1, sizeof(*ctx)); + if (ctx == NULL) { + SDL_OutOfMemory(); + return SDL_FALSE; + } + + // Always 1kHz according to USB descriptor + ctx->update_rate_us = 1000; + + device->context = ctx; + + // Read a report to see if this is the correct endpoint. + // Mouse, Keyboard and Controller have the same VID/PID but + // only the controller hidraw device receives hid reports. + size = SDL_hid_read_timeout(device->dev, data, sizeof(data), 16); + if (size == 0) + return SDL_FALSE; + + if (!DisableDeckLizardMode(device->dev)) + return SDL_FALSE; + + HIDAPI_SetDeviceName(device, "Steam Deck"); + + return HIDAPI_JoystickConnected(device, NULL); +} + +static int HIDAPI_DriverSteamDeck_GetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id) +{ + return -1; +} + +static void HIDAPI_DriverSteamDeck_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL_JoystickID instance_id, int player_index) +{ +} + +static SDL_bool HIDAPI_DriverSteamDeck_UpdateDevice(SDL_HIDAPI_Device *device) +{ + SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context; + SDL_Joystick *joystick = NULL; + int r; + uint8_t data[64]; + float values[3]; + ValveInReport_t *pInReport = (ValveInReport_t *)data; + + if (device->num_joysticks > 0) { + joystick = SDL_JoystickFromInstanceID(device->joysticks[0]); + if (joystick == NULL) { + return SDL_FALSE; + } + } else { + return SDL_FALSE; + } + + if (ctx->watchdog_counter++ > 200) { + ctx->watchdog_counter = 0; + if (!FeedDeckLizardWatchdog(device->dev)) + return SDL_FALSE; + } + + SDL_memset(data, 0, sizeof(data)); + r = SDL_hid_read(device->dev, data, sizeof(data)); + if (r == 0) { + return SDL_FALSE; + } else if (r <= 0) { + /* Failed to read from controller */ + HIDAPI_JoystickDisconnected(device, device->joysticks[0]); + return SDL_FALSE; + } + + if (!(r == 64 && pInReport->header.unReportVersion == k_ValveInReportMsgVersion && pInReport->header.ucType == ID_CONTROLLER_DECK_STATE && pInReport->header.ucLength == 64)) { + return SDL_FALSE; + } + + // Uint64 timestamp = SDL_GetTicksNS(); + + if (pInReport->payload.deckState.ulButtons != ctx->last_button_state) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_A, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_A) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_B, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_B) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_X, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_X) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_Y, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_Y) ? SDL_PRESSED : SDL_RELEASED); + + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R) ? SDL_PRESSED : SDL_RELEASED); + + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_BACK, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_VIEW) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_START, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_MENU) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_GUIDE, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_STEAM) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, + (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_QAM) ? SDL_PRESSED : SDL_RELEASED); + + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_LEFTSTICK, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L3) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_RIGHTSTICK, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R3) ? SDL_PRESSED : SDL_RELEASED); + + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE1, + (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_R4) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE2, + (pInReport->payload.deckState.ulButtonsH & STEAMDECK_HBUTTON_L4) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE3, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_R5) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_PADDLE4, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_L5) ? SDL_PRESSED : SDL_RELEASED); + + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_UP, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_UP) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_DOWN, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_DOWN) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_LEFT, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_LEFT) ? SDL_PRESSED : SDL_RELEASED); + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_DPAD_RIGHT, + (pInReport->payload.deckState.ulButtonsL & STEAMDECK_LBUTTON_DPAD_RIGHT) ? SDL_PRESSED : SDL_RELEASED); + ctx->last_button_state = pInReport->payload.deckState.ulButtons; + } + + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERLEFT, + (int)pInReport->payload.deckState.sTriggerRawL * 2 - 32768); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, + (int)pInReport->payload.deckState.sTriggerRawR * 2 - 32768); + + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTX, + pInReport->payload.deckState.sLeftStickX); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_LEFTY, + -pInReport->payload.deckState.sLeftStickY); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTX, + pInReport->payload.deckState.sRightStickX); + SDL_PrivateJoystickAxis(joystick, SDL_CONTROLLER_AXIS_RIGHTY, + -pInReport->payload.deckState.sRightStickY); + + ctx->sensor_timestamp_us += ctx->update_rate_us; + + values[0] = (pInReport->payload.deckState.sGyroX / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f)); + values[1] = (pInReport->payload.deckState.sGyroZ / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f)); + values[2] = (-pInReport->payload.deckState.sGyroY / 32768.0f) * (2000.0f * ((float)M_PI / 180.0f)); + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, ctx->sensor_timestamp_us, values, 3); + + values[0] = (pInReport->payload.deckState.sAccelX / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY; + values[1] = (pInReport->payload.deckState.sAccelZ / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY; + values[2] = (-pInReport->payload.deckState.sAccelY / 32768.0f) * 2.0f * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, ctx->sensor_timestamp_us, values, 3); + + return SDL_TRUE; +} + +static SDL_bool HIDAPI_DriverSteamDeck_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + SDL_DriverSteamDeck_Context *ctx = (SDL_DriverSteamDeck_Context *)device->context; + float update_rate_in_hz = 1.0f / (float)(ctx->update_rate_us) * 1.0e6f; + + SDL_AssertJoysticksLocked(); + + // Initialize the joystick capabilities + joystick->nbuttons = 20; + joystick->naxes = SDL_CONTROLLER_AXIS_MAX; + + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, update_rate_in_hz); + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, update_rate_in_hz); + + return SDL_TRUE; +} + +static int HIDAPI_DriverSteamDeck_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + int rc; + Uint8 buffer[HID_FEATURE_REPORT_BYTES + 1] = { 0 }; + FeatureReportMsg *msg = (FeatureReportMsg *)(buffer + 1); + + msg->header.type = ID_TRIGGER_RUMBLE_CMD; + msg->payload.simpleRumble.unRumbleType = 0; + msg->payload.simpleRumble.unIntensity = HAPTIC_INTENSITY_SYSTEM; + msg->payload.simpleRumble.unLeftMotorSpeed = low_frequency_rumble; + msg->payload.simpleRumble.unRightMotorSpeed = high_frequency_rumble; + msg->payload.simpleRumble.nLeftGain = 2; + msg->payload.simpleRumble.nRightGain = 0; + + rc = SDL_hid_send_feature_report(device->dev, buffer, sizeof(buffer)); + if (rc != sizeof(buffer)) + return -1; + return 0; +} + +static int HIDAPI_DriverSteamDeck_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) +{ + return SDL_Unsupported(); +} + +static Uint32 HIDAPI_DriverSteamDeck_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + return SDL_JOYCAP_RUMBLE; +} + +static int HIDAPI_DriverSteamDeck_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) +{ + return SDL_Unsupported(); +} + +static int HIDAPI_DriverSteamDeck_SendJoystickEffect(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, const void *data, int size) +{ + return SDL_Unsupported(); +} + +static int HIDAPI_DriverSteamDeck_SetSensorsEnabled(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, SDL_bool enabled) +{ + // On steam deck, sensors are enabled by default. Nothing to do here. + return 0; +} + +static void HIDAPI_DriverSteamDeck_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick) +{ + // Lizard mode id automatically re-enabled by watchdog. Nothing to do here. +} + +static void HIDAPI_DriverSteamDeck_FreeDevice(SDL_HIDAPI_Device *device) +{ +} + +SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteamDeck = { + SDL_HINT_JOYSTICK_HIDAPI_STEAMDECK, + SDL_TRUE, + HIDAPI_DriverSteamDeck_RegisterHints, + HIDAPI_DriverSteamDeck_UnregisterHints, + HIDAPI_DriverSteamDeck_IsEnabled, + HIDAPI_DriverSteamDeck_IsSupportedDevice, + HIDAPI_DriverSteamDeck_InitDevice, + HIDAPI_DriverSteamDeck_GetDevicePlayerIndex, + HIDAPI_DriverSteamDeck_SetDevicePlayerIndex, + HIDAPI_DriverSteamDeck_UpdateDevice, + HIDAPI_DriverSteamDeck_OpenJoystick, + HIDAPI_DriverSteamDeck_RumbleJoystick, + HIDAPI_DriverSteamDeck_RumbleJoystickTriggers, + HIDAPI_DriverSteamDeck_GetJoystickCapabilities, + HIDAPI_DriverSteamDeck_SetJoystickLED, + HIDAPI_DriverSteamDeck_SendJoystickEffect, + HIDAPI_DriverSteamDeck_SetSensorsEnabled, + HIDAPI_DriverSteamDeck_CloseJoystick, + HIDAPI_DriverSteamDeck_FreeDevice, +}; + +#endif /* SDL_JOYSTICK_HIDAPI_STEAMDECK */ + +#endif /* SDL_JOYSTICK_HIDAPI */ diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_switch.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_switch.c index 6a983c8960..45a2260d1b 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_switch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -274,6 +274,8 @@ typedef struct SDL_bool m_bSyncWrite; int m_nMaxWriteAttempts; ESwitchDeviceInfoControllerType m_eControllerType; + Uint8 m_nInitialInputMode; + Uint8 m_nCurrentInputMode; Uint8 m_rgucMACAddress[6]; Uint8 m_nCommandNumber; SwitchCommonOutputPacket_t m_RumblePacket; @@ -444,7 +446,7 @@ static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand SwitchSubcommandInputPacket_t *reply = NULL; int nTries; - for (nTries = 1; reply == NULL && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { + for (nTries = 1; !reply && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchSubcommandOutputPacket_t commandPacket; ConstructSubcommand(ctx, ucCommandID, pBuf, ucLen, &commandPacket); @@ -468,7 +470,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta for (nTries = 1; nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchProprietaryOutputPacket_t packet; - if ((pBuf == NULL && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { + if ((!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { return SDL_FALSE; } @@ -653,7 +655,13 @@ static SDL_bool SetVibrationEnabled(SDL_DriverSwitch_Context *ctx, Uint8 enabled } static SDL_bool SetInputMode(SDL_DriverSwitch_Context *ctx, Uint8 input_mode) { - return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetInputReportMode, &input_mode, 1, NULL); + if (input_mode == ctx->m_nCurrentInputMode) { + return SDL_TRUE; + } else { + ctx->m_nCurrentInputMode = input_mode; + + return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SetInputReportMode, &input_mode, sizeof(input_mode), NULL); + } } static SDL_bool SetHomeLED(SDL_DriverSwitch_Context *ctx, Uint8 brightness) @@ -719,15 +727,29 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c } } +static Uint8 GetInitialInputMode(SDL_DriverSwitch_Context *ctx) +{ + Uint8 input_mode = 0; + + if (ReadInput(ctx) > 0) { + input_mode = ctx->m_rgucReadBuffer[0]; + } + return input_mode; +} + static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) { Uint8 input_mode; /* Determine the desired input mode */ - if (ctx->device->is_bluetooth) { - input_mode = k_eSwitchInputReportIDs_SimpleControllerState; + if (ctx->m_nInitialInputMode) { + input_mode = ctx->m_nInitialInputMode; } else { - input_mode = k_eSwitchInputReportIDs_FullControllerState; + if (ctx->device->is_bluetooth) { + input_mode = k_eSwitchInputReportIDs_SimpleControllerState; + } else { + input_mode = k_eSwitchInputReportIDs_FullControllerState; + } } /* The official Nintendo Switch Pro Controller supports FullControllerState over Bluetooth @@ -736,7 +758,32 @@ static Uint8 GetDefaultInputMode(SDL_DriverSwitch_Context *ctx) * battery level over Bluetooth anyway. */ if (ctx->device->vendor_id == USB_VENDOR_NINTENDO) { + /* However, switching to full controller state breaks DirectInput, so let's not do that */ + #if 0 + input_mode = k_eSwitchInputReportIDs_FullControllerState; + #endif + + /* However, Joy-Con controllers switch their thumbsticks into D-pad mode in simple mode, + * so let's enable full controller state for them. + */ + if (ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT || + ctx->device->product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) { + input_mode = k_eSwitchInputReportIDs_FullControllerState; + } + } + return input_mode; +} + +static Uint8 GetSensorInputMode(SDL_DriverSwitch_Context *ctx) +{ + Uint8 input_mode; + + /* Determine the desired input mode */ + if (!ctx->m_nInitialInputMode || + ctx->m_nInitialInputMode == k_eSwitchInputReportIDs_SimpleControllerState) { input_mode = k_eSwitchInputReportIDs_FullControllerState; + } else { + input_mode = ctx->m_nInitialInputMode; } return input_mode; } @@ -1256,6 +1303,27 @@ static void UpdateDeviceIdentity(SDL_HIDAPI_Device *device) break; case k_eSwitchDeviceInfoControllerType_Unknown: /* We couldn't read the device info for this controller, might not be fully compliant */ + if (device->vendor_id == USB_VENDOR_NINTENDO) { + switch (device->product_id) { + case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConLeft; + HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (L)"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT; + break; + case USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_JoyConRight; + HIDAPI_SetDeviceName(device, "Nintendo Switch Joy-Con (R)"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT; + break; + case USB_PRODUCT_NINTENDO_SWITCH_PRO: + ctx->m_eControllerType = k_eSwitchDeviceInfoControllerType_ProController; + HIDAPI_SetDeviceName(device, "Nintendo Switch Pro Controller"); + device->type = SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO; + break; + default: + break; + } + } return; default: device->type = SDL_CONTROLLER_TYPE_UNKNOWN; @@ -1278,7 +1346,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSwitch_Context *ctx; ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1344,6 +1412,9 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_ ctx->m_bSyncWrite = SDL_TRUE; if (!ctx->m_bInputOnly) { + ctx->m_nInitialInputMode = GetInitialInputMode(ctx); + ctx->m_nCurrentInputMode = ctx->m_nInitialInputMode; + /* Initialize rumble data */ SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[0]); SetNeutralRumble(&ctx->m_RumblePacket.rumbleData[1]); @@ -1595,7 +1666,7 @@ static int HIDAPI_DriverSwitch_SetJoystickSensorsEnabled(SDL_HIDAPI_Device *devi Uint8 input_mode; if (enabled) { - input_mode = k_eSwitchInputReportIDs_FullControllerState; + input_mode = GetSensorInputMode(ctx); } else { input_mode = GetDefaultInputMode(ctx); } @@ -2168,13 +2239,19 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->m_unLastInput = now; - if (joystick == NULL) { + if (!joystick) { + continue; + } + + if (ctx->m_rgucReadBuffer[0] == k_eSwitchInputReportIDs_SubcommandReply) { continue; } if (ctx->m_bInputOnly) { HandleInputOnlyControllerState(joystick, ctx, (SwitchInputOnlyControllerStatePacket_t *)&ctx->m_rgucReadBuffer[0]); } else { + ctx->m_nCurrentInputMode = ctx->m_rgucReadBuffer[0]; + switch (ctx->m_rgucReadBuffer[0]) { case k_eSwitchInputReportIDs_SimpleControllerState: HandleSimpleControllerState(joystick, ctx, (SwitchSimpleStatePacket_t *)&ctx->m_rgucReadBuffer[1]); @@ -2241,7 +2318,10 @@ static void HIDAPI_DriverSwitch_CloseJoystick(SDL_HIDAPI_Device *device, SDL_Joy if (!ctx->m_bInputOnly) { /* Restore simple input mode for other applications */ - SetInputMode(ctx, k_eSwitchInputReportIDs_SimpleControllerState); + if (!ctx->m_nInitialInputMode || + ctx->m_nInitialInputMode == k_eSwitchInputReportIDs_SimpleControllerState) { + SetInputMode(ctx, k_eSwitchInputReportIDs_SimpleControllerState); + } } SDL_DelHintCallback(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_wii.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_wii.c index 3471b777ae..3b3d994482 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_wii.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -236,7 +236,7 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp int nRead = 0; while ((nRead = ReadInput(ctx)) != -1) { if (nRead > 0) { - if (ctx->m_rgucReadBuffer[0] == expectedID && (isMine == NULL || isMine(ctx->m_rgucReadBuffer))) { + if (ctx->m_rgucReadBuffer[0] == expectedID && (!isMine || isMine(ctx->m_rgucReadBuffer))) { return SDL_TRUE; } } else { @@ -733,7 +733,7 @@ static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverWii_Context *ctx; ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360.c index 843819f37f..2917fffa7b 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -143,7 +143,7 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXbox360_Context *ctx; ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -332,7 +332,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_XBOX_PROTOCOL HIDAPI_DumpPacket("Xbox 360 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 5223d1a5b7..9c44085eb3 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceName(device, "Xbox 360 Wireless Controller"); ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -162,7 +162,7 @@ static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xboxone.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xboxone.c index 755daa5dd6..497234a91d 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -368,7 +368,7 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXboxOne_Context *ctx; ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1159,7 +1159,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) if (ctx->bluetooth) { switch (data[0]) { case 0x01: - if (joystick == NULL) { + if (!joystick) { break; } if (size >= 16) { @@ -1171,13 +1171,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) } break; case 0x02: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(joystick, ctx, data, size); break; case 0x04: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(joystick, ctx, data, size); @@ -1225,7 +1225,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) break; case 0x03: /* Controller status update */ - if (joystick == NULL) { + if (!joystick) { /* We actually want to handle this packet any time it arrives */ /*break;*/ } @@ -1238,13 +1238,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) /* Unknown chatty controller information, sent by both sides */ break; case 0x07: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size); break; case 0x0C: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size); @@ -1259,7 +1259,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) The controller sends that in response to this request: 0x1E 0x30 0x07 0x01 0x04 */ - if (joystick == NULL) { + if (!joystick) { break; } #ifdef SET_SERIAL_AFTER_OPEN @@ -1278,7 +1278,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) #endif break; } - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size); diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick.c b/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick.c index c0e5cd5d7d..84767dca52 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,6 +71,9 @@ static SDL_HIDAPI_DeviceDriver *SDL_HIDAPI_drivers[] = { #ifdef SDL_JOYSTICK_HIDAPI_STEAM &SDL_HIDAPI_DriverSteam, #endif +#ifdef SDL_JOYSTICK_HIDAPI_STEAMDECK + &SDL_HIDAPI_DriverSteamDeck, +#endif #ifdef SDL_JOYSTICK_HIDAPI_SWITCH &SDL_HIDAPI_DriverNintendoClassic, &SDL_HIDAPI_DriverJoyCons, @@ -104,7 +107,7 @@ static char *HIDAPI_ConvertString(const wchar_t *wide_string) if (wide_string) { string = SDL_iconv_string("UTF-8", "WCHAR_T", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); - if (string == NULL) { + if (!string) { switch (sizeof(wchar_t)) { case 2: string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); @@ -154,14 +157,22 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) case USB_VENDOR_HORI: return SDL_TRUE; case USB_VENDOR_LOGITECH: - /* Most Logitech devices are fine with this, but the F310 will lock up */ - if (product == USB_PRODUCT_LOGITECH_F310) { + /* Most Logitech devices are not PlayStation controllers, and some of them + * lock up or reset when we send them the Sony third-party query feature + * report, so don't include that vendor here. Instead add devices as + * appropriate to controller_list.h + */ + return SDL_FALSE; + case USB_VENDOR_MADCATZ: + if (product == USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK) { + /* This is not a Playstation compatible device */ return SDL_FALSE; } return SDL_TRUE; - case USB_VENDOR_MADCATZ: + case USB_VENDOR_MAYFLASH: return SDL_TRUE; case USB_VENDOR_NACON: + case USB_VENDOR_NACON_ALT: return SDL_TRUE; case USB_VENDOR_PDP: return SDL_TRUE; @@ -172,10 +183,10 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product) case USB_VENDOR_QANBA: return SDL_TRUE; case USB_VENDOR_RAZER: - /* Most Razer devices are not game controllers, and some of them lock up - * or reset when we send them the Sony third-party query feature report, - * so don't include that vendor here. Instead add devices as appropriate - * to controller_type.c + /* Most Razer devices are not PlayStation controllers, and some of them + * lock up or reset when we send them the Sony third-party query feature + * report, so don't include that vendor here. Instead add devices as + * appropriate to controller_list.h * * Reference: https://github.com/libsdl-org/SDL/issues/6733 * https://github.com/libsdl-org/SDL/issues/6799 @@ -265,6 +276,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char * interface_protocol == XBONE_IFACE_PROTOCOL) { static const int SUPPORTED_VENDORS[] = { + 0x03f0, /* HP */ 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ @@ -276,6 +288,7 @@ static SDL_GameControllerType SDL_GetJoystickGameControllerProtocol(const char * 0x24c6, /* PowerA */ 0x2dc8, /* 8BitDo */ 0x2e24, /* Hyperkin */ + 0x3537, /* GameSir */ }; int i; @@ -611,7 +624,7 @@ static int HIDAPI_JoystickInit(void) static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks)); - if (joysticks == NULL) { + if (!joysticks) { return SDL_FALSE; } @@ -660,7 +673,7 @@ void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name) void HIDAPI_SetDeviceProduct(SDL_HIDAPI_Device *device, Uint16 vendor_id, Uint16 product_id) { /* Don't set the device product ID directly, or we'll constantly re-enumerate this device */ - device->guid = SDL_CreateJoystickGUID(device->guid.data[0], vendor_id, product_id, device->version, device->name, 'h', 0); + device->guid = SDL_CreateJoystickGUID(device->guid.data[0], vendor_id, product_id, device->version, device->manufacturer_string, device->product_string, 'h', 0); } static void HIDAPI_UpdateJoystickSerial(SDL_HIDAPI_Device *device) @@ -731,7 +744,7 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return SDL_FALSE; } @@ -757,7 +770,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return; } @@ -866,7 +879,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device)); - if (device == NULL) { + if (!device) { return NULL; } device->magic = &SDL_HIDAPI_device_magic; @@ -889,18 +902,11 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf /* Need the device name before getting the driver to know whether to ignore this device */ { - char *manufacturer_string = HIDAPI_ConvertString(info->manufacturer_string); - char *product_string = HIDAPI_ConvertString(info->product_string); char *serial_number = HIDAPI_ConvertString(info->serial_number); - device->name = SDL_CreateJoystickName(device->vendor_id, device->product_id, manufacturer_string, product_string); - - if (manufacturer_string) { - SDL_free(manufacturer_string); - } - if (product_string) { - SDL_free(product_string); - } + device->manufacturer_string = HIDAPI_ConvertString(info->manufacturer_string); + device->product_string = HIDAPI_ConvertString(info->product_string); + device->name = SDL_CreateJoystickName(device->vendor_id, device->product_id, device->manufacturer_string, device->product_string); if (serial_number && *serial_number) { device->serial = serial_number; @@ -909,6 +915,8 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } if (!device->name) { + SDL_free(device->manufacturer_string); + SDL_free(device->product_string); SDL_free(device->serial); SDL_free(device->path); SDL_free(device); @@ -917,7 +925,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } /* FIXME: Is there any way to tell whether this is a Bluetooth device? */ - device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->name, 'h', 0); + device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->manufacturer_string, device->product_string, 'h', 0); device->joystick_type = SDL_JOYSTICK_TYPE_GAMECONTROLLER; device->type = SDL_GetJoystickGameControllerProtocol(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol); @@ -945,7 +953,9 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } #ifdef DEBUG_HIDAPI - SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif return device; @@ -959,7 +969,9 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) SDL_AssertJoysticksLocked(); #ifdef DEBUG_HIDAPI - SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) { @@ -983,6 +995,8 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) device->magic = NULL; SDL_DestroyMutex(device->dev_lock); + SDL_free(device->manufacturer_string); + SDL_free(device->product_string); SDL_free(device->serial); SDL_free(device->name); SDL_free(device->path); @@ -1033,7 +1047,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons() if (joycons[0] && joycons[1]) { SDL_hid_device_info info; SDL_HIDAPI_Device **children = (SDL_HIDAPI_Device **)SDL_malloc(2 * sizeof(SDL_HIDAPI_Device *)); - if (children == NULL) { + if (!children) { return SDL_FALSE; } children[0] = joycons[0]; @@ -1164,7 +1178,7 @@ static SDL_bool HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, } /* If we're looking for an XInput controller, match it against any other Xbox controller */ - if (product_id == USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER) { + if (product_id == USB_PRODUCT_XBOX360_XUSB_CONTROLLER) { if (device->type == SDL_CONTROLLER_TYPE_XBOX360 || device->type == SDL_CONTROLLER_TYPE_XBOXONE) { return SDL_TRUE; } @@ -1363,6 +1377,11 @@ static const char *HIDAPI_JoystickGetDevicePath(int device_index) return path; } +static int HIDAPI_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int HIDAPI_JoystickGetDevicePlayerIndex(int device_index) { SDL_HIDAPI_Device *device; @@ -1418,13 +1437,13 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); - if (device == NULL || !device->driver) { + if (!device || !device->driver) { /* This should never happen - validated before being called */ return SDL_SetError("Couldn't find HIDAPI device at index %d\n", device_index); } hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } hwdata->device = device; @@ -1436,6 +1455,12 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) device->updating = SDL_FALSE; SDL_UnlockMutex(device->dev_lock); + /* UpdateDevice() may have called HIDAPI_JoystickDisconnected() if the device went away */ + if (device->num_joysticks == 0) { + SDL_free(hwdata); + return SDL_SetError("HIDAPI device disconnected while opening"); + } + if (!device->driver->OpenJoystick(device, joystick)) { /* The open failed, mark this device as disconnected and update devices */ HIDAPI_JoystickDisconnected(device, joystickID); @@ -1635,6 +1660,7 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver = { HIDAPI_JoystickDetect, HIDAPI_JoystickGetDeviceName, HIDAPI_JoystickGetDevicePath, + HIDAPI_JoystickGetDeviceSteamVirtualGamepadSlot, HIDAPI_JoystickGetDevicePlayerIndex, HIDAPI_JoystickSetDevicePlayerIndex, HIDAPI_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick_c.h b/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick_c.h index d17203f43b..cd18730a83 100644 --- a/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick_c.h +++ b/vs/sdl2/src/joystick/hidapi/SDL_hidapijoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +39,7 @@ #define SDL_JOYSTICK_HIDAPI_PS5 #define SDL_JOYSTICK_HIDAPI_STADIA #define SDL_JOYSTICK_HIDAPI_STEAM /* Simple support for BLE Steam Controller, hint is disabled by default */ +#define SDL_JOYSTICK_HIDAPI_STEAMDECK #define SDL_JOYSTICK_HIDAPI_SWITCH #define SDL_JOYSTICK_HIDAPI_WII #define SDL_JOYSTICK_HIDAPI_XBOX360 @@ -58,6 +59,8 @@ typedef struct _SDL_HIDAPI_Device { const void *magic; char *name; + char *manufacturer_string; + char *product_string; char *path; Uint16 vendor_id; Uint16 product_id; @@ -132,6 +135,7 @@ extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverPS5; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverShield; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverStadia; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteam; +extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSteamDeck; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverSwitch; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverWii; extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXbox360; diff --git a/vs/sdl2/src/joystick/hidapi/steam/controller_constants.h b/vs/sdl2/src/joystick/hidapi/steam/controller_constants.h index d0d5688516..ab4ac2ee15 100644 --- a/vs/sdl2/src/joystick/hidapi/steam/controller_constants.h +++ b/vs/sdl2/src/joystick/hidapi/steam/controller_constants.h @@ -47,6 +47,8 @@ enum ValveControllerPID D0G_BLE_PID = 0x1105, D0G_BLE2_PID = 0x1106, D0GGLE_PID = 0x1142, + + JUPITER_PID = 0x1205, }; // This enum contains all of the messages exchanged between the host and the target (only add to this enum and never change the order) @@ -68,10 +70,11 @@ enum FeatureReportMessageIDs ID_SET_CONTROLLER_MODE = 0x8D, ID_LOAD_DEFAULT_SETTINGS = 0x8E, ID_TRIGGER_HAPTIC_PULSE = 0x8F, + ID_TURN_OFF_CONTROLLER = 0x9F, ID_GET_DEVICE_INFO = 0xA1, - + ID_CALIBRATE_TRACKPADS = 0xA7, ID_RESERVED_0 = 0xA8, ID_SET_SERIAL_NUMBER = 0xA9, @@ -99,6 +102,12 @@ enum FeatureReportMessageIDs ID_CHECK_GYRO_FW_LOAD = 0xC2, ID_CALIBRATE_ANALOG = 0xC3, ID_DONGLE_GET_CONNECTED_SLOTS = 0xC4, + + ID_RESET_IMU = 0xCE, + + // Deck only + ID_TRIGGER_HAPTIC_CMD = 0xEA, + ID_TRIGGER_RUMBLE_CMD = 0xEB, }; @@ -215,6 +224,32 @@ typedef enum IO_RAW_JOYSTICK_X, IO_RAW_JOYSTICK_Y, IO_GYRO_TILT_VEC, + IO_PRESSURE_LEFT_PAD, + IO_PRESSURE_RIGHT_PAD, + IO_PRESSURE_LEFT_BUMPER, + IO_PRESSURE_RIGHT_BUMPER, + IO_PRESSURE_LEFT_GRIP, + IO_PRESSURE_RIGHT_GRIP, + IO_ANALOG_LEFT_TRIGGER_THRESHOLD, + IO_ANALOG_RIGHT_TRIGGER_THRESHOLD, + IO_PRESSURE_RIGHT_PAD_THRESHOLD, + IO_PRESSURE_LEFT_PAD_THRESHOLD, + IO_PRESSURE_RIGHT_BUMPER_THRESHOLD, + IO_PRESSURE_LEFT_BUMPER_THRESHOLD, + IO_PRESSURE_RIGHT_GRIP_THRESHOLD, + IO_PRESSURE_LEFT_GRIP_THRESHOLD, + IO_PRESSURE_RIGHT_PAD_RAW, + IO_PRESSURE_LEFT_PAD_RAW, + IO_PRESSURE_RIGHT_BUMPER_RAW, + IO_PRESSURE_LEFT_BUMPER_RAW, + IO_PRESSURE_RIGHT_GRIP_RAW, + IO_PRESSURE_LEFT_GRIP_RAW, + IO_PRESSURE_RIGHT_GRIP2_THRESHOLD, + IO_PRESSURE_LEFT_GRIP2_THRESHOLD, + IO_PRESSURE_LEFT_GRIP2, + IO_PRESSURE_RIGHT_GRIP2, + IO_PRESSURE_RIGHT_GRIP2_RAW, + IO_PRESSURE_LEFT_GRIP2_RAW, IO_ANALOG_COUNT } AnalogIO; @@ -382,13 +417,15 @@ typedef enum SETTING_MOUSE_SENSITIVITY, SETTING_MOUSE_ACCELERATION, SETTING_TRACKBALL_ROTATION_ANGLE, - SETTING_HAPTIC_INTENSITY, + SETTING_HAPTIC_INTENSITY_UNUSED, SETTING_LEFT_GAMEPAD_STICK_ENABLED, SETTING_RIGHT_GAMEPAD_STICK_ENABLED, SETTING_USB_DEBUG_MODE, SETTING_LEFT_TRACKPAD_MODE, SETTING_RIGHT_TRACKPAD_MODE, SETTING_MOUSE_POINTER_ENABLED, + + // 10 SETTING_DPAD_DEADZONE, SETTING_MINIMUM_MOMENTUM_VEL, SETTING_MOMENTUM_DECAY_AMMOUNT, @@ -399,6 +436,8 @@ typedef enum SETTING_MOMENTUM_VERTICAL_DIVISOR, SETTING_MOMENTUM_MAXIMUM_VELOCITY, SETTING_TRACKPAD_Z_ON, + + // 20 SETTING_TRACKPAD_Z_OFF, SETTING_SENSITIVY_SCALE_AMMOUNT, SETTING_LEFT_TRACKPAD_SECONDARY_MODE, @@ -409,6 +448,8 @@ typedef enum SETTING_TRACKPAD_OUTER_RADIUS, SETTING_TRACKPAD_Z_ON_LEFT, SETTING_TRACKPAD_Z_OFF_LEFT, + + // 30 SETTING_TRACKPAD_OUTER_SPIN_VEL, SETTING_TRACKPAD_OUTER_SPIN_RADIUS, SETTING_TRACKPAD_OUTER_SPIN_HORIZONTAL_ONLY, @@ -419,6 +460,8 @@ typedef enum SETTING_TRACKPAD_DOUBLE_TAP_BEEP_PERIOD, SETTING_TRACKPAD_DOUBLE_TAP_BEEP_COUNT, SETTING_TRACKPAD_OUTER_RADIUS_RELEASE_ON_TRANSITION, + + // 40 SETTING_RADIAL_MODE_ANGLE, SETTING_HAPTIC_INTENSITY_MOUSE_MODE, SETTING_LEFT_DPAD_REQUIRES_CLICK, @@ -427,9 +470,48 @@ typedef enum SETTING_LED_USER_BRIGHTNESS, SETTING_ENABLE_RAW_JOYSTICK, SETTING_ENABLE_FAST_SCAN, - SETTING_GYRO_MODE, + SETTING_IMU_MODE, SETTING_WIRELESS_PACKET_VERSION, + + // 50 SETTING_SLEEP_INACTIVITY_TIMEOUT, + SETTING_TRACKPAD_NOISE_THRESHOLD, + SETTING_LEFT_TRACKPAD_CLICK_PRESSURE, + SETTING_RIGHT_TRACKPAD_CLICK_PRESSURE, + SETTING_LEFT_BUMPER_CLICK_PRESSURE, + SETTING_RIGHT_BUMPER_CLICK_PRESSURE, + SETTING_LEFT_GRIP_CLICK_PRESSURE, + SETTING_RIGHT_GRIP_CLICK_PRESSURE, + SETTING_LEFT_GRIP2_CLICK_PRESSURE, + SETTING_RIGHT_GRIP2_CLICK_PRESSURE, + + // 60 + SETTING_PRESSURE_MODE, + SETTING_CONTROLLER_TEST_MODE, + SETTING_TRIGGER_MODE, + SETTING_TRACKPAD_Z_THRESHOLD, + SETTING_FRAME_RATE, + SETTING_TRACKPAD_FILT_CTRL, + SETTING_TRACKPAD_CLIP, + SETTING_DEBUG_OUTPUT_SELECT, + SETTING_TRIGGER_THRESHOLD_PERCENT, + SETTING_TRACKPAD_FREQUENCY_HOPPING, + + // 70 + SETTING_HAPTICS_ENABLED, + SETTING_STEAM_WATCHDOG_ENABLE, + SETTING_TIMP_TOUCH_THRESHOLD_ON, + SETTING_TIMP_TOUCH_THRESHOLD_OFF, + SETTING_FREQ_HOPPING, + SETTING_TEST_CONTROL, + SETTING_HAPTIC_MASTER_GAIN_DB, + SETTING_THUMB_TOUCH_THRESH, + SETTING_DEVICE_POWER_STATUS, + SETTING_HAPTIC_INTENSITY, + + // 80 + SETTING_STABILIZER_ENABLED, + SETTING_TIMP_MODE_MTE, SETTING_COUNT, // This is a special setting value use for callbacks and should not be set/get explicitly. @@ -461,6 +543,7 @@ typedef enum HAPTIC_PULSE_NORMAL = 0x0000, HAPTIC_PULSE_HIGH_PRIORITY = 0x0001, HAPTIC_PULSE_VERY_HIGH_PRIORITY = 0x0002, + HAPTIC_PULSE_IGNORE_USER_PREFS = 0x0003, } SettingHapticPulseFlags; typedef struct diff --git a/vs/sdl2/src/joystick/hidapi/steam/controller_structs.h b/vs/sdl2/src/joystick/hidapi/steam/controller_structs.h index c8fd61226e..1659f74c90 100644 --- a/vs/sdl2/src/joystick/hidapi/steam/controller_structs.h +++ b/vs/sdl2/src/joystick/hidapi/steam/controller_structs.h @@ -32,6 +32,13 @@ typedef struct unsigned char length; } FeatureReportHeader; +// Generic controller settings structure +typedef struct +{ + unsigned char settingNum; + unsigned short settingValue; +} ControllerSetting; + // Generic controller attribute structure typedef struct { @@ -39,12 +46,89 @@ typedef struct uint32_t attributeValue; } ControllerAttribute; +// Generic controller settings structure +typedef struct +{ + ControllerSetting settings[ ( HID_FEATURE_REPORT_BYTES - sizeof( FeatureReportHeader ) ) / sizeof( ControllerSetting ) ]; +} MsgSetSettingsValues, MsgGetSettingsValues, MsgGetSettingsDefaults, MsgGetSettingsMaxs; + // Generic controller settings structure typedef struct { ControllerAttribute attributes[ ( HID_FEATURE_REPORT_BYTES - sizeof( FeatureReportHeader ) ) / sizeof( ControllerAttribute ) ]; } MsgGetAttributes; +typedef struct +{ + unsigned char attributeTag; + char attributeValue[20]; +} MsgGetStringAttribute; + +typedef struct +{ + unsigned char mode; +} MsgSetControllerMode; + +// Trigger a haptic pulse +typedef struct { + unsigned char which_pad; + unsigned short pulse_duration; + unsigned short pulse_interval; + unsigned short pulse_count; + short dBgain; + unsigned char priority; +} MsgFireHapticPulse; + +typedef struct { + uint8_t mode; +} MsgHapticSetMode; + +typedef enum { + HAPTIC_TYPE_OFF, + HAPTIC_TYPE_TICK, + HAPTIC_TYPE_CLICK, + HAPTIC_TYPE_TONE, + HAPTIC_TYPE_RUMBLE, + HAPTIC_TYPE_NOISE, + HAPTIC_TYPE_SCRIPT, + HAPTIC_TYPE_LOG_SWEEP, +} haptic_type_t; + +typedef enum { + HAPTIC_INTENSITY_SYSTEM, + HAPTIC_INTENSITY_SHORT, + HAPTIC_INTENSITY_MEDIUM, + HAPTIC_INTENSITY_LONG, + HAPTIC_INTENSITY_INSANE, +} haptic_intensity_t; + +typedef struct { + uint8_t side; // 0x01 = L, 0x02 = R, 0x03 = Both + uint8_t cmd; // 0 = Off, 1 = tick, 2 = click, 3 = tone, 4 = rumble, 5 = + // rumble_noise, 6 = script, 7 = sweep, + uint8_t ui_intensity; // 0-4 (0 = default) + int8_t dBgain; // dB Can be positive (reasonable clipping / limiting will apply) + uint16_t freq; // Frequency of tone (if applicable) + int16_t dur_ms; // Duration of tone / rumble (if applicable) (neg = infinite) + + uint16_t noise_intensity; + uint16_t lfo_freq; // Drives both tone and rumble geneators + uint8_t lfo_depth; // percentage, typically 100 + uint8_t rand_tone_gain; // Randomize each LFO cycle's gain + uint8_t script_id; // Used w/ dBgain for scripted haptics + + uint16_t lss_start_freq; // Used w/ Log Sine Sweep + uint16_t lss_end_freq; // Ditto +} MsgTriggerHaptic; + +typedef struct { + uint8_t unRumbleType; + uint16_t unIntensity; + uint16_t unLeftMotorSpeed; + uint16_t unRightMotorSpeed; + int8_t nLeftGain; + int8_t nRightGain; +} MsgSimpleRumbleCmd; // This is the only message struct that application code should use to interact with feature request messages. Any new // messages should be added to the union. The structures defined here should correspond to the ones defined in @@ -55,7 +139,17 @@ typedef struct FeatureReportHeader header; union { - MsgGetAttributes getAttributes; + MsgSetSettingsValues setSettingsValues; + MsgGetSettingsValues getSettingsValues; + MsgGetSettingsMaxs getSettingsMaxs; + MsgGetSettingsDefaults getSettingsDefaults; + MsgGetAttributes getAttributes; + MsgSetControllerMode controllerMode; + MsgFireHapticPulse fireHapticPulse; + MsgGetStringAttribute getStringAttribute; + MsgHapticSetMode hapticMode; + MsgTriggerHaptic triggerHaptic; + MsgSimpleRumbleCmd simpleRumble; } payload; } FeatureReportMsg; @@ -77,6 +171,7 @@ typedef enum ID_CONTROLLER_DEBUG2 = 5, ID_CONTROLLER_SECONDARY_STATE = 6, ID_CONTROLLER_BLE_STATE = 7, + ID_CONTROLLER_DECK_STATE = 9, ID_CONTROLLER_MSG_COUNT } ValveInReportMessageIDs; @@ -94,12 +189,12 @@ typedef struct { // If packet num matches that on your prior call, then the controller state hasn't been changed since // your last call and there is no need to process it - uint32 unPacketNum; + Uint32 unPacketNum; // Button bitmask and trigger data. union { - uint64 ulButtons; + Uint64 ulButtons; struct { unsigned char _pad0[3]; @@ -143,12 +238,12 @@ typedef struct { // If packet num matches that on your prior call, then the controller state hasn't been changed since // your last call and there is no need to process it - uint32 unPacketNum; + Uint32 unPacketNum; // Button bitmask and trigger data. union { - uint64 ulButtons; + Uint64 ulButtons; struct { unsigned char _pad0[3]; @@ -258,6 +353,66 @@ typedef struct unsigned char ucBatteryLevel; } SteamControllerStatusEvent_t; +// Deck State payload +typedef struct +{ + // If packet num matches that on your prior call, then the controller + // state hasn't been changed since your last call and there is no need to + // process it + Uint32 unPacketNum; + + // Button bitmask and trigger data. + union + { + Uint64 ulButtons; + struct + { + Uint32 ulButtonsL; + Uint32 ulButtonsH; + }; + }; + + // Left pad coordinates + short sLeftPadX; + short sLeftPadY; + + // Right pad coordinates + short sRightPadX; + short sRightPadY; + + // Accelerometer values + short sAccelX; + short sAccelY; + short sAccelZ; + + // Gyroscope values + short sGyroX; + short sGyroY; + short sGyroZ; + + // Gyro quaternions + short sGyroQuatW; + short sGyroQuatX; + short sGyroQuatY; + short sGyroQuatZ; + + // Uncalibrated trigger values + unsigned short sTriggerRawL; + unsigned short sTriggerRawR; + + // Left stick values + short sLeftStickX; + short sLeftStickY; + + // Right stick values + short sRightStickX; + short sRightStickY; + + // Touchpad pressures + unsigned short sPressurePadLeft; + unsigned short sPressurePadRight; +} SteamDeckStatePacket_t; + typedef struct { ValveInReportHeader_t header; @@ -271,6 +426,7 @@ typedef struct ValveControllerRawTrackpadImage_t rawPadImage; SteamControllerWirelessEvent_t wirelessEvent; SteamControllerStatusEvent_t statusEvent; + SteamDeckStatePacket_t deckState; } payload; } ValveInReport_t; diff --git a/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick.m b/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick.m index b9aeed703c..28ddca7234 100644 --- a/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick.m +++ b/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +33,7 @@ #include "SDL_mfijoystick_c.h" -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED #include "../../events/SDL_events_c.h" #endif @@ -55,11 +55,22 @@ static id connectObserver = nil; static id disconnectObserver = nil; -static NSString *GCInputXboxShareButton = @"Button Share"; #include #include +#ifndef __IPHONE_OS_VERSION_MAX_ALLOWED +#define __IPHONE_OS_VERSION_MAX_ALLOWED 0 +#endif + +#ifndef __APPLETV_OS_VERSION_MAX_ALLOWED +#define __APPLETV_OS_VERSION_MAX_ALLOWED 0 +#endif + +#ifndef __MAC_OS_VERSION_MAX_ALLOWED +#define __MAC_OS_VERSION_MAX_ALLOWED 0 +#endif + /* remove compilation warnings for strict builds by defining these selectors, even though * they are only ever used indirectly through objc_msgSend */ @@ -224,11 +235,125 @@ static BOOL IsControllerBackboneOne(GCController *controller) } return FALSE; } +static void CheckControllerSiriRemote(GCController *controller, int *is_siri_remote) +{ + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + if ([controller.productCategory hasPrefix:@"Siri Remote"]) { + *is_siri_remote = 1; + SDL_sscanf(controller.productCategory.UTF8String, "Siri Remote (%i%*s Generation)", is_siri_remote); + return; + } + } + *is_siri_remote = 0; +} + +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE +static BOOL ElementAlreadyHandled(SDL_JoystickDeviceItem *device, NSString *element, NSDictionary *elements) +{ + if ([element isEqualToString:@"Left Thumbstick Left"] || + [element isEqualToString:@"Left Thumbstick Right"]) { + if (elements[@"Left Thumbstick X Axis"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Left Thumbstick Up"] || + [element isEqualToString:@"Left Thumbstick Down"]) { + if (elements[@"Left Thumbstick Y Axis"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Right Thumbstick Left"] || + [element isEqualToString:@"Right Thumbstick Right"]) { + if (elements[@"Right Thumbstick X Axis"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Right Thumbstick Up"] || + [element isEqualToString:@"Right Thumbstick Down"]) { + if (elements[@"Right Thumbstick Y Axis"]) { + return TRUE; + } + } + if (device->is_siri_remote) { + if ([element isEqualToString:@"Direction Pad Left"] || + [element isEqualToString:@"Direction Pad Right"]) { + if (elements[@"Direction Pad X Axis"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Direction Pad Up"] || + [element isEqualToString:@"Direction Pad Down"]) { + if (elements[@"Direction Pad Y Axis"]) { + return TRUE; + } + } + } else { + if ([element isEqualToString:@"Direction Pad X Axis"]) { + if (elements[@"Direction Pad Left"] && + elements[@"Direction Pad Right"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Direction Pad Y Axis"]) { + if (elements[@"Direction Pad Up"] && + elements[@"Direction Pad Down"]) { + return TRUE; + } + } + } + if ([element isEqualToString:@"Cardinal Direction Pad X Axis"]) { + if (elements[@"Cardinal Direction Pad Left"] && + elements[@"Cardinal Direction Pad Right"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Cardinal Direction Pad Y Axis"]) { + if (elements[@"Cardinal Direction Pad Up"] && + elements[@"Cardinal Direction Pad Down"]) { + return TRUE; + } + } + if ([element isEqualToString:@"Touchpad 1 X Axis"] || + [element isEqualToString:@"Touchpad 1 Y Axis"] || + [element isEqualToString:@"Touchpad 1 Left"] || + [element isEqualToString:@"Touchpad 1 Right"] || + [element isEqualToString:@"Touchpad 1 Up"] || + [element isEqualToString:@"Touchpad 1 Down"] || + [element isEqualToString:@"Touchpad 2 X Axis"] || + [element isEqualToString:@"Touchpad 2 Y Axis"] || + [element isEqualToString:@"Touchpad 2 Left"] || + [element isEqualToString:@"Touchpad 2 Right"] || + [element isEqualToString:@"Touchpad 2 Up"] || + [element isEqualToString:@"Touchpad 2 Down"]) { + /* The touchpad is handled separately */ + return TRUE; + } + if ([element isEqualToString:@"Button Home"]) { + if (device->is_switch_joycon_pair) { + /* The Nintendo Switch JoyCon home button doesn't ever show as being held down */ + return TRUE; + } +#if TARGET_OS_TV + /* The OS uses the home button, it's not available to apps */ + return TRUE; +#endif + } + if ([element isEqualToString:@"Button Share"]) { + if (device->is_backbone_one) { + /* The Backbone app uses share button */ + return TRUE; + } + } + return FALSE; +} +#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ + static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCController *controller) { Uint16 vendor = 0; Uint16 product = 0; Uint8 subtype = 0; + Uint16 signature = 0; const char *name = NULL; if (@available(macOS 11.3, iOS 14.5, tvOS 14.5, *)) { @@ -252,214 +377,252 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->name = SDL_CreateJoystickName(0, 0, NULL, name); #ifdef DEBUG_CONTROLLER_PROFILE + NSLog(@"Product name: %@\n", controller.vendorName); + NSLog(@"Product category: %@\n", controller.productCategory); + NSLog(@"Elements available:\n"); +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { - if (controller.physicalInputProfile) { - for (id key in controller.physicalInputProfile.buttons) { - NSLog(@"Button %@ available\n", key); - } - for (id key in controller.physicalInputProfile.axes) { - NSLog(@"Axis %@ available\n", key); - } + NSDictionary *elements = controller.physicalInputProfile.elements; + for (id key in controller.physicalInputProfile.buttons) { + NSLog(@"\tButton: %@ (%s)\n", key, elements[key].analog ? "analog" : "digital"); + } + for (id key in controller.physicalInputProfile.axes) { + NSLog(@"\tAxis: %@\n", key); + } + for (id key in controller.physicalInputProfile.dpads) { + NSLog(@"\tHat: %@\n", key); } } +#endif #endif - if (controller.extendedGamepad) { - GCExtendedGamepad *gamepad = controller.extendedGamepad; - BOOL is_xbox = IsControllerXbox(controller); - BOOL is_ps4 = IsControllerPS4(controller); - BOOL is_ps5 = IsControllerPS5(controller); - BOOL is_switch_pro = IsControllerSwitchPro(controller); - BOOL is_switch_joycon_pair = IsControllerSwitchJoyConPair(controller); - BOOL is_stadia = IsControllerStadia(controller); - BOOL is_backbone_one = IsControllerBackboneOne(controller); - int nbuttons = 0; - BOOL has_direct_menu; - + device->is_xbox = IsControllerXbox(controller); + device->is_ps4 = IsControllerPS4(controller); + device->is_ps5 = IsControllerPS5(controller); + device->is_switch_pro = IsControllerSwitchPro(controller); + device->is_switch_joycon_pair = IsControllerSwitchJoyConPair(controller); + device->is_stadia = IsControllerStadia(controller); + device->is_backbone_one = IsControllerBackboneOne(controller); + device->is_switch_joyconL = IsControllerSwitchJoyConL(controller); + device->is_switch_joyconR = IsControllerSwitchJoyConR(controller); #ifdef SDL_JOYSTICK_HIDAPI - if ((is_xbox && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE)) || - (is_ps4 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS4)) || - (is_ps5 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS5)) || - (is_switch_pro && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO)) || - (is_switch_joycon_pair && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR, 0, "")) || - (is_stadia && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_GOOGLE_STADIA))) { - /* The HIDAPI driver is taking care of this device */ - return FALSE; - } + if ((device->is_xbox && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_XBOXONE)) || + (device->is_ps4 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS4)) || + (device->is_ps5 && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_PS5)) || + (device->is_switch_pro && HIDAPI_IsDeviceTypePresent(SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO)) || + (device->is_switch_joycon_pair && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR, 0, "")) || + (device->is_stadia && HIDAPI_IsDevicePresent(USB_VENDOR_GOOGLE, USB_PRODUCT_GOOGLE_STADIA_CONTROLLER, 0, "")) || + (device->is_switch_joyconL && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT, 0, "")) || + (device->is_switch_joyconR && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT, 0, ""))) { + /* The HIDAPI driver is taking care of this device */ + return FALSE; + } #endif + CheckControllerSiriRemote(controller, &device->is_siri_remote); - /* These buttons are part of the original MFi spec */ - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_A); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_B); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_X); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_Y); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_LEFTSHOULDER); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); - nbuttons += 6; + if (device->is_siri_remote && !SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { + /* Ignore remotes, they'll be handled as keyboard input */ + return SDL_FALSE; + } - /* These buttons are available on some newer controllers */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunguarded-availability-new" - if ([gamepad respondsToSelector:@selector(leftThumbstickButton)] && gamepad.leftThumbstickButton) { - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_LEFTSTICK); - ++nbuttons; - } - if ([gamepad respondsToSelector:@selector(rightThumbstickButton)] && gamepad.rightThumbstickButton) { - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_RIGHTSTICK); - ++nbuttons; +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) { + device->has_dualshock_touchpad = TRUE; } - if ([gamepad respondsToSelector:@selector(buttonOptions)] && gamepad.buttonOptions) { - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_BACK); - ++nbuttons; + if (controller.physicalInputProfile.buttons[GCInputXboxPaddleOne] != nil) { + device->has_xbox_paddles = TRUE; } - /* The Nintendo Switch JoyCon home button doesn't ever show as being held down */ - if ([gamepad respondsToSelector:@selector(buttonHome)] && gamepad.buttonHome && !is_switch_joycon_pair) { - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_GUIDE); - ++nbuttons; + if (controller.physicalInputProfile.buttons[@"Button Share"] != nil) { + device->has_xbox_share_button = TRUE; } - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START); - ++nbuttons; + } +#endif // ENABLE_PHYSICAL_INPUT_PROFILE - has_direct_menu = [gamepad respondsToSelector:@selector(buttonMenu)] && gamepad.buttonMenu; - if (!has_direct_menu) { - device->uses_pause_handler = SDL_TRUE; + if (device->is_backbone_one) { + vendor = USB_VENDOR_BACKBONE; + if (device->is_ps5) { + product = USB_PRODUCT_BACKBONE_ONE_IOS_PS5; + } else { + product = USB_PRODUCT_BACKBONE_ONE_IOS; + } + } else if (device->is_xbox) { + vendor = USB_VENDOR_MICROSOFT; + if (device->has_xbox_paddles) { + /* Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID */ + product = USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH; + } else if (device->has_xbox_share_button) { + /* Assume Xbox Series X Controller unless/until GCController flows VID/PID */ + product = USB_PRODUCT_XBOX_SERIES_X_BLE; + } else { + /* Assume Xbox One S Bluetooth Controller unless/until GCController flows VID/PID */ + product = USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH; + } + } else if (device->is_ps4) { + /* Assume DS4 Slim unless/until GCController flows VID/PID */ + vendor = USB_VENDOR_SONY; + product = USB_PRODUCT_SONY_DS4_SLIM; + if (device->has_dualshock_touchpad) { + subtype = 1; } + } else if (device->is_ps5) { + vendor = USB_VENDOR_SONY; + product = USB_PRODUCT_SONY_DS5; + } else if (device->is_switch_pro) { + vendor = USB_VENDOR_NINTENDO; + product = USB_PRODUCT_NINTENDO_SWITCH_PRO; + } else if (device->is_switch_joycon_pair) { + vendor = USB_VENDOR_NINTENDO; + product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR; + } else if (device->is_switch_joyconL) { + vendor = USB_VENDOR_NINTENDO; + product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT; + } else if (device->is_switch_joyconR) { + vendor = USB_VENDOR_NINTENDO; + product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT; +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE + } else if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + vendor = USB_VENDOR_APPLE; + product = 4; + subtype = 4; +#endif + } else if (controller.extendedGamepad) { + vendor = USB_VENDOR_APPLE; + product = 1; + subtype = 1; + } else if (controller.gamepad) { + vendor = USB_VENDOR_APPLE; + product = 2; + subtype = 2; #if TARGET_OS_TV - /* The single menu button isn't very reliable, at least as of tvOS 16.1 */ - if ((device->button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) == 0) { - device->uses_pause_handler = SDL_TRUE; - } + } else if (controller.microGamepad) { + vendor = USB_VENDOR_APPLE; + product = 3; + subtype = 3; #endif + } else { + /* We don't know how to get input events from this device */ + return SDL_FALSE; + } #ifdef ENABLE_PHYSICAL_INPUT_PROFILE - if ([controller respondsToSelector:@selector(physicalInputProfile)]) { - if (controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton] != nil) { - device->has_dualshock_touchpad = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_MISC1); - ++nbuttons; + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + NSDictionary *elements = controller.physicalInputProfile.elements; + + /* Provide both axes and analog buttons as SDL axes */ + NSArray *axes = [[[elements allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] + filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *bindings) { + GCControllerElement *element; + + if (ElementAlreadyHandled(device, (NSString *)object, elements)) { + return NO; } - if (controller.physicalInputProfile.buttons[GCInputXboxPaddleOne] != nil) { - device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE1); - ++nbuttons; + + element = elements[object]; + if (element.analog) { + if ([element isKindOfClass:[GCControllerAxisInput class]] || + [element isKindOfClass:[GCControllerButtonInput class]]) { + return YES; + } } - if (controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo] != nil) { - device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE2); - ++nbuttons; + return NO; + }]]; + NSArray *buttons = [[[elements allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)] + filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id object, NSDictionary *bindings) { + GCControllerElement *element; + + if (ElementAlreadyHandled(device, (NSString *)object, elements)) { + return NO; } - if (controller.physicalInputProfile.buttons[GCInputXboxPaddleThree] != nil) { - device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE3); - ++nbuttons; + + element = elements[object]; + if ([element isKindOfClass:[GCControllerButtonInput class]]) { + return YES; } - if (controller.physicalInputProfile.buttons[GCInputXboxPaddleFour] != nil) { - device->has_xbox_paddles = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_PADDLE4); + return NO; + }]]; + /* Explicitly retain the arrays because SDL_JoystickDeviceItem is a + * struct, and ARC doesn't work with structs. */ + device->naxes = (int)axes.count; + device->axes = (__bridge NSArray *)CFBridgingRetain(axes); + device->nbuttons = (int)buttons.count; + device->buttons = (__bridge NSArray *)CFBridgingRetain(buttons); + subtype = 4; + +#ifdef DEBUG_CONTROLLER_PROFILE + NSLog(@"Elements used:\n", controller.vendorName); + for (id key in device->buttons) { + NSLog(@"\tButton: %@ (%s)\n", key, elements[key].analog ? "analog" : "digital"); + } + for (id key in device->axes) { + NSLog(@"\tAxis: %@\n", key); + } +#endif /* DEBUG_CONTROLLER_PROFILE */ + +#if TARGET_OS_TV + /* tvOS turns the menu button into a system gesture, so we grab it here instead */ + if (elements[GCInputButtonMenu] && !elements[@"Button Home"]) { + device->pause_button_index = [device->buttons indexOfObject:GCInputButtonMenu]; + } +#endif + } else +#endif + if (controller.extendedGamepad) { + GCExtendedGamepad *gamepad = controller.extendedGamepad; + int nbuttons = 0; + BOOL has_direct_menu = FALSE; + + /* These buttons are part of the original MFi spec */ + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_A); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_B); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_X); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_Y); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_LEFTSHOULDER); + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); + nbuttons += 6; + + /* These buttons are available on some newer controllers */ + if (@available(macOS 10.14.1, iOS 12.1, tvOS 12.1, *)) { + if (gamepad.leftThumbstickButton) { + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_LEFTSTICK); ++nbuttons; } - if (controller.physicalInputProfile.buttons[GCInputXboxShareButton] != nil) { - device->has_xbox_share_button = SDL_TRUE; - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_MISC1); + if (gamepad.rightThumbstickButton) { + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_RIGHTSTICK); ++nbuttons; } } -#endif -#pragma clang diagnostic pop - - if (is_backbone_one) { - vendor = USB_VENDOR_BACKBONE; - if (is_ps5) { - product = USB_PRODUCT_BACKBONE_ONE_IOS_PS5; - } else { - product = USB_PRODUCT_BACKBONE_ONE_IOS; - } - subtype = 0; - } else if (is_xbox) { - vendor = USB_VENDOR_MICROSOFT; - if (device->has_xbox_paddles) { - /* Assume Xbox One Elite Series 2 Controller unless/until GCController flows VID/PID */ - product = USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH; - subtype = 1; - } else if (device->has_xbox_share_button) { - /* Assume Xbox Series X Controller unless/until GCController flows VID/PID */ - product = USB_PRODUCT_XBOX_SERIES_X_BLE; - subtype = 1; - } else { - /* Assume Xbox One S Bluetooth Controller unless/until GCController flows VID/PID */ - product = USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH; - subtype = 0; - } - } else if (is_ps4) { - /* Assume DS4 Slim unless/until GCController flows VID/PID */ - vendor = USB_VENDOR_SONY; - product = USB_PRODUCT_SONY_DS4_SLIM; - if (device->has_dualshock_touchpad) { - subtype = 1; - } else { - subtype = 0; + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + if (gamepad.buttonOptions) { + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_BACK); + ++nbuttons; } - } else if (is_ps5) { - vendor = USB_VENDOR_SONY; - product = USB_PRODUCT_SONY_DS5; - subtype = 0; - } else if (is_switch_pro) { - vendor = USB_VENDOR_NINTENDO; - product = USB_PRODUCT_NINTENDO_SWITCH_PRO; - subtype = 0; - } else if (is_switch_joycon_pair) { - vendor = USB_VENDOR_NINTENDO; - product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_PAIR; - subtype = 0; - } else { - vendor = USB_VENDOR_APPLE; - product = 1; - subtype = 1; } + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START); + ++nbuttons; - if (is_backbone_one) { - /* The Backbone app uses share button */ - if ((device->button_mask & (1 << SDL_CONTROLLER_BUTTON_MISC1)) != 0) { - device->button_mask &= ~(1 << SDL_CONTROLLER_BUTTON_MISC1); - --nbuttons; - device->has_xbox_share_button = SDL_FALSE; + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + if (gamepad.buttonMenu) { + has_direct_menu = TRUE; } } +#if TARGET_OS_TV + /* The single menu button isn't very reliable, at least as of tvOS 16.1 */ + if ((device->button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) == 0) { + has_direct_menu = FALSE; + } +#endif + if (!has_direct_menu) { + device->pause_button_index = (nbuttons - 1); + } device->naxes = 6; /* 2 thumbsticks and 2 triggers */ device->nhats = 1; /* d-pad */ device->nbuttons = nbuttons; } else if (controller.gamepad) { - BOOL is_switch_joyconL = IsControllerSwitchJoyConL(controller); - BOOL is_switch_joyconR = IsControllerSwitchJoyConR(controller); int nbuttons = 0; -#ifdef SDL_JOYSTICK_HIDAPI - if ((is_switch_joyconL && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT, 0, "")) || - (is_switch_joyconR && HIDAPI_IsDevicePresent(USB_VENDOR_NINTENDO, USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT, 0, ""))) { - /* The HIDAPI driver is taking care of this device */ - return FALSE; - } -#else - (void)is_switch_joyconL; - (void)is_switch_joyconR; -#endif - - if (is_switch_joyconL) { - vendor = USB_VENDOR_NINTENDO; - product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_LEFT; - subtype = 0; - } else if (is_switch_joyconR) { - vendor = USB_VENDOR_NINTENDO; - product = USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT; - subtype = 0; - } else { - vendor = USB_VENDOR_APPLE; - product = 2; - subtype = 2; - } - /* These buttons are part of the original MFi spec */ device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_A); device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_B); @@ -467,14 +630,9 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_Y); device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_LEFTSHOULDER); device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_RIGHTSHOULDER); -#if TARGET_OS_TV - /* The menu button is used by the OS and not available to applications */ - nbuttons += 6; -#else device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START); nbuttons += 7; - device->uses_pause_handler = SDL_TRUE; -#endif + device->pause_button_index = (nbuttons - 1); device->naxes = 0; /* no traditional analog inputs */ device->nhats = 1; /* d-pad */ @@ -485,35 +643,41 @@ static BOOL IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle int nbuttons = 0; device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_A); - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_B); /* Button X on microGamepad */ - nbuttons += 2; - - device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START); - ++nbuttons; - device->uses_pause_handler = SDL_TRUE; + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_X); /* Button X on microGamepad */ + device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_B); + nbuttons += 3; + device->pause_button_index = (nbuttons - 1); - vendor = USB_VENDOR_APPLE; - product = 3; - subtype = 3; device->naxes = 2; /* treat the touch surface as two axes */ device->nhats = 0; /* apparently the touch surface-as-dpad is buggy */ device->nbuttons = nbuttons; controller.microGamepad.allowsRotation = SDL_GetHintBoolean(SDL_HINT_APPLE_TV_REMOTE_ALLOW_ROTATION, SDL_FALSE); } -#endif /* TARGET_OS_TV */ +#endif + else { + /* We don't know how to get input events from this device */ + return SDL_FALSE; + } - if (vendor == USB_VENDOR_APPLE) { - /* Note that this is an MFI controller and what subtype it is */ - device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, 0, name, 'm', subtype); + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + signature = 0; + signature = SDL_crc16(signature, device->name, SDL_strlen(device->name)); + for (id key in device->axes) { + const char *string = ((NSString *)key).UTF8String; + signature = SDL_crc16(signature, string, SDL_strlen(string)); + } + for (id key in device->buttons) { + const char *string = ((NSString *)key).UTF8String; + signature = SDL_crc16(signature, string, SDL_strlen(string)); + } } else { - device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, 0, name, 0, subtype); + signature = device->button_mask; } + device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, signature, NULL, name, 'm', subtype); - /* Update the GUID with capability bits */ - { - Uint16 *guid16 = (Uint16 *)device->guid.data; - guid16[6] = SDL_SwapLE16(device->button_mask); + if (SDL_ShouldIgnoreJoystick(name, device->guid)) { + return SDL_FALSE; } /* This will be set when the first button press of the controller is @@ -528,15 +692,6 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet { SDL_JoystickDeviceItem *device = deviceList; -#if TARGET_OS_TV - if (!SDL_GetHintBoolean(SDL_HINT_TV_REMOTE_AS_JOYSTICK, SDL_TRUE)) { - /* Ignore devices that aren't actually controllers (e.g. remotes), they'll be handled as keyboard input */ - if (controller && !controller.extendedGamepad && !controller.gamepad && controller.microGamepad) { - return; - } - } -#endif - while (device != NULL) { if (device->controller == controller) { return; @@ -551,6 +706,7 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet device->accelerometer = accelerometer; device->instance_id = SDL_GetNextJoystickInstanceID(); + device->pause_button_index = -1; if (accelerometer) { #ifdef SDL_JOYSTICK_iOS_ACCELEROMETER @@ -568,6 +724,7 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet } else if (controller) { #ifdef SDL_JOYSTICK_MFI if (!IOS_AddMFIJoystickDevice(device, controller)) { + SDL_free(device->name); SDL_free(device); return; } @@ -626,13 +783,20 @@ static void IOS_AddJoystickDevice(GCController *controller, SDL_bool acceleromet #ifdef SDL_JOYSTICK_MFI @autoreleasepool { + /* These were explicitly retained in the struct, so they should be explicitly released before freeing the struct. */ if (device->controller) { - /* The controller was explicitly retained in the struct, so it - * should be explicitly released before freeing the struct. */ GCController *controller = CFBridgingRelease((__bridge CFTypeRef)(device->controller)); controller.controllerPausedHandler = nil; device->controller = nil; } + if (device->axes) { + CFRelease((__bridge CFTypeRef)device->axes); + device->axes = nil; + } + if (device->buttons) { + CFRelease((__bridge CFTypeRef)device->buttons); + device->buttons = nil; + } } #endif /* SDL_JOYSTICK_MFI */ @@ -663,6 +827,10 @@ static void SDLCALL SDL_AppleTVRemoteRotationHintChanged(void *udata, const char static int IOS_JoystickInit(void) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { + return 0; + } + #if defined(__MACOSX__) #if _SDL_HAS_BUILTIN(__builtin_available) if (@available(macOS 10.16, *)) { @@ -757,6 +925,11 @@ static void IOS_JoystickDetect(void) return NULL; } +static int IOS_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int IOS_JoystickGetDevicePlayerIndex(int device_index) { #ifdef SDL_JOYSTICK_MFI @@ -830,11 +1003,11 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) #endif } else { #ifdef SDL_JOYSTICK_MFI - if (device->uses_pause_handler) { + if (device->pause_button_index >= 0) { GCController *controller = device->controller; controller.controllerPausedHandler = ^(GCController *c) { if (joystick->hwdata) { - ++joystick->hwdata->num_pause_presses; + joystick->hwdata->pause_button_pressed = SDL_GetTicks(); } }; } @@ -867,7 +1040,7 @@ static int IOS_JoystickOpen(SDL_Joystick *joystick, int device_index) #endif /* SDL_JOYSTICK_MFI */ } } - if (device->remote) { + if (device->is_siri_remote) { ++SDL_AppleTVRemoteOpenedAsJoystick; } @@ -944,14 +1117,14 @@ static Uint8 IOS_MFIJoystickHatStateForDPad(GCControllerDirectionPad *dpad) static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) { -#if SDL_JOYSTICK_MFI +#ifdef SDL_JOYSTICK_MFI @autoreleasepool { - GCController *controller = joystick->hwdata->controller; + SDL_JoystickDeviceItem *device = joystick->hwdata; + GCController *controller = device->controller; Uint8 hatstate = SDL_HAT_CENTERED; int i; - int pause_button_index = 0; -#ifdef DEBUG_CONTROLLER_STATE +#if defined(DEBUG_CONTROLLER_STATE) && defined(ENABLE_PHYSICAL_INPUT_PROFILE) if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { if (controller.physicalInputProfile) { for (id key in controller.physicalInputProfile.buttons) { @@ -962,12 +1135,51 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) for (id key in controller.physicalInputProfile.axes) { GCControllerAxisInput *axis = controller.physicalInputProfile.axes[key]; if (axis.value != 0.0f) - NSLog(@"Axis %@ = %.2f\n", key, axis.value); + NSLog(@"Axis %@ = %g\n", key, axis.value); + } + for (id key in controller.physicalInputProfile.dpads) { + GCControllerDirectionPad *dpad = controller.physicalInputProfile.dpads[key]; + if (dpad.up.isPressed || dpad.down.isPressed || dpad.left.isPressed || dpad.right.isPressed) { + NSLog(@"Hat %@ =%s%s%s%s\n", key, + dpad.up.isPressed ? " UP" : "", + dpad.down.isPressed ? " DOWN" : "", + dpad.left.isPressed ? " LEFT" : "", + dpad.right.isPressed ? " RIGHT" : ""); + } } } } -#endif +#endif /* DEBUG_CONTROLLER_STATE */ + +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + NSDictionary *elements = controller.physicalInputProfile.elements; + NSDictionary *buttons = controller.physicalInputProfile.buttons; + int axis = 0; + int button = 0; + + for (id key in device->axes) { + Sint16 value; + GCControllerElement *element = elements[key]; + if ([element isKindOfClass:[GCControllerAxisInput class]]) { + value = (Sint16)([(GCControllerAxisInput *)element value] * 32767); + } else { + value = (Sint16)([(GCControllerButtonInput *)element value] * 32767); + } + SDL_PrivateJoystickAxis(joystick, axis++, value); + } + for (id key in device->buttons) { + Uint8 value; + if (button == device->pause_button_index) { + value = (device->pause_button_pressed > 0); + } else { + value = buttons[key].isPressed; + } + SDL_PrivateJoystickButton(joystick, button++, value); + } + } else +#endif if (controller.extendedGamepad) { SDL_bool isstack; GCExtendedGamepad *gamepad = controller.extendedGamepad; @@ -1000,78 +1212,29 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) buttons[button_count++] = gamepad.rightShoulder.isPressed; /* These buttons are available on some newer controllers */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunguarded-availability-new" - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_LEFTSTICK)) { - buttons[button_count++] = gamepad.leftThumbstickButton.isPressed; - } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_RIGHTSTICK)) { - buttons[button_count++] = gamepad.rightThumbstickButton.isPressed; - } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) { - buttons[button_count++] = gamepad.buttonOptions.isPressed; - } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_GUIDE)) { - buttons[button_count++] = gamepad.buttonHome.isPressed; - } - /* This must be the last button, so we can optionally handle it with pause_button_index below */ - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_START)) { - if (joystick->hwdata->uses_pause_handler) { - pause_button_index = button_count; - buttons[button_count++] = joystick->delayed_guide_button; - } else { - buttons[button_count++] = gamepad.buttonMenu.isPressed; - } - } - -#ifdef ENABLE_PHYSICAL_INPUT_PROFILE - if (joystick->hwdata->has_dualshock_touchpad) { - GCControllerDirectionPad *dpad; - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputDualShockTouchpadButton].isPressed; - - dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne]; - if (dpad.xAxis.value || dpad.yAxis.value) { - SDL_PrivateJoystickTouchpad(joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); - } else { - SDL_PrivateJoystickTouchpad(joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f); + if (@available(macOS 10.14.1, iOS 12.1, tvOS 12.1, *)) { + if (device->button_mask & (1 << SDL_CONTROLLER_BUTTON_LEFTSTICK)) { + buttons[button_count++] = gamepad.leftThumbstickButton.isPressed; } - - dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo]; - if (dpad.xAxis.value || dpad.yAxis.value) { - SDL_PrivateJoystickTouchpad(joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); - } else { - SDL_PrivateJoystickTouchpad(joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f); + if (device->button_mask & (1 << SDL_CONTROLLER_BUTTON_RIGHTSTICK)) { + buttons[button_count++] = gamepad.rightThumbstickButton.isPressed; } } - - if (joystick->hwdata->has_xbox_paddles) { - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE1)) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleOne].isPressed; + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + if (device->button_mask & (1 << SDL_CONTROLLER_BUTTON_BACK)) { + buttons[button_count++] = gamepad.buttonOptions.isPressed; } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE2)) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo].isPressed; - } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE3)) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleThree].isPressed; - } - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_PADDLE4)) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed; - } - - /* - SDL_Log("Paddles: [%d,%d,%d,%d]", - controller.physicalInputProfile.buttons[GCInputXboxPaddleOne].isPressed, - controller.physicalInputProfile.buttons[GCInputXboxPaddleTwo].isPressed, - controller.physicalInputProfile.buttons[GCInputXboxPaddleThree].isPressed, - controller.physicalInputProfile.buttons[GCInputXboxPaddleFour].isPressed); - */ } - - if (joystick->hwdata->has_xbox_share_button) { - buttons[button_count++] = controller.physicalInputProfile.buttons[GCInputXboxShareButton].isPressed; + if (device->button_mask & (1 << SDL_CONTROLLER_BUTTON_START)) { + if (device->pause_button_index >= 0) { + /* Guaranteed if buttonMenu is not supported on this OS */ + buttons[button_count++] = (device->pause_button_pressed > 0); + } else { + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + buttons[button_count++] = gamepad.buttonMenu.isPressed; + } + } } -#endif -#pragma clang diagnostic pop hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad); @@ -1083,30 +1246,6 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_PrivateJoystickButton(joystick, i, buttons[i]); } -#ifdef ENABLE_MFI_SENSORS - if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { - GCMotion *motion = controller.motion; - if (motion && motion.sensorsActive) { - float data[3]; - - if (motion.hasRotationRate) { - GCRotationRate rate = motion.rotationRate; - data[0] = rate.x; - data[1] = rate.z; - data[2] = -rate.y; - SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, 0, data, 3); - } - if (motion.hasGravityAndUserAcceleration) { - GCAcceleration accel = motion.acceleration; - data[0] = -accel.x * SDL_STANDARD_GRAVITY; - data[1] = -accel.y * SDL_STANDARD_GRAVITY; - data[2] = -accel.z * SDL_STANDARD_GRAVITY; - SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, 0, data, 3); - } - } - } -#endif /* ENABLE_MFI_SENSORS */ - SDL_small_free(buttons, isstack); } else if (controller.gamepad) { SDL_bool isstack; @@ -1127,8 +1266,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) buttons[button_count++] = gamepad.buttonY.isPressed; buttons[button_count++] = gamepad.leftShoulder.isPressed; buttons[button_count++] = gamepad.rightShoulder.isPressed; - pause_button_index = button_count; - buttons[button_count++] = joystick->delayed_guide_button; + buttons[button_count++] = (device->pause_button_pressed > 0); hatstate = IOS_MFIJoystickHatStateForDPad(gamepad.dpad); @@ -1155,18 +1293,7 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) int button_count = 0; buttons[button_count++] = gamepad.buttonA.isPressed; buttons[button_count++] = gamepad.buttonX.isPressed; -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunguarded-availability-new" - /* This must be the last button, so we can optionally handle it with pause_button_index below */ - if (joystick->hwdata->button_mask & (1 << SDL_CONTROLLER_BUTTON_START)) { - if (joystick->hwdata->uses_pause_handler) { - pause_button_index = button_count; - buttons[button_count++] = joystick->delayed_guide_button; - } else { - buttons[button_count++] = gamepad.buttonMenu.isPressed; - } - } -#pragma clang diagnostic pop + buttons[button_count++] = (device->pause_button_pressed > 0); for (i = 0; i < button_count; i++) { SDL_PrivateJoystickButton(joystick, i, buttons[i]); @@ -1178,14 +1305,60 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick) SDL_PrivateJoystickHat(joystick, 0, hatstate); } - if (joystick->hwdata->uses_pause_handler) { - for (i = 0; i < joystick->hwdata->num_pause_presses; i++) { - SDL_PrivateJoystickButton(joystick, pause_button_index, SDL_PRESSED); - SDL_PrivateJoystickButton(joystick, pause_button_index, SDL_RELEASED); + if (device->pause_button_pressed) { + /* The pause callback is instantaneous, so we extend the duration to allow "holding down" by pressing it repeatedly */ + const int PAUSE_BUTTON_PRESS_DURATION_MS = 250; + if (SDL_TICKS_PASSED(SDL_GetTicks(), device->pause_button_pressed + PAUSE_BUTTON_PRESS_DURATION_MS)) { + device->pause_button_pressed = 0; } - joystick->hwdata->num_pause_presses = 0; } +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + if (device->has_dualshock_touchpad) { + GCControllerDirectionPad *dpad; + + dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne]; + if (dpad.xAxis.value || dpad.yAxis.value) { + SDL_PrivateJoystickTouchpad(joystick, 0, 0, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); + } else { + SDL_PrivateJoystickTouchpad(joystick, 0, 0, SDL_RELEASED, 0.0f, 0.0f, 1.0f); + } + + dpad = controller.physicalInputProfile.dpads[GCInputDualShockTouchpadTwo]; + if (dpad.xAxis.value || dpad.yAxis.value) { + SDL_PrivateJoystickTouchpad(joystick, 0, 1, SDL_PRESSED, (1.0f + dpad.xAxis.value) * 0.5f, 1.0f - (1.0f + dpad.yAxis.value) * 0.5f, 1.0f); + } else { + SDL_PrivateJoystickTouchpad(joystick, 0, 1, SDL_RELEASED, 0.0f, 0.0f, 1.0f); + } + } + } +#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ + +#ifdef ENABLE_MFI_SENSORS + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + GCMotion *motion = controller.motion; + if (motion && motion.sensorsActive) { + float data[3]; + + if (motion.hasRotationRate) { + GCRotationRate rate = motion.rotationRate; + data[0] = rate.x; + data[1] = rate.z; + data[2] = -rate.y; + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, 0, data, 3); + } + if (motion.hasGravityAndUserAcceleration) { + GCAcceleration accel = motion.acceleration; + data[0] = -accel.x * SDL_STANDARD_GRAVITY; + data[1] = -accel.y * SDL_STANDARD_GRAVITY; + data[2] = -accel.z * SDL_STANDARD_GRAVITY; + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, 0, data, 3); + } + } + } +#endif /* ENABLE_MFI_SENSORS */ + #ifdef ENABLE_MFI_BATTERY if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { GCDeviceBattery *battery = controller.battery; @@ -1633,7 +1806,7 @@ static void IOS_JoystickClose(SDL_Joystick *joystick) #endif /* SDL_JOYSTICK_MFI */ } } - if (device->remote) { + if (device->is_siri_remote) { --SDL_AppleTVRemoteOpenedAsJoystick; } } @@ -1674,12 +1847,144 @@ static void IOS_JoystickQuit(void) static SDL_bool IOS_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { +#ifdef ENABLE_PHYSICAL_INPUT_PROFILE + SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); + if (device == NULL) { + return SDL_FALSE; + } + if (device->accelerometer) { + return SDL_FALSE; + } + + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + int axis = 0; + int button = 0; + for (id key in device->axes) { + if ([(NSString *)key isEqualToString:@"Left Thumbstick X Axis"] || + [(NSString *)key isEqualToString:@"Direction Pad X Axis"]) { + out->leftx.kind = EMappingKind_Axis; + out->leftx.target = axis; + } else if ([(NSString *)key isEqualToString:@"Left Thumbstick Y Axis"] || + [(NSString *)key isEqualToString:@"Direction Pad Y Axis"]) { + out->lefty.kind = EMappingKind_Axis; + out->lefty.target = axis; + out->lefty.axis_reversed = SDL_TRUE; + } else if ([(NSString *)key isEqualToString:@"Right Thumbstick X Axis"]) { + out->rightx.kind = EMappingKind_Axis; + out->rightx.target = axis; + } else if ([(NSString *)key isEqualToString:@"Right Thumbstick Y Axis"]) { + out->righty.kind = EMappingKind_Axis; + out->righty.target = axis; + out->righty.axis_reversed = SDL_TRUE; + } else if ([(NSString *)key isEqualToString:GCInputLeftTrigger]) { + out->lefttrigger.kind = EMappingKind_Axis; + out->lefttrigger.target = axis; + out->lefttrigger.half_axis_positive = SDL_TRUE; + } else if ([(NSString *)key isEqualToString:GCInputRightTrigger]) { + out->righttrigger.kind = EMappingKind_Axis; + out->righttrigger.target = axis; + out->righttrigger.half_axis_positive = SDL_TRUE; + } + ++axis; + } + + for (id key in device->buttons) { + SDL_InputMapping *mapping = NULL; + + if ([(NSString *)key isEqualToString:GCInputButtonA]) { + if (device->is_siri_remote > 1) { + /* GCInputButtonA is triggered for any D-Pad press, ignore it in favor of "Button Center" */ + } else { + mapping = &out->a; + } + } else if ([(NSString *)key isEqualToString:GCInputButtonB]) { + if (device->is_switch_joyconL || device->is_switch_joyconR) { + mapping = &out->x; + } else { + mapping = &out->b; + } + } else if ([(NSString *)key isEqualToString:GCInputButtonX]) { + if (device->is_switch_joyconL || device->is_switch_joyconR) { + mapping = &out->b; + } else { + mapping = &out->x; + } + } else if ([(NSString *)key isEqualToString:GCInputButtonY]) { + mapping = &out->y; + } else if ([(NSString *)key isEqualToString:@"Direction Pad Left"]) { + mapping = &out->dpleft; + } else if ([(NSString *)key isEqualToString:@"Direction Pad Right"]) { + mapping = &out->dpright; + } else if ([(NSString *)key isEqualToString:@"Direction Pad Up"]) { + mapping = &out->dpup; + } else if ([(NSString *)key isEqualToString:@"Direction Pad Down"]) { + mapping = &out->dpdown; + } else if ([(NSString *)key isEqualToString:@"Cardinal Direction Pad Left"]) { + mapping = &out->dpleft; + } else if ([(NSString *)key isEqualToString:@"Cardinal Direction Pad Right"]) { + mapping = &out->dpright; + } else if ([(NSString *)key isEqualToString:@"Cardinal Direction Pad Up"]) { + mapping = &out->dpup; + } else if ([(NSString *)key isEqualToString:@"Cardinal Direction Pad Down"]) { + mapping = &out->dpdown; + } else if ([(NSString *)key isEqualToString:GCInputLeftShoulder]) { + mapping = &out->leftshoulder; + } else if ([(NSString *)key isEqualToString:GCInputRightShoulder]) { + mapping = &out->rightshoulder; + } else if ([(NSString *)key isEqualToString:GCInputLeftThumbstickButton]) { + mapping = &out->leftstick; + } else if ([(NSString *)key isEqualToString:GCInputRightThumbstickButton]) { + mapping = &out->rightstick; + } else if ([(NSString *)key isEqualToString:@"Button Home"]) { + mapping = &out->guide; + } else if ([(NSString *)key isEqualToString:GCInputButtonMenu]) { + if (device->is_siri_remote) { + mapping = &out->b; + } else { + mapping = &out->start; + } + } else if ([(NSString *)key isEqualToString:GCInputButtonOptions]) { + mapping = &out->back; + } else if ([(NSString *)key isEqualToString:@"Button Share"]) { + mapping = &out->misc1; + } else if ([(NSString *)key isEqualToString:GCInputXboxPaddleOne]) { + mapping = &out->paddle1; + } else if ([(NSString *)key isEqualToString:GCInputXboxPaddleTwo]) { + mapping = &out->paddle3; + } else if ([(NSString *)key isEqualToString:GCInputXboxPaddleThree]) { + mapping = &out->paddle2; + } else if ([(NSString *)key isEqualToString:GCInputXboxPaddleFour]) { + mapping = &out->paddle4; + } else if ([(NSString *)key isEqualToString:GCInputLeftTrigger]) { + mapping = &out->lefttrigger; + } else if ([(NSString *)key isEqualToString:GCInputRightTrigger]) { + mapping = &out->righttrigger; + } else if ([(NSString *)key isEqualToString:GCInputDualShockTouchpadButton]) { + mapping = &out->touchpad; + } else if ([(NSString *)key isEqualToString:@"Button Center"]) { + mapping = &out->a; + } + if (mapping && mapping->kind == EMappingKind_None) { + mapping->kind = EMappingKind_Button; + mapping->target = button; + } + ++button; + } + + return SDL_TRUE; + } +#endif /* ENABLE_PHYSICAL_INPUT_PROFILE */ + return SDL_FALSE; } #if defined(SDL_JOYSTICK_MFI) && defined(__MACOSX__) SDL_bool IOS_SupportedHIDDevice(IOHIDDeviceRef device) { + if (!SDL_GetHintBoolean(SDL_HINT_JOYSTICK_MFI, SDL_TRUE)) { + return SDL_FALSE; + } + if (@available(macOS 10.16, *)) { const int MAX_ATTEMPTS = 3; for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) { @@ -1708,6 +2013,10 @@ static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char * static GCControllerDirectionPad *GetDirectionalPadForController(GCController *controller) { + if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) { + return controller.physicalInputProfile.dpads[GCInputDirectionPad]; + } + if (controller.extendedGamepad) { return controller.extendedGamepad.dpad; } @@ -1885,6 +2194,7 @@ static void GetAppleSFSymbolsNameForElement(GCControllerElement *element, char * IOS_JoystickDetect, IOS_JoystickGetDeviceName, IOS_JoystickGetDevicePath, + IOS_JoystickGetDeviceSteamVirtualGamepadSlot, IOS_JoystickGetDevicePlayerIndex, IOS_JoystickSetDevicePlayerIndex, IOS_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick_c.h b/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick_c.h index bf5311c986..84a4e71a3a 100644 --- a/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick_c.h +++ b/vs/sdl2/src/joystick/iphoneos/SDL_mfijoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,18 +26,19 @@ #include "SDL_stdinc.h" #include "../SDL_sysjoystick.h" +#import +#import + @class GCController; typedef struct joystick_hwdata { SDL_bool accelerometer; - SDL_bool remote; GCController __unsafe_unretained *controller; void *rumble; - SDL_bool uses_pause_handler; - int num_pause_presses; - Uint32 pause_button_down_time; + int pause_button_index; + Uint32 pause_button_pressed; char *name; SDL_Joystick *joystick; @@ -48,6 +49,20 @@ typedef struct joystick_hwdata int nbuttons; int nhats; Uint32 button_mask; + SDL_bool is_xbox; + SDL_bool is_ps4; + SDL_bool is_ps5; + SDL_bool is_switch_pro; + SDL_bool is_switch_joycon_pair; + SDL_bool is_switch_joyconL; + SDL_bool is_switch_joyconR; + SDL_bool is_stadia; + SDL_bool is_backbone_one; + int is_siri_remote; + + NSArray __unsafe_unretained *axes; + NSArray __unsafe_unretained *buttons; + SDL_bool has_dualshock_touchpad; SDL_bool has_xbox_paddles; SDL_bool has_xbox_share_button; diff --git a/vs/sdl2/src/joystick/linux/SDL_sysjoystick.c b/vs/sdl2/src/joystick/linux/SDL_sysjoystick.c index 06f227b67b..bb7c31cedc 100644 --- a/vs/sdl2/src/joystick/linux/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/linux/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +53,10 @@ #include "../hidapi/SDL_hidapijoystick_c.h" /* This isn't defined in older Linux kernel headers */ +#ifndef MSC_TIMESTAMP +#define MSC_TIMESTAMP 0x05 +#endif + #ifndef SYN_DROPPED #define SYN_DROPPED 3 #endif @@ -119,6 +123,7 @@ #define BTN_TRIGGER_HAPPY40 0x2e7 #endif + #include "../../core/linux/SDL_evdev_capabilities.h" #include "../../core/linux/SDL_udev.h" #include "../../core/linux/SDL_sandbox.h" @@ -141,8 +146,8 @@ typedef enum static EnumerationMethod enumeration_method = ENUMERATION_UNSET; static SDL_bool IsJoystickJSNode(const char *node); -static int MaybeAddDevice(const char *path); -static int MaybeRemoveDevice(const char *path); +static void MaybeAddDevice(const char *path); +static void MaybeRemoveDevice(const char *path); /* A linked list of available joysticks */ typedef struct SDL_joylist_item @@ -152,6 +157,7 @@ typedef struct SDL_joylist_item char *name; /* "SideWinder 3D Pro" or whatever */ SDL_JoystickGUID guid; dev_t devnum; + int steam_virtual_gamepad_slot; struct joystick_hwdata *hwdata; struct SDL_joylist_item *next; @@ -162,10 +168,20 @@ typedef struct SDL_joylist_item SDL_GamepadMapping *mapping; } SDL_joylist_item; +/* A linked list of available gamepad sensors */ +typedef struct SDL_sensorlist_item +{ + char *path; /* "/dev/input/event2" or whatever */ + dev_t devnum; + struct joystick_hwdata *hwdata; + struct SDL_sensorlist_item *next; +} SDL_sensorlist_item; + static SDL_bool SDL_classic_joysticks = SDL_FALSE; -static SDL_joylist_item *SDL_joylist = NULL; -static SDL_joylist_item *SDL_joylist_tail = NULL; -static int numjoysticks = 0; +static SDL_joylist_item *SDL_joylist SDL_GUARDED_BY(SDL_joystick_lock) = NULL; +static SDL_joylist_item *SDL_joylist_tail SDL_GUARDED_BY(SDL_joystick_lock) = NULL; +static int numjoysticks SDL_GUARDED_BY(SDL_joystick_lock) = 0; +static SDL_sensorlist_item *SDL_sensorlist SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static int inotify_fd = -1; static Uint32 last_joy_detect_time; @@ -205,13 +221,29 @@ static SDL_bool IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, } #endif /* SDL_JOYSTICK_HIDAPI */ -static int GuessIsJoystick(int fd) +static SDL_bool GetSteamVirtualGamepadSlot(int fd, int *slot) +{ + char name[128]; + + if (ioctl(fd, EVIOCGNAME(sizeof(name)), name) > 0) { + const char *digits = SDL_strstr(name, "pad "); + if (digits) { + digits += 4; + if (SDL_isdigit(*digits)) { + *slot = SDL_atoi(digits); + return SDL_TRUE; + } + } + } + return SDL_FALSE; +} + +static int GuessDeviceClass(int fd) { unsigned long evbit[NBITS(EV_MAX)] = { 0 }; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; unsigned long absbit[NBITS(ABS_MAX)] = { 0 }; unsigned long relbit[NBITS(REL_MAX)] = { 0 }; - int devclass; if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) || (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) || @@ -220,43 +252,68 @@ static int GuessIsJoystick(int fd) return 0; } - devclass = SDL_EVDEV_GuessDeviceClass(evbit, absbit, keybit, relbit); + return SDL_EVDEV_GuessDeviceClass(evbit, absbit, keybit, relbit); +} + +static int GuessIsJoystick(int fd) +{ + if (GuessDeviceClass(fd) & SDL_UDEV_DEVICE_JOYSTICK) { + return 1; + } + + return 0; +} - if (devclass & SDL_UDEV_DEVICE_JOYSTICK) { +static int GuessIsSensor(int fd) +{ + if (GuessDeviceClass(fd) & SDL_UDEV_DEVICE_ACCELEROMETER) { return 1; } return 0; } -static int IsJoystick(const char *path, int fd, char **name_return, SDL_JoystickGUID *guid) +static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid) { struct input_id inpid; char *name; char product_string[128]; + int class = 0; - if (ioctl(fd, JSIOCGNAME(sizeof(product_string)), product_string) >= 0) { - SDL_zero(inpid); -#if SDL_USE_LIBUDEV - SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version); + SDL_zero(inpid); +#ifdef SDL_USE_LIBUDEV + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + !(class & SDL_UDEV_DEVICE_JOYSTICK)) { + return 0; + } #endif - } else { - /* When udev is enabled we only get joystick devices here, so there's no need to test them */ - if (enumeration_method != ENUMERATION_LIBUDEV && !GuessIsJoystick(fd)) { + + if (fd && *fd < 0) { + *fd = open(path, O_RDONLY | O_CLOEXEC, 0); + } + if (!fd || *fd < 0) { + return 0; + } + + if (ioctl(*fd, JSIOCGNAME(sizeof(product_string)), product_string) <= 0) { + /* When udev enumeration or classification, we only got joysticks here, so no need to test */ + if (enumeration_method != ENUMERATION_LIBUDEV && !class && !GuessIsJoystick(*fd)) { return 0; } - if (ioctl(fd, EVIOCGID, &inpid) < 0) { + /* Could have vendor and product already from udev, but should agree with evdev */ + if (ioctl(*fd, EVIOCGID, &inpid) < 0) { return 0; } - if (ioctl(fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) { + if (ioctl(*fd, EVIOCGNAME(sizeof(product_string)), product_string) < 0) { return 0; } } name = SDL_CreateJoystickName(inpid.vendor, inpid.product, NULL, product_string); - if (name == NULL) { + if (!name) { return 0; } @@ -269,26 +326,66 @@ static int IsJoystick(const char *path, int fd, char **name_return, SDL_Joystick } #endif - FixupDeviceInfoForMapping(fd, &inpid); + FixupDeviceInfoForMapping(*fd, &inpid); #ifdef DEBUG_JOYSTICK SDL_Log("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", name, inpid.bustype, inpid.vendor, inpid.product, inpid.version); #endif - *guid = SDL_CreateJoystickGUID(inpid.bustype, inpid.vendor, inpid.product, inpid.version, name, 0, 0); + *guid = SDL_CreateJoystickGUID(inpid.bustype, inpid.vendor, inpid.product, inpid.version, NULL, product_string, 0, 0); if (SDL_ShouldIgnoreJoystick(name, *guid)) { SDL_free(name); return 0; } *name_return = name; + *vendor_return = inpid.vendor; + *product_return = inpid.product; + return 1; +} + +static int IsSensor(const char *path, int *fd) +{ + struct input_id inpid; + int class = 0; + + SDL_zero(inpid); +#ifdef SDL_USE_LIBUDEV + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + !(class & SDL_UDEV_DEVICE_ACCELEROMETER)) { + return 0; + } +#endif + + if (fd && *fd < 0) { + *fd = open(path, O_RDONLY | O_CLOEXEC, 0); + } + if (!fd || *fd < 0) { + return 0; + } + + if (!class && !GuessIsSensor(*fd)) { + return 0; + } + + if (ioctl(*fd, EVIOCGID, &inpid) < 0) { + return 0; + } + + if (inpid.vendor == USB_VENDOR_NINTENDO && inpid.product == USB_PRODUCT_NINTENDO_WII_REMOTE) { + /* Wii extension controls */ + /* These may create 3 sensor devices but we only support reading from 1: ignore them */ + return 0; + } + return 1; } -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - if (devpath == NULL) { + if (!devpath) { return; } @@ -331,84 +428,126 @@ static void FreeJoylistItem(SDL_joylist_item *item) SDL_free(item); } -static int MaybeAddDevice(const char *path) +static void FreeSensorlistItem(SDL_sensorlist_item *item) +{ + SDL_free(item->path); + SDL_free(item); +} + +static void MaybeAddDevice(const char *path) { struct stat sb; int fd = -1; - int isstick = 0; char *name = NULL; + Uint16 vendor, product; SDL_JoystickGUID guid; SDL_joylist_item *item; + SDL_sensorlist_item *item_sensor; - if (path == NULL) { - return -1; + if (!path) { + return; } if (stat(path, &sb) == -1) { - return -1; + return; } + SDL_LockJoysticks(); + /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { - return -1; /* already have this one */ + goto done; /* already have this one */ } } - - fd = open(path, O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) { - return -1; + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { + if (sb.st_rdev == item_sensor->devnum) { + goto done; /* already have this one */ + } } #ifdef DEBUG_INPUT_EVENTS SDL_Log("Checking %s\n", path); #endif - isstick = IsJoystick(path, fd, &name, &guid); - close(fd); - if (!isstick) { - return -1; - } + if (IsJoystick(path, &fd, &name, &vendor, &product, &guid)) { +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("found joystick: %s\n", path); +#endif + item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); + if (!item) { + SDL_free(name); + goto done; + } - item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { - SDL_free(name); - return -1; - } + item->devnum = sb.st_rdev; + item->steam_virtual_gamepad_slot = -1; + item->path = SDL_strdup(path); + item->name = name; + item->guid = guid; - item->devnum = sb.st_rdev; - item->path = SDL_strdup(path); - item->name = name; - item->guid = guid; + if (vendor == USB_VENDOR_VALVE && + product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { + GetSteamVirtualGamepadSlot(fd, &item->steam_virtual_gamepad_slot); + } - if ((item->path == NULL) || (item->name == NULL)) { - FreeJoylistItem(item); - return -1; - } + if ((!item->path) || (!item->name)) { + FreeJoylistItem(item); + goto done; + } - item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { - SDL_joylist = SDL_joylist_tail = item; - } else { - SDL_joylist_tail->next = item; - SDL_joylist_tail = item; + item->device_instance = SDL_GetNextJoystickInstanceID(); + if (!SDL_joylist_tail) { + SDL_joylist = SDL_joylist_tail = item; + } else { + SDL_joylist_tail->next = item; + SDL_joylist_tail = item; + } + + /* Need to increment the joystick count before we post the event */ + ++numjoysticks; + + SDL_PrivateJoystickAdded(item->device_instance); + goto done; } - /* Need to increment the joystick count before we post the event */ - ++numjoysticks; + if (IsSensor(path, &fd)) { +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("found sensor: %s\n", path); +#endif + item_sensor = (SDL_sensorlist_item *)SDL_calloc(1, sizeof(SDL_sensorlist_item)); + if (!item_sensor) { + goto done; + } + item_sensor->devnum = sb.st_rdev; + item_sensor->path = SDL_strdup(path); - SDL_PrivateJoystickAdded(item->device_instance); + if (!item_sensor->path) { + FreeSensorlistItem(item_sensor); + goto done; + } - return numjoysticks; + item_sensor->next = SDL_sensorlist; + SDL_sensorlist = item_sensor; + goto done; + } + +done: + if (fd >= 0) { + close(fd); + } + SDL_UnlockJoysticks(); } static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) { + SDL_AssertJoysticksLocked(); + if (item->hwdata) { item->hwdata->item = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -426,38 +565,73 @@ static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) FreeJoylistItem(item); } -static int MaybeRemoveDevice(const char *path) +static void RemoveSensorlistItem(SDL_sensorlist_item *item, SDL_sensorlist_item *prev) +{ + SDL_AssertJoysticksLocked(); + + if (item->hwdata) { + item->hwdata->item_sensor = NULL; + } + + if (prev) { + prev->next = item->next; + } else { + SDL_assert(SDL_sensorlist == item); + SDL_sensorlist = item->next; + } + + /* Do not call SDL_PrivateJoystickRemoved here as RemoveJoylistItem will do it, + * assuming both sensor and joy item are removed at the same time */ + FreeSensorlistItem(item); +} + +static void MaybeRemoveDevice(const char *path) { SDL_joylist_item *item; SDL_joylist_item *prev = NULL; + SDL_sensorlist_item *item_sensor; + SDL_sensorlist_item *prev_sensor = NULL; - if (path == NULL) { - return -1; + if (!path) { + return; } - for (item = SDL_joylist; item != NULL; item = item->next) { + SDL_LockJoysticks(); + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->path) == 0) { - const int retval = item->device_instance; RemoveJoylistItem(item, prev); - return retval; + goto done; } prev = item; } - - return -1; + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { + /* found it, remove it. */ + if (SDL_strcmp(path, item_sensor->path) == 0) { + RemoveSensorlistItem(item_sensor, prev_sensor); + goto done; + } + prev_sensor = item_sensor; + } +done: + SDL_UnlockJoysticks(); } static void HandlePendingRemovals(void) { SDL_joylist_item *prev = NULL; - SDL_joylist_item *item = SDL_joylist; + SDL_joylist_item *item = NULL; + SDL_sensorlist_item *prev_sensor = NULL; + SDL_sensorlist_item *item_sensor = NULL; + + SDL_AssertJoysticksLocked(); - while (item != NULL) { + item = SDL_joylist; + while (item) { if (item->hwdata && item->hwdata->gone) { RemoveJoylistItem(item, prev); - if (prev != NULL) { + if (prev) { item = prev->next; } else { item = SDL_joylist; @@ -467,6 +641,22 @@ static void HandlePendingRemovals(void) item = item->next; } } + + item_sensor = SDL_sensorlist; + while (item_sensor) { + if (item_sensor->hwdata && item_sensor->hwdata->sensor_gone) { + RemoveSensorlistItem(item_sensor, prev_sensor); + + if (prev_sensor) { + item_sensor = prev_sensor->next; + } else { + item_sensor = SDL_sensorlist; + } + } else { + prev_sensor = item_sensor; + item_sensor = item_sensor->next; + } + } } static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, int *device_instance) @@ -474,7 +664,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG SDL_joylist_item *item; item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return SDL_FALSE; } @@ -483,13 +673,14 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG item->guid = guid; item->m_bSteamController = SDL_TRUE; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return SDL_FALSE; } *device_instance = item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + SDL_LockJoysticks(); + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -500,6 +691,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG ++numjoysticks; SDL_PrivateJoystickAdded(item->device_instance); + SDL_UnlockJoysticks(); return SDL_TRUE; } @@ -509,14 +701,16 @@ static void SteamControllerDisconnectedCallback(int device_instance) SDL_joylist_item *item; SDL_joylist_item *prev = NULL; - for (item = SDL_joylist; item != NULL; item = item->next) { + SDL_LockJoysticks(); + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (item->device_instance == device_instance) { RemoveJoylistItem(item, prev); - return; + break; } prev = item; } + SDL_UnlockJoysticks(); } static int StrHasPrefix(const char *string, const char *prefix) @@ -690,6 +884,102 @@ static int sort_entries(const void *_a, const void *_b) return numA - numB; } +typedef struct +{ + char *path; + int slot; +} VirtualGamepadEntry; + +static int SDLCALL sort_virtual_gamepads(const void *_a, const void *_b) +{ + const VirtualGamepadEntry *a = (const VirtualGamepadEntry *)_a; + const VirtualGamepadEntry *b = (const VirtualGamepadEntry *)_b; + return a->slot - b->slot; +} + +static void LINUX_ScanSteamVirtualGamepads(void) +{ + int i, count; + int fd; + struct dirent **entries = NULL; + char path[PATH_MAX]; + struct input_id inpid; + int num_virtual_gamepads = 0; + int virtual_gamepad_slot; + VirtualGamepadEntry *virtual_gamepads = NULL; +#ifdef SDL_USE_LIBUDEV + int class; +#endif + + count = scandir("/dev/input", &entries, filter_entries, NULL); + for (i = 0; i < count; ++i) { + (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); + +#ifdef SDL_USE_LIBUDEV + /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ + class = 0; + SDL_zero(inpid); + if (SDL_UDEV_GetProductInfo(path, &inpid.vendor, &inpid.product, &inpid.version, &class) && + (inpid.vendor != USB_VENDOR_VALVE || inpid.product != USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD)) { + free(entries[i]); /* This should NOT be SDL_free() */ + continue; + } +#endif + fd = open(path, O_RDONLY | O_CLOEXEC, 0); + if (fd >= 0) { + if (ioctl(fd, EVIOCGID, &inpid) == 0 && + inpid.vendor == USB_VENDOR_VALVE && + inpid.product == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD && + GetSteamVirtualGamepadSlot(fd, &virtual_gamepad_slot)) { + VirtualGamepadEntry *new_virtual_gamepads = (VirtualGamepadEntry *)SDL_realloc(virtual_gamepads, (num_virtual_gamepads + 1) * sizeof(*virtual_gamepads)); + if (new_virtual_gamepads) { + VirtualGamepadEntry *entry = &new_virtual_gamepads[num_virtual_gamepads]; + entry->path = SDL_strdup(path); + entry->slot = virtual_gamepad_slot; + if (entry->path) { + virtual_gamepads = new_virtual_gamepads; + ++num_virtual_gamepads; + } else { + SDL_free(entry->path); + SDL_free(new_virtual_gamepads); + } + } + } + close(fd); + } + free(entries[i]); /* This should NOT be SDL_free() */ + } + free(entries); /* This should NOT be SDL_free() */ + + if (num_virtual_gamepads > 1) { + SDL_qsort(virtual_gamepads, num_virtual_gamepads, sizeof(*virtual_gamepads), sort_virtual_gamepads); + } + for (i = 0; i < num_virtual_gamepads; ++i) { + MaybeAddDevice(virtual_gamepads[i].path); + SDL_free(virtual_gamepads[i].path); + } + SDL_free(virtual_gamepads); +} + +static void LINUX_ScanInputDevices(void) +{ + int i, count; + struct dirent **entries = NULL; + char path[PATH_MAX]; + + count = scandir("/dev/input", &entries, filter_entries, NULL); + if (count > 1) { + SDL_qsort(entries, count, sizeof(*entries), sort_entries); + } + for (i = 0; i < count; ++i) { + (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); + MaybeAddDevice(path); + + free(entries[i]); /* This should NOT be SDL_free() */ + } + free(entries); /* This should NOT be SDL_free() */ +} + static void LINUX_FallbackJoystickDetect(void) { const Uint32 SDL_JOY_DETECT_INTERVAL_MS = 3000; /* Update every 3 seconds */ @@ -700,21 +990,10 @@ static void LINUX_FallbackJoystickDetect(void) /* Opening input devices can generate synchronous device I/O, so avoid it if we can */ if (stat("/dev/input", &sb) == 0 && sb.st_mtime != last_input_dir_mtime) { - int i, count; - struct dirent **entries = NULL; - char path[PATH_MAX]; - - count = scandir("/dev/input", &entries, filter_entries, NULL); - if (count > 1) { - qsort(entries, count, sizeof(*entries), sort_entries); - } - for (i = 0; i < count; ++i) { - (void)SDL_snprintf(path, SDL_arraysize(path), "/dev/input/%s", entries[i]->d_name); - MaybeAddDevice(path); + /* Look for Steam virtual gamepads first, and sort by Steam controller slot */ + LINUX_ScanSteamVirtualGamepads(); - free(entries[i]); /* This should NOT be SDL_free() */ - } - free(entries); /* This should NOT be SDL_free() */ + LINUX_ScanInputDevices(); last_input_dir_mtime = sb.st_mtime; } @@ -725,7 +1004,7 @@ static void LINUX_FallbackJoystickDetect(void) static void LINUX_JoystickDetect(void) { -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV if (enumeration_method == ENUMERATION_LIBUDEV) { SDL_UDEV_Poll(); } else @@ -747,19 +1026,22 @@ static void LINUX_JoystickDetect(void) static int LINUX_JoystickInit(void) { const char *devices = SDL_GetHint(SDL_HINT_JOYSTICK_DEVICE); +#ifdef SDL_USE_LIBUDEV + int udev_status = SDL_UDEV_Init(); +#endif SDL_classic_joysticks = SDL_GetHintBoolean(SDL_HINT_LINUX_JOYSTICK_CLASSIC, SDL_FALSE); enumeration_method = ENUMERATION_UNSET; /* First see if the user specified one or more joysticks to use */ - if (devices != NULL) { + if (devices) { char *envcopy, *envpath, *delim; envcopy = SDL_strdup(devices); envpath = envcopy; - while (envpath != NULL) { + while (envpath) { delim = SDL_strchr(envpath, ':'); - if (delim != NULL) { + if (delim) { *delim++ = '\0'; } MaybeAddDevice(envpath); @@ -778,7 +1060,7 @@ static int LINUX_JoystickInit(void) /* Manually scan first, since we sort by device number and udev doesn't */ LINUX_JoystickDetect(); -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV if (enumeration_method == ENUMERATION_UNSET) { if (SDL_GetHintBoolean("SDL_JOYSTICK_DISABLE_UDEV", SDL_FALSE)) { SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, @@ -797,21 +1079,24 @@ static int LINUX_JoystickInit(void) } if (enumeration_method == ENUMERATION_LIBUDEV) { - if (SDL_UDEV_Init() < 0) { - return SDL_SetError("Could not initialize UDEV"); - } + if (udev_status == 0) { + /* Set up the udev callback */ + if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { + SDL_UDEV_Quit(); + return SDL_SetError("Could not set up joystick <-> udev callback"); + } - /* Set up the udev callback */ - if (SDL_UDEV_AddCallback(joystick_udev_callback) < 0) { - SDL_UDEV_Quit(); - return SDL_SetError("Could not set up joystick <-> udev callback"); + /* Force a scan to build the initial device list */ + SDL_UDEV_Scan(); + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_INPUT, + "udev init failed, disabling udev integration"); + enumeration_method = ENUMERATION_FALLBACK; } - - /* Force a scan to build the initial device list */ - SDL_UDEV_Scan(); - } else + } #endif - { + + if (enumeration_method != ENUMERATION_LIBUDEV) { #if defined(HAVE_INOTIFY) inotify_fd = SDL_inotify_init1(); @@ -842,17 +1127,22 @@ static int LINUX_JoystickInit(void) static int LINUX_JoystickGetCount(void) { + SDL_AssertJoysticksLocked(); + return numjoysticks; } static SDL_joylist_item *JoystickByDevIndex(int device_index) { - SDL_joylist_item *item = SDL_joylist; + SDL_joylist_item *item; + + SDL_AssertJoysticksLocked(); if ((device_index < 0) || (device_index >= numjoysticks)) { return NULL; } + item = SDL_joylist; while (device_index > 0) { SDL_assert(item != NULL); device_index--; @@ -872,6 +1162,11 @@ static const char *LINUX_JoystickGetDevicePath(int device_index) return JoystickByDevIndex(device_index)->path; } +static int LINUX_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return JoystickByDevIndex(device_index)->steam_virtual_gamepad_slot; +} + static int LINUX_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -901,7 +1196,7 @@ static int allocate_hatdata(SDL_Joystick *joystick) joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc(joystick->nhats * sizeof(struct hwdata_hat)); - if (joystick->hwdata->hats == NULL) { + if (!joystick->hwdata->hats) { return -1; } for (i = 0; i < joystick->nhats; ++i) { @@ -920,7 +1215,7 @@ static int allocate_balldata(SDL_Joystick *joystick) joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc(joystick->nballs * sizeof(struct hwdata_ball)); - if (joystick->hwdata->balls == NULL) { + if (!joystick->hwdata->balls) { return -1; } for (i = 0; i < joystick->nballs; ++i) { @@ -939,7 +1234,7 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct * other continuous analog axis, so we have to guess. */ /* If both axes are missing, they're not anything. */ - if (absinfo_x == NULL && absinfo_y == NULL) { + if (!absinfo_x && !absinfo_y) { return SDL_FALSE; } @@ -949,12 +1244,12 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct } /* If both axes have ranges constrained between -1 and 1, they're definitely digital. */ - if ((absinfo_x == NULL || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (absinfo_y == NULL || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { + if ((!absinfo_x || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (!absinfo_y || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { return SDL_TRUE; } /* If both axes lack fuzz, flat, and resolution values, they're probably digital. */ - if ((absinfo_x == NULL || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (absinfo_y == NULL || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { + if ((!absinfo_x || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (!absinfo_y || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { return SDL_TRUE; } @@ -962,7 +1257,7 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct return SDL_FALSE; } -static void ConfigJoystick(SDL_Joystick *joystick, int fd) +static void ConfigJoystick(SDL_Joystick *joystick, int fd, int fd_sensor) { int i, t; unsigned long keybit[NBITS(KEY_MAX)] = { 0 }; @@ -1041,7 +1336,7 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd) } for (i = 0; i < ABS_MAX; ++i) { /* Skip digital hats */ - if (joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) { + if (i >= ABS_HAT0X && i <= ABS_HAT3Y && joystick->hwdata->has_hat[(i - ABS_HAT0X) / 2]) { continue; } if (test_bit(i, absbit)) { @@ -1153,6 +1448,45 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd) } } + /* Sensors are only available through the new unified event API */ + if (fd_sensor >= 0 && (ioctl(fd_sensor, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0)) { + if (test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) && test_bit(ABS_Z, absbit)) { + joystick->hwdata->has_accelerometer = SDL_TRUE; + for (i = 0; i < 3; ++i) { + struct input_absinfo absinfo; + if (ioctl(fd_sensor, EVIOCGABS(ABS_X + i), &absinfo) < 0) { + joystick->hwdata->has_accelerometer = SDL_FALSE; + break; /* do not report an accelerometer if we can't read all axes */ + } + joystick->hwdata->accelerometer_scale[i] = absinfo.resolution; +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Joystick has accelerometer axis: 0x%.2x\n", ABS_X + i); + SDL_Log("Values = { val:%d, min:%d, max:%d, fuzz:%d, flat:%d, res:%d }\n", + absinfo.value, absinfo.minimum, absinfo.maximum, + absinfo.fuzz, absinfo.flat, absinfo.resolution); +#endif /* DEBUG_INPUT_EVENTS */ + } + } + + if (test_bit(ABS_RX, absbit) && test_bit(ABS_RY, absbit) && test_bit(ABS_RZ, absbit)) { + joystick->hwdata->has_gyro = SDL_TRUE; + for (i = 0; i < 3; ++i) { + struct input_absinfo absinfo; + if (ioctl(fd_sensor, EVIOCGABS(ABS_RX + i), &absinfo) < 0) { + joystick->hwdata->has_gyro = SDL_FALSE; + break; /* do not report a gyro if we can't read all axes */ + } + joystick->hwdata->gyro_scale[i] = absinfo.resolution; +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Joystick has gyro axis: 0x%.2x\n", ABS_RX + i); + SDL_Log("Values = { val:%d, min:%d, max:%d, fuzz:%d, flat:%d, res:%d }\n", + absinfo.value, absinfo.minimum, absinfo.maximum, + absinfo.fuzz, absinfo.flat, absinfo.resolution); +#endif /* DEBUG_INPUT_EVENTS */ + } + } + } + /* Allocate data to keep track of these thingamajigs */ if (joystick->nhats > 0) { if (allocate_hatdata(joystick) < 0) { @@ -1180,11 +1514,12 @@ static void ConfigJoystick(SDL_Joystick *joystick, int fd) without adding an opened SDL_Joystick object to the system. This expects `joystick->hwdata` to be allocated and will not free it on error. Returns -1 on error, 0 on success. */ -static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) +static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item, SDL_sensorlist_item *item_sensor) { SDL_AssertJoysticksLocked(); joystick->hwdata->item = item; + joystick->hwdata->item_sensor = item_sensor; joystick->hwdata->guid = item->guid; joystick->hwdata->effect.id = -1; joystick->hwdata->m_bSteamController = item->m_bSteamController; @@ -1193,12 +1528,14 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) if (item->m_bSteamController) { joystick->hwdata->fd = -1; + joystick->hwdata->fd_sensor = -1; SDL_GetSteamControllerInputs(&joystick->nbuttons, &joystick->naxes, &joystick->nhats); } else { + int fd = -1, fd_sensor = -1; /* Try read-write first, so we can do rumble */ - int fd = open(item->path, O_RDWR | O_CLOEXEC, 0); + fd = open(item->path, O_RDWR | O_CLOEXEC, 0); if (fd < 0) { /* Try read-only again, at least we'll get events in this case */ fd = open(item->path, O_RDONLY | O_CLOEXEC, 0); @@ -1206,23 +1543,88 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) if (fd < 0) { return SDL_SetError("Unable to open %s", item->path); } + /* If opening sensor fail, continue with buttons and axes only */ + if (item_sensor) { + fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0); + } joystick->hwdata->fd = fd; + joystick->hwdata->fd_sensor = fd_sensor; joystick->hwdata->fname = SDL_strdup(item->path); - if (joystick->hwdata->fname == NULL) { + if (!joystick->hwdata->fname) { close(fd); + if (fd_sensor >= 0) { + close(fd_sensor); + } return SDL_OutOfMemory(); } /* Set the joystick to non-blocking read mode */ fcntl(fd, F_SETFL, O_NONBLOCK); + if (fd_sensor >= 0) { + fcntl(fd_sensor, F_SETFL, O_NONBLOCK); + } /* Get the number of buttons and axes on the joystick */ - ConfigJoystick(joystick, fd); + ConfigJoystick(joystick, fd, fd_sensor); } return 0; } +static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) +{ + SDL_sensorlist_item *item_sensor; + char uniq_item[128]; + int fd_item = -1; + + SDL_AssertJoysticksLocked(); + + if (!item || !SDL_sensorlist) { + return NULL; + } + + SDL_memset(uniq_item, 0, sizeof(uniq_item)); + fd_item = open(item->path, O_RDONLY | O_CLOEXEC, 0); + if (fd_item < 0) { + return NULL; + } + if (ioctl(fd_item, EVIOCGUNIQ(sizeof(uniq_item) - 1), &uniq_item) < 0) { + return NULL; + } + close(fd_item); +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Joystick UNIQ: %s\n", uniq_item); +#endif /* DEBUG_INPUT_EVENTS */ + + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { + char uniq_sensor[128]; + int fd_sensor = -1; + if (item_sensor->hwdata) { + /* already associated with another joystick */ + continue; + } + + SDL_memset(uniq_sensor, 0, sizeof(uniq_sensor)); + fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0); + if (fd_sensor < 0) { + continue; + } + if (ioctl(fd_sensor, EVIOCGUNIQ(sizeof(uniq_sensor) - 1), &uniq_sensor) < 0) { + close(fd_sensor); + continue; + } + close(fd_sensor); +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Sensor UNIQ: %s\n", uniq_sensor); +#endif /* DEBUG_INPUT_EVENTS */ + + if (SDL_strcmp(uniq_item, uniq_sensor) == 0) { + return item_sensor; + } + } + return NULL; +} + /* 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. @@ -1230,33 +1632,52 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item) */ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) { - SDL_joylist_item *item = JoystickByDevIndex(device_index); + SDL_joylist_item *item; + SDL_sensorlist_item *item_sensor; SDL_AssertJoysticksLocked(); - if (item == NULL) { + item = JoystickByDevIndex(device_index); + if (!item) { return SDL_SetError("No such device"); } joystick->instance_id = item->device_instance; joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { return SDL_OutOfMemory(); } - if (PrepareJoystickHwdata(joystick, item) == -1) { + item_sensor = GetSensor(item); + if (PrepareJoystickHwdata(joystick, item, item_sensor) == -1) { SDL_free(joystick->hwdata); joystick->hwdata = NULL; return -1; /* SDL_SetError will already have been called */ } SDL_assert(item->hwdata == NULL); + SDL_assert(!item_sensor || item_sensor->hwdata == NULL); item->hwdata = joystick->hwdata; + if (item_sensor) { + item_sensor->hwdata = joystick->hwdata; + } /* mark joystick as fresh and ready */ joystick->hwdata->fresh = SDL_TRUE; + if (joystick->hwdata->has_gyro) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 0.0f); + } + if (joystick->hwdata->has_accelerometer) { + SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f); + } + if (joystick->hwdata->fd_sensor >= 0) { + /* Don't keep fd_sensor opened while sensor is disabled */ + close(joystick->hwdata->fd_sensor); + joystick->hwdata->fd_sensor = -1; + } + return 0; } @@ -1333,7 +1754,32 @@ static int LINUX_JoystickSendEffect(SDL_Joystick *joystick, const void *data, in static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { - return SDL_Unsupported(); + SDL_AssertJoysticksLocked(); + + if (!joystick->hwdata->has_accelerometer && !joystick->hwdata->has_gyro) { + return SDL_Unsupported(); + } + if (enabled == joystick->hwdata->report_sensor) { + return 0; + } + + if (enabled) { + if (!joystick->hwdata->item_sensor) { + return SDL_SetError("Sensors unplugged."); + } + joystick->hwdata->fd_sensor = open(joystick->hwdata->item_sensor->path, O_RDONLY | O_CLOEXEC, 0); + if (joystick->hwdata->fd_sensor < 0) { + return SDL_SetError("Couldn't open sensor file %s.", joystick->hwdata->item_sensor->path); + } + fcntl(joystick->hwdata->fd_sensor, F_SETFL, O_NONBLOCK); + } else { + SDL_assert(joystick->hwdata->fd_sensor >= 0); + close(joystick->hwdata->fd_sensor); + joystick->hwdata->fd_sensor = -1; + } + + joystick->hwdata->report_sensor = enabled; + return 0; } static void HandleHat(SDL_Joystick *stick, int hatidx, int axis, int value) @@ -1486,6 +1932,41 @@ static void PollAllValues(SDL_Joystick *joystick) /* Joyballs are relative input, so there's no poll state. Events only! */ } +static void PollAllSensors(SDL_Joystick *joystick) +{ + struct input_absinfo absinfo; + int i; + + SDL_AssertJoysticksLocked(); + + SDL_assert(joystick->hwdata->fd_sensor >= 0); + + if (joystick->hwdata->has_gyro) { + float data[3] = {0.0f, 0.0f, 0.0f}; + for (i = 0; i < 3; i++) { + if (ioctl(joystick->hwdata->fd_sensor, EVIOCGABS(ABS_RX + i), &absinfo) >= 0) { + data[i] = absinfo.value * (M_PI / 180.f) / joystick->hwdata->gyro_scale[i]; +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Joystick : Re-read Gyro (axis %d) val= %f\n", i, data[i]); +#endif + } + } + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, joystick->hwdata->sensor_tick, data, 3); + } + if (joystick->hwdata->has_accelerometer) { + float data[3] = {0.0f, 0.0f, 0.0f}; + for (i = 0; i < 3; i++) { + if (ioctl(joystick->hwdata->fd_sensor, EVIOCGABS(ABS_X + i), &absinfo) >= 0) { + data[i] = absinfo.value * SDL_STANDARD_GRAVITY / joystick->hwdata->accelerometer_scale[i]; +#ifdef DEBUG_INPUT_EVENTS + SDL_Log("Joystick : Re-read Accelerometer (axis %d) val= %f\n", i, data[i]); +#endif + } + } + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, joystick->hwdata->sensor_tick, data, 3); + } +} + static void HandleInputEvents(SDL_Joystick *joystick) { struct input_event events[32]; @@ -1495,9 +1976,14 @@ static void HandleInputEvents(SDL_Joystick *joystick) if (joystick->hwdata->fresh) { PollAllValues(joystick); + if (joystick->hwdata->report_sensor) { + PollAllSensors(joystick); + } joystick->hwdata->fresh = SDL_FALSE; } + errno = 0; + while ((len = read(joystick->hwdata->fd, events, sizeof(events))) > 0) { len /= sizeof(events[0]); for (i = 0; i < len; ++i) { @@ -1577,6 +2063,96 @@ static void HandleInputEvents(SDL_Joystick *joystick) if (errno == ENODEV) { /* We have to wait until the JoystickDetect callback to remove this */ joystick->hwdata->gone = SDL_TRUE; + errno = 0; + } + + if (joystick->hwdata->report_sensor) { + SDL_assert(joystick->hwdata->fd_sensor >= 0); + + while ((len = read(joystick->hwdata->fd_sensor, events, sizeof(events))) > 0) { + len /= sizeof(events[0]); + for (i = 0; i < len; ++i) { + unsigned int j; + struct input_event *event = &events[i]; + + code = event->code; + + /* If the kernel sent a SYN_DROPPED, we are supposed to ignore the + rest of the packet (the end of it signified by a SYN_REPORT) */ + if (joystick->hwdata->recovering_from_dropped_sensor && + ((event->type != EV_SYN) || (code != SYN_REPORT))) { + continue; + } + + switch (event->type) { + case EV_KEY: + SDL_assert(0); + break; + case EV_ABS: + switch (code) { + case ABS_X: + case ABS_Y: + case ABS_Z: + j = code - ABS_X; + joystick->hwdata->accel_data[j] = event->value * SDL_STANDARD_GRAVITY + / joystick->hwdata->accelerometer_scale[j]; + break; + case ABS_RX: + case ABS_RY: + case ABS_RZ: + j = code - ABS_RX; + joystick->hwdata->gyro_data[j] = event->value * (M_PI / 180.f) + / joystick->hwdata->gyro_scale[j]; + break; + } + break; + case EV_MSC: + if (code == MSC_TIMESTAMP) { + Sint32 tick = event->value; + Sint32 delta; + if (joystick->hwdata->last_tick < tick) { + delta = (tick - joystick->hwdata->last_tick); + } else { + delta = (SDL_MAX_SINT32 - joystick->hwdata->last_tick + tick + 1); + } + joystick->hwdata->sensor_tick += delta; + joystick->hwdata->last_tick = tick; + } + break; + case EV_SYN: + switch (code) { + case SYN_DROPPED: + #ifdef DEBUG_INPUT_EVENTS + SDL_Log("Event SYN_DROPPED detected\n"); + #endif + joystick->hwdata->recovering_from_dropped_sensor = SDL_TRUE; + break; + case SYN_REPORT: + if (joystick->hwdata->recovering_from_dropped_sensor) { + joystick->hwdata->recovering_from_dropped_sensor = SDL_FALSE; + PollAllSensors(joystick); /* try to sync up to current state now */ + } else { + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_GYRO, + joystick->hwdata->sensor_tick, + joystick->hwdata->gyro_data, 3); + SDL_PrivateJoystickSensor(joystick, SDL_SENSOR_ACCEL, + joystick->hwdata->sensor_tick, + joystick->hwdata->accel_data, 3); + } + break; + default: + break; + } + default: + break; + } + } + } + } + + if (errno == ENODEV) { + /* We have to wait until the JoystickDetect callback to remove this */ + joystick->hwdata->sensor_gone = SDL_TRUE; } } @@ -1670,9 +2246,15 @@ static void LINUX_JoystickClose(SDL_Joystick *joystick) if (joystick->hwdata->fd >= 0) { close(joystick->hwdata->fd); } + if (joystick->hwdata->fd_sensor >= 0) { + close(joystick->hwdata->fd_sensor); + } if (joystick->hwdata->item) { joystick->hwdata->item->hwdata = NULL; } + if (joystick->hwdata->item_sensor) { + joystick->hwdata->item_sensor->hwdata = NULL; + } SDL_free(joystick->hwdata->key_pam); SDL_free(joystick->hwdata->abs_pam); SDL_free(joystick->hwdata->hats); @@ -1687,6 +2269,10 @@ static void LINUX_JoystickQuit(void) { SDL_joylist_item *item = NULL; SDL_joylist_item *next = NULL; + SDL_sensorlist_item *item_sensor = NULL; + SDL_sensorlist_item *next_sensor = NULL; + + SDL_AssertJoysticksLocked(); if (inotify_fd >= 0) { close(inotify_fd); @@ -1697,12 +2283,17 @@ static void LINUX_JoystickQuit(void) next = item->next; FreeJoylistItem(item); } + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = next_sensor) { + next_sensor = item_sensor->next; + FreeSensorlistItem(item_sensor); + } SDL_joylist = SDL_joylist_tail = NULL; + SDL_sensorlist = NULL; numjoysticks = 0; -#if SDL_USE_LIBUDEV +#ifdef SDL_USE_LIBUDEV if (enumeration_method == ENUMERATION_LIBUDEV) { SDL_UDEV_DelCallback(joystick_udev_callback); SDL_UDEV_Quit(); @@ -1752,16 +2343,16 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap /* We temporarily open the device to check how it's configured. Make a fake SDL_Joystick object to do so. */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - joystick->magic = &SDL_joystick_magic; - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); return SDL_FALSE; } + joystick->magic = &SDL_joystick_magic; SDL_memcpy(&joystick->guid, &item->guid, sizeof(item->guid)); joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { SDL_free(joystick); SDL_OutOfMemory(); return SDL_FALSE; @@ -1769,7 +2360,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap item->checked_mapping = SDL_TRUE; - if (PrepareJoystickHwdata(joystick, item) == -1) { + if (PrepareJoystickHwdata(joystick, item, NULL) == -1) { SDL_free(joystick->hwdata); SDL_free(joystick); return SDL_FALSE; /* SDL_SetError will already have been called */ @@ -2200,6 +2791,7 @@ SDL_JoystickDriver SDL_LINUX_JoystickDriver = { LINUX_JoystickDetect, LINUX_JoystickGetDeviceName, LINUX_JoystickGetDevicePath, + LINUX_JoystickGetDeviceSteamVirtualGamepadSlot, LINUX_JoystickGetDevicePlayerIndex, LINUX_JoystickSetDevicePlayerIndex, LINUX_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/linux/SDL_sysjoystick_c.h b/vs/sdl2/src/joystick/linux/SDL_sysjoystick_c.h index a567312a91..6d6ee69abc 100644 --- a/vs/sdl2/src/joystick/linux/SDL_sysjoystick_c.h +++ b/vs/sdl2/src/joystick/linux/SDL_sysjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,12 +25,16 @@ #include struct SDL_joylist_item; +struct SDL_sensorlist_item; /* The private structure used to keep track of a joystick */ struct joystick_hwdata { int fd; + /* linux driver creates a separate device for gyro/accelerometer */ + int fd_sensor; struct SDL_joylist_item *item; + struct SDL_sensorlist_item *item_sensor; SDL_JoystickGUID guid; char *fname; /* Used in haptic subsystem */ @@ -55,6 +59,8 @@ struct joystick_hwdata Uint8 abs_map[ABS_MAX]; SDL_bool has_key[KEY_MAX]; SDL_bool has_abs[ABS_MAX]; + SDL_bool has_accelerometer; + SDL_bool has_gyro; /* Support for the classic joystick interface */ SDL_bool classic; @@ -74,8 +80,20 @@ struct joystick_hwdata float scale; } abs_correct[ABS_MAX]; + float accelerometer_scale[3]; + float gyro_scale[3]; + + /* Each axis is read independently, if we don't get all axis this call to + * LINUX_JoystickUpdateupdate(), store them for the next one */ + float gyro_data[3]; + float accel_data[3]; + Uint64 sensor_tick; + Sint32 last_tick; + + SDL_bool report_sensor; SDL_bool fresh; SDL_bool recovering_from_dropped; + SDL_bool recovering_from_dropped_sensor; /* Steam Controller support */ SDL_bool m_bSteamController; @@ -92,6 +110,7 @@ struct joystick_hwdata /* Set when gamepad is pending removal due to ENODEV read error */ SDL_bool gone; + SDL_bool sensor_gone; }; #endif /* SDL_sysjoystick_c_h_ */ diff --git a/vs/sdl2/src/joystick/n3ds/SDL_sysjoystick.c b/vs/sdl2/src/joystick/n3ds/SDL_sysjoystick.c index 49b9937ae1..bfb1a37f1e 100644 --- a/vs/sdl2/src/joystick/n3ds/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/n3ds/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +37,23 @@ This correction is applied to axis values so they fit better in SDL's value range. */ -#define CORRECT_AXIS_X(X) ((X * SDL_JOYSTICK_AXIS_MAX) / 160) +static inline int Correct_Axis_X(int X) { + if (X > 160) { + return SDL_JOYSTICK_AXIS_MAX; + } + else if (X < -160) { + return -SDL_JOYSTICK_AXIS_MAX; + } + return (X * SDL_JOYSTICK_AXIS_MAX) / 160; +} /* The Y axis needs to be flipped because SDL's "up" is reversed compared to libctru's "up" */ -#define CORRECT_AXIS_Y(Y) CORRECT_AXIS_X(-Y) +static inline int Correct_Axis_Y(int Y) { + return Correct_Axis_X(-Y); +} SDL_FORCE_INLINE void UpdateN3DSPressedButtons(SDL_Joystick *joystick); SDL_FORCE_INLINE void UpdateN3DSReleasedButtons(SDL_Joystick *joystick); @@ -143,12 +153,12 @@ UpdateN3DSCircle(SDL_Joystick *joystick) if (previous_state.dx != current_state.dx) { SDL_PrivateJoystickAxis(joystick, 0, - CORRECT_AXIS_X(current_state.dx)); + Correct_Axis_X(current_state.dx)); } if (previous_state.dy != current_state.dy) { SDL_PrivateJoystickAxis(joystick, 1, - CORRECT_AXIS_Y(current_state.dy)); + Correct_Axis_Y(current_state.dy)); } previous_state = current_state; } @@ -162,12 +172,12 @@ UpdateN3DSCStick(SDL_Joystick *joystick) if (previous_state.dx != current_state.dx) { SDL_PrivateJoystickAxis(joystick, 2, - CORRECT_AXIS_X(current_state.dx)); + Correct_Axis_X(current_state.dx)); } if (previous_state.dy != current_state.dy) { SDL_PrivateJoystickAxis(joystick, 3, - CORRECT_AXIS_Y(current_state.dy)); + Correct_Axis_Y(current_state.dy)); } previous_state = current_state; } @@ -224,6 +234,11 @@ static const char *N3DS_JoystickGetDevicePath(int device_index) return NULL; } +static int N3DS_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int N3DS_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -264,6 +279,7 @@ SDL_JoystickDriver SDL_N3DS_JoystickDriver = { .Detect = N3DS_JoystickDetect, .GetDeviceName = N3DS_JoystickGetDeviceName, .GetDevicePath = N3DS_JoystickGetDevicePath, + .GetDeviceSteamVirtualGamepadSlot = N3DS_JoystickGetDeviceSteamVirtualGamepadSlot, .GetDevicePlayerIndex = N3DS_JoystickGetDevicePlayerIndex, .SetDevicePlayerIndex = N3DS_JoystickSetDevicePlayerIndex, .GetDeviceGUID = N3DS_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/os2/SDL_os2joystick.c b/vs/sdl2/src/joystick/os2/SDL_os2joystick.c index 7f72b625e0..8df26ffe89 100644 --- a/vs/sdl2/src/joystick/os2/SDL_os2joystick.c +++ b/vs/sdl2/src/joystick/os2/SDL_os2joystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,29 +93,29 @@ typedef struct { #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 */ +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; + APIRET rc; /* Generic OS/2 return code */ + GAME_PORT_STRUCT stJoyStatus; /* Joystick Status Structure */ + GAME_PARM_STRUCT stGameParms; /* Joystick Parameter Structure */ + GAME_CALIB_STRUCT stGameCalib; /* Calibration Struct */ + ULONG ulDataLen; /* Size of data */ + ULONG ulLastTick; /* Tick Counter for timing operations */ + Uint8 maxdevs; /* Maximum number of devices */ + Uint8 numdevs; /* Number of present devices */ + Uint8 maxbut; /* Maximum number of buttons... */ + Uint8 i; /* Temporary Count Vars */ + Uint8 ucNewJoystickMask; /* Mask for Joystick Detection */ + struct _joycfg joycfg; /* Joy Configuration from envvar */ + + /* Open GAME$ port */ + if (joyPortOpen(&hJoyPort) < 0) { + return 0; /* Cannot open... report no joystick */ + } + /* Get Max Number of Devices */ + ulDataLen = sizeof(stGameParms); + rc = DosDevIOCtl(hJoyPort, IOCTL_CAT_USER, GAME_GET_PARMS, + NULL, 0, NULL, &stGameParms, ulDataLen, &ulDataLen); /* Ask device info */ + if (rc != 0) { + joyPortClose(&hJoyPort); + return SDL_SetError("Could not read joystick port."); + } + maxdevs = 0; + if (stGameParms.useA != 0) { + maxdevs++; + } + if (stGameParms.useB != 0) { + maxdevs++; + } + if (maxdevs > 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; i < joycfg.axes; i++) { + SYS_JoyData[0].axes_min[i] = axis[i]->lower; + 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; + return numjoysticks; } static void OS2_JoystickDetect(void) @@ -379,18 +399,23 @@ static void OS2_JoystickDetect(void) 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; + /* No need to verify if device exists, already done in upper layer */ + return SYS_JoyData[device_index].szDeviceName; } static const char *OS2_JoystickGetDevicePath(int device_index) { - return NULL; + return NULL; +} + +static int OS2_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; } static int OS2_JoystickGetDevicePlayerIndex(int device_index) { - return -1; + return -1; } static void OS2_JoystickSetDevicePlayerIndex(int device_index, int player_index) @@ -406,80 +431,75 @@ static SDL_JoystickGUID OS2_JoystickGetDeviceGUID(int device_index) static SDL_JoystickID OS2_JoystickGetDeviceInstanceID(int device_index) { - return 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. */ +/* 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_calloc(1, sizeof(*joystick->hwdata)); - if (!joystick->hwdata) - { - return SDL_OutOfMemory(); - } - - /* 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)SDL_abs((SDL_JOYSTICK_AXIS_MIN/SYS_JoyData[index].axes_min[i])); - joystick->hwdata->transaxes[i].scale2 = (float)SDL_abs((SDL_JOYSTICK_AXIS_MAX/SYS_JoyData[index].axes_max[i])); - } - else - { - joystick->hwdata->transaxes[i].offset = 0; - joystick->hwdata->transaxes[i].scale1 = 1.0f; /* Just in case */ - joystick->hwdata->transaxes[i].scale2 = 1.0f; /* 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; + 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_calloc(1, sizeof(*joystick->hwdata)); + if (!joystick->hwdata) { + return SDL_OutOfMemory(); + } + + /* 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)SDL_abs((SDL_JOYSTICK_AXIS_MIN/SYS_JoyData[index].axes_min[i])); + joystick->hwdata->transaxes[i].scale2 = (float)SDL_abs((SDL_JOYSTICK_AXIS_MAX/SYS_JoyData[index].axes_max[i])); + } else { + joystick->hwdata->transaxes[i].offset = 0; + joystick->hwdata->transaxes[i].scale1 = 1.0f; /* Just in case */ + joystick->hwdata->transaxes[i].scale2 = 1.0f; /* 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(); + return SDL_Unsupported(); } static int OS2_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) { - return SDL_Unsupported(); + return SDL_Unsupported(); } static Uint32 OS2_JoystickGetCapabilities(SDL_Joystick *joystick) { - return 0; + return 0; } static int OS2_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) { - return SDL_Unsupported(); + return SDL_Unsupported(); } static int OS2_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) @@ -489,133 +509,145 @@ static int OS2_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int static int OS2_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) { - return SDL_Unsupported(); + 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. */ +/* 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->nbuttons < normbut) normbut = joystick->nbuttons; - 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 */ + 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->nbuttons < normbut) { + normbut = joystick->nbuttons; + } + 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 */ } /******************************************/ @@ -623,8 +655,8 @@ static void OS2_JoystickUpdate(SDL_Joystick *joystick) /******************************************/ static void OS2_JoystickClose(SDL_Joystick *joystick) { - /* free system specific hardware data */ - SDL_free(joystick->hwdata); + /* free system specific hardware data */ + SDL_free(joystick->hwdata); } /********************************************************************/ @@ -632,12 +664,12 @@ static void OS2_JoystickClose(SDL_Joystick *joystick) /********************************************************************/ static void OS2_JoystickQuit(void) { - joyPortClose(&hJoyPort); + joyPortClose(&hJoyPort); } static SDL_bool OS2_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) { - return SDL_FALSE; + return SDL_FALSE; } @@ -650,38 +682,38 @@ static SDL_bool OS2_JoystickGetGamepadMapping(int device_index, SDL_GamepadMappi /*****************************************/ 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; + 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; } /****************************/ @@ -689,8 +721,10 @@ static int joyPortOpen(HFILE * hGame) /****************************/ static void joyPortClose(HFILE * hGame) { - if (*hGame != NULLHANDLE) DosClose(*hGame); - *hGame = NULLHANDLE; + if (*hGame != NULLHANDLE) { + DosClose(*hGame); + } + *hGame = NULLHANDLE; } /***************************/ @@ -698,106 +732,112 @@ static void joyPortClose(HFILE * hGame) /***************************/ static int joyGetEnv(struct _joycfg * joydata) { - const 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++; - joyenv += joyGetData(joyenv,joydata->name,'\'',sizeof(joydata->name)); - } - /* If not, get it until the next space */ - else if (*joyenv == '\"') { - 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 = SDL_atoi(tempnumber); - - /* Now get the number of buttons */ - while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); - joydata->buttons = SDL_atoi(tempnumber); - - /* Now get the number of hats */ - while (*joyenv == ' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); - joydata->hats = SDL_atoi(tempnumber); - - /* Now get the number of balls */ - while (*joyenv==' ' && *joyenv != 0) joyenv++; /* jump spaces... */ - joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); - joydata->balls = SDL_atoi(tempnumber); - return 1; + const char *joyenv; /* Pointer to tested character */ + char tempnumber[5]; /* Temporary place to put numeric texts */ + + joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); + if (!joyenv) { + 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++; + joyenv += joyGetData(joyenv,joydata->name,'\'',sizeof(joydata->name)); + } + /* If not, get it until the next space */ + else if (*joyenv == '\"') { + 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 = SDL_atoi(tempnumber); + + /* Now get the number of buttons */ + while (*joyenv == ' ' && *joyenv != 0) { + joyenv++; /* jump spaces... */ + } + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->buttons = SDL_atoi(tempnumber); + + /* Now get the number of hats */ + while (*joyenv == ' ' && *joyenv != 0) { + joyenv++; /* jump spaces... */ + } + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->hats = SDL_atoi(tempnumber); + + /* Now get the number of balls */ + while (*joyenv==' ' && *joyenv != 0) { + joyenv++; /* jump spaces... */ + } + joyenv += joyGetData(joyenv,tempnumber,' ',sizeof(tempnumber)); + joydata->balls = SDL_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. */ +/* 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(const 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; + 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_JoystickGetDevicePath, - OS2_JoystickGetDevicePlayerIndex, - OS2_JoystickSetDevicePlayerIndex, - OS2_JoystickGetDeviceGUID, - OS2_JoystickGetDeviceInstanceID, - OS2_JoystickOpen, - OS2_JoystickRumble, - OS2_JoystickRumbleTriggers, - OS2_JoystickGetCapabilities, - OS2_JoystickSetLED, - OS2_JoystickSendEffect, - OS2_JoystickSetSensorsEnabled, - OS2_JoystickUpdate, - OS2_JoystickClose, - OS2_JoystickQuit, - OS2_JoystickGetGamepadMapping +SDL_JoystickDriver SDL_OS2_JoystickDriver = { + OS2_JoystickInit, + OS2_NumJoysticks, + OS2_JoystickDetect, + OS2_JoystickGetDeviceName, + OS2_JoystickGetDevicePath, + OS2_JoystickGetDeviceSteamVirtualGamepadSlot, + OS2_JoystickGetDevicePlayerIndex, + OS2_JoystickSetDevicePlayerIndex, + OS2_JoystickGetDeviceGUID, + OS2_JoystickGetDeviceInstanceID, + OS2_JoystickOpen, + OS2_JoystickRumble, + OS2_JoystickRumbleTriggers, + OS2_JoystickGetCapabilities, + OS2_JoystickSetLED, + OS2_JoystickSendEffect, + OS2_JoystickSetSensorsEnabled, + OS2_JoystickUpdate, + OS2_JoystickClose, + OS2_JoystickQuit, + OS2_JoystickGetGamepadMapping }; #endif /* SDL_JOYSTICK_OS2 */ diff --git a/vs/sdl2/src/joystick/ps2/SDL_sysjoystick.c b/vs/sdl2/src/joystick/ps2/SDL_sysjoystick.c index 698d632bf8..8c0edb7a56 100644 --- a/vs/sdl2/src/joystick/ps2/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/ps2/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_JOYSTICK_PS2 +#ifdef SDL_JOYSTICK_PS2 /* This is the PS2 implementation of the SDL joystick API */ #include @@ -160,6 +160,12 @@ static const char *PS2_JoystickGetDevicePath(int index) return NULL; } +/* Function to get the Steam virtual gamepad slot of a joystick */ +static int PS2_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + /* Function to get the player index of a joystick */ static int PS2_JoystickGetDevicePlayerIndex(int device_index) { @@ -343,6 +349,7 @@ SDL_JoystickDriver SDL_PS2_JoystickDriver = { PS2_JoystickDetect, PS2_JoystickGetDeviceName, PS2_JoystickGetDevicePath, + PS2_JoystickGetDeviceSteamVirtualGamepadSlot, PS2_JoystickGetDevicePlayerIndex, PS2_JoystickSetDevicePlayerIndex, PS2_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/psp/SDL_sysjoystick.c b/vs/sdl2/src/joystick/psp/SDL_sysjoystick.c index 3478ca8037..3d7d53148c 100644 --- a/vs/sdl2/src/joystick/psp/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/psp/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_JOYSTICK_PSP +#ifdef SDL_JOYSTICK_PSP /* This is the PSP implementation of the SDL joystick API */ #include @@ -124,6 +124,11 @@ static const char *PSP_JoystickGetDevicePath(int index) return NULL; } +static int PSP_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int PSP_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -205,7 +210,9 @@ static void PSP_JoystickUpdate(SDL_Joystick *joystick) static enum PspCtrlButtons old_buttons = 0; static unsigned char old_x = 0, old_y = 0; - sceCtrlReadBufferPositive(&pad, 1); + if (sceCtrlPeekBufferPositive(&pad, 1) <= 0) { + return; + } buttons = pad.Buttons; x = pad.Lx; y = pad.Ly; @@ -255,6 +262,7 @@ SDL_JoystickDriver SDL_PSP_JoystickDriver = { PSP_JoystickDetect, PSP_JoystickGetDeviceName, PSP_JoystickGetDevicePath, + PSP_JoystickGetDeviceSteamVirtualGamepadSlot, PSP_JoystickGetDevicePlayerIndex, PSP_JoystickSetDevicePlayerIndex, PSP_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/sort_controllers.py b/vs/sdl2/src/joystick/sort_controllers.py index c74e151514..c97559f553 100755 --- a/vs/sdl2/src/joystick/sort_controllers.py +++ b/vs/sdl2/src/joystick/sort_controllers.py @@ -22,6 +22,7 @@ invalid_controllers = ( ('0079', '0006', '0000'), # DragonRise Inc. Generic USB Joystick ('0079', '0006', '6120'), # DragonRise Inc. Generic USB Joystick + ('04b4', '2412', 'c529'), # Flydigi Vader 2, Vader 2 Pro, Apex 2, Apex 3 ('16c0', '05e1', '0000'), # Xinmotek Controller ) @@ -34,6 +35,15 @@ def find_element(prefix, bindings): return -1 +def get_crc_from_entry(entry): + crc = "" + line = "".join(entry) + bindings = line.split(",") + pos = find_element("crc:", bindings) + if pos >= 0: + crc = bindings[pos][4:] + return crc + def save_controller(line): global controllers match = split_pattern.match(line) @@ -84,7 +94,7 @@ def save_controller(line): entry.append(match.group(5)) controllers.append(entry) - entry_id = entry[1] + entry[3] + entry_id = entry[1] + get_crc_from_entry(entry) if ',sdk' in line or ',hint:' in line: conditionals.append(entry_id) @@ -93,7 +103,7 @@ def write_controllers(): global controller_guids # Check for duplicates for entry in controllers: - entry_id = entry[1] + entry[3] + entry_id = entry[1] + get_crc_from_entry(entry) if (entry_id in controller_guids and entry_id not in conditionals): current_name = entry[2] existing_name = controller_guids[entry_id][2] diff --git a/vs/sdl2/src/joystick/steam/SDL_steamcontroller.c b/vs/sdl2/src/joystick/steam/SDL_steamcontroller.c index 256aa7dc74..04327e37ec 100644 --- a/vs/sdl2/src/joystick/steam/SDL_steamcontroller.c +++ b/vs/sdl2/src/joystick/steam/SDL_steamcontroller.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/steam/SDL_steamcontroller.h b/vs/sdl2/src/joystick/steam/SDL_steamcontroller.h index e63e51bb78..35a72226c6 100644 --- a/vs/sdl2/src/joystick/steam/SDL_steamcontroller.h +++ b/vs/sdl2/src/joystick/steam/SDL_steamcontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/usb_ids.h b/vs/sdl2/src/joystick/usb_ids.h index bc9e319e48..9cdcfa68ad 100644 --- a/vs/sdl2/src/joystick/usb_ids.h +++ b/vs/sdl2/src/joystick/usb_ids.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +29,17 @@ #define USB_VENDOR_APPLE 0x05ac #define USB_VENDOR_ASTRO 0x9886 #define USB_VENDOR_BACKBONE 0x358a +#define USB_VENDOR_GAMESIR 0x3537 #define USB_VENDOR_DRAGONRISE 0x0079 #define USB_VENDOR_GOOGLE 0x18d1 #define USB_VENDOR_HORI 0x0f0d #define USB_VENDOR_HYPERKIN 0x2e24 #define USB_VENDOR_LOGITECH 0x046d #define USB_VENDOR_MADCATZ 0x0738 +#define USB_VENDOR_MAYFLASH 0x33df #define USB_VENDOR_MICROSOFT 0x045e #define USB_VENDOR_NACON 0x146b +#define USB_VENDOR_NACON_ALT 0x3285 #define USB_VENDOR_NINTENDO 0x057e #define USB_VENDOR_NVIDIA 0x0955 #define USB_VENDOR_PDP 0x0e6f @@ -44,6 +47,7 @@ #define USB_VENDOR_POWERA_ALT 0x20d6 #define USB_VENDOR_QANBA 0x2c22 #define USB_VENDOR_RAZER 0x1532 +#define USB_VENDOR_SAITEK 0x06a3 #define USB_VENDOR_SHANWAN 0x2563 #define USB_VENDOR_SHANWAN_ALT 0x20bc #define USB_VENDOR_SONY 0x054c @@ -52,19 +56,27 @@ #define USB_VENDOR_VALVE 0x28de #define USB_VENDOR_ZEROPLUS 0x0c12 -#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER 0x2002 +#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER1 0x2002 /* Ultimate Wired Controller for Xbox */ +#define USB_PRODUCT_8BITDO_XBOX_CONTROLLER2 0x3106 /* Ultimate Wireless / Pro 2 Wired Controller */ #define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419 #define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024 #define USB_PRODUCT_BACKBONE_ONE_IOS 0x0103 #define USB_PRODUCT_BACKBONE_ONE_IOS_PS5 0x0104 +#define USB_PRODUCT_GAMESIR_G7 0x1001 #define USB_PRODUCT_GOOGLE_STADIA_CONTROLLER 0x9400 -#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER 0x1846 +#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER1 0x1843 +#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER2 0x1846 #define USB_PRODUCT_HORI_FIGHTING_COMMANDER_OCTA_SERIES_X 0x0150 #define USB_PRODUCT_HORI_HORIPAD_PRO_SERIES_X 0x014f #define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS4 0x011c #define USB_PRODUCT_HORI_FIGHTING_STICK_ALPHA_PS5 0x0184 #define USB_PRODUCT_LOGITECH_F310 0xc216 #define USB_PRODUCT_LOGITECH_CHILLSTREAM 0xcad1 +#define USB_PRODUCT_MADCATZ_SAITEK_SIDE_PANEL_CONTROL_DECK 0x2218 +#define USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS4_WIRELESS 0x0d16 +#define USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS4_WIRED 0x0d17 +#define USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRELESS 0x0d18 +#define USB_PRODUCT_NACON_REVOLUTION_5_PRO_PS5_WIRED 0x0d19 #define USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER 0x0337 #define USB_PRODUCT_NINTENDO_N64_CONTROLLER 0x2019 #define USB_PRODUCT_NINTENDO_SEGA_GENESIS_CONTROLLER 0x201e @@ -79,6 +91,7 @@ #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103 0x7210 #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104 0x7214 #define USB_PRODUCT_RAZER_ATROX 0x0a00 +#define USB_PRODUCT_RAZER_KITSUNE 0x1012 #define USB_PRODUCT_RAZER_PANTHERA 0x0401 #define USB_PRODUCT_RAZER_PANTHERA_EVO 0x1008 #define USB_PRODUCT_RAZER_RAIJU 0x1000 @@ -92,6 +105,7 @@ #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_PS5_WIRELESS 0x100c #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRED 0x1010 #define USB_PRODUCT_RAZER_WOLVERINE_V2_PRO_XBOX_WIRELESS 0x1011 +#define USB_PRODUCT_SAITEK_CYBORG_V3 0xf622 #define USB_PRODUCT_SHANWAN_DS3 0x0523 #define USB_PRODUCT_SONY_DS3 0x0268 #define USB_PRODUCT_SONY_DS4 0x05c4 @@ -103,6 +117,7 @@ #define USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO 0xd012 #define USB_PRODUCT_TURTLE_BEACH_SERIES_X_REACT_R 0x7013 #define USB_PRODUCT_TURTLE_BEACH_SERIES_X_RECON 0x7009 +#define USB_PRODUCT_VICTRIX_FS_PRO 0x0203 #define USB_PRODUCT_VICTRIX_FS_PRO_V2 0x0207 #define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */ #define USB_PRODUCT_XBOX360_WIRED_CONTROLLER 0x028e @@ -126,7 +141,6 @@ #define USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2 0x4001 #define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA 0x4002 #define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER 0x02ff /* XBOXGIP driver software PID */ -#define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */ #define USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD 0x11ff /* USB usage pages */ diff --git a/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick.c b/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick.c index 71095e81df..e5e9b38c39 100644 --- a/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick.c +++ b/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if defined(SDL_JOYSTICK_VIRTUAL) +#ifdef SDL_JOYSTICK_VIRTUAL /* This is the virtual implementation of the SDL joystick API */ @@ -53,7 +53,7 @@ static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata) SDL_AssertJoysticksLocked(); - if (hwdata == NULL) { + if (!hwdata) { return; } @@ -102,7 +102,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) SDL_AssertJoysticksLocked(); - if (desc == NULL) { + if (!desc) { return SDL_InvalidParamError("desc"); } if (desc->version != SDL_VIRTUAL_JOYSTICK_DESC_VERSION) { @@ -111,7 +111,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) } hwdata = SDL_calloc(1, sizeof(joystick_hwdata)); - if (hwdata == NULL) { + if (!hwdata) { VIRTUAL_FreeHWData(hwdata); return SDL_OutOfMemory(); } @@ -191,7 +191,7 @@ int SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *desc) } } - hwdata->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_VIRTUAL, hwdata->desc.vendor_id, hwdata->desc.product_id, 0, name, 'v', (Uint8)hwdata->desc.type); + hwdata->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_VIRTUAL, hwdata->desc.vendor_id, hwdata->desc.product_id, 0, NULL, name, 'v', (Uint8)hwdata->desc.type); /* Allocate fields for different control-types */ if (hwdata->desc.naxes > 0) { @@ -248,7 +248,7 @@ int SDL_JoystickDetachVirtualInner(int device_index) { SDL_JoystickID instance_id; joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("Virtual joystick data not found"); } instance_id = hwdata->instance_id; @@ -263,7 +263,7 @@ int SDL_JoystickSetVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 val SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -286,7 +286,7 @@ int SDL_JoystickSetVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -309,7 +309,7 @@ int SDL_JoystickSetVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) SDL_LockJoysticks(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -351,7 +351,7 @@ static void VIRTUAL_JoystickDetect(void) static const char *VIRTUAL_JoystickGetDeviceName(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return NULL; } return hwdata->name; @@ -362,6 +362,11 @@ static const char *VIRTUAL_JoystickGetDevicePath(int device_index) return NULL; } +static int VIRTUAL_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int VIRTUAL_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -379,7 +384,7 @@ static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_in static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { SDL_JoystickGUID guid; SDL_zero(guid); return guid; @@ -390,7 +395,7 @@ static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return -1; } return hwdata->instance_id; @@ -403,7 +408,7 @@ static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("No such device"); } joystick->instance_id = hwdata->instance_id; @@ -529,7 +534,7 @@ static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - if (joystick == NULL) { + if (!joystick) { return; } if (!joystick->hwdata) { @@ -722,6 +727,7 @@ SDL_JoystickDriver SDL_VIRTUAL_JoystickDriver = { VIRTUAL_JoystickDetect, VIRTUAL_JoystickGetDeviceName, VIRTUAL_JoystickGetDevicePath, + VIRTUAL_JoystickGetDeviceSteamVirtualGamepadSlot, VIRTUAL_JoystickGetDevicePlayerIndex, VIRTUAL_JoystickSetDevicePlayerIndex, VIRTUAL_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick_c.h b/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick_c.h index 9fa0594d6c..10c5cff456 100644 --- a/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick_c.h +++ b/vs/sdl2/src/joystick/virtual/SDL_virtualjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_VIRTUALJOYSTICK_C_H #define SDL_VIRTUALJOYSTICK_C_H -#if SDL_JOYSTICK_VIRTUAL +#ifdef SDL_JOYSTICK_VIRTUAL #include "SDL_joystick.h" diff --git a/vs/sdl2/src/joystick/vita/SDL_sysjoystick.c b/vs/sdl2/src/joystick/vita/SDL_sysjoystick.c index ce66c7cbc8..9da62c2b3d 100644 --- a/vs/sdl2/src/joystick/vita/SDL_sysjoystick.c +++ b/vs/sdl2/src/joystick/vita/SDL_sysjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_JOYSTICK_VITA +#ifdef SDL_JOYSTICK_VITA /* This is the PSVita implementation of the SDL joystick API */ #include @@ -187,6 +187,11 @@ const char *VITA_JoystickGetDevicePath(int index) return NULL; } +static int VITA_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return -1; +} + static int VITA_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -377,6 +382,7 @@ SDL_JoystickDriver SDL_VITA_JoystickDriver = { VITA_JoystickDetect, VITA_JoystickGetDeviceName, VITA_JoystickGetDevicePath, + VITA_JoystickGetDeviceSteamVirtualGamepadSlot, VITA_JoystickGetDevicePlayerIndex, VITA_JoystickSetDevicePlayerIndex, VITA_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/windows/SDL_dinputjoystick.c b/vs/sdl2/src/joystick/windows/SDL_dinputjoystick.c index 92996192f1..fb46445e10 100644 --- a/vs/sdl2/src/joystick/windows/SDL_dinputjoystick.c +++ b/vs/sdl2/src/joystick/windows/SDL_dinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../SDL_sysjoystick.h" -#if SDL_JOYSTICK_DINPUT +#ifdef SDL_JOYSTICK_DINPUT #include "SDL_hints.h" #include "SDL_timer.h" @@ -273,7 +273,7 @@ static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) { DIPROPSTRING dipstr; - if (!device || device_name == NULL) { + if (!device || !device_name) { return SDL_FALSE; } @@ -295,7 +295,7 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) { DIPROPGUIDANDPATH dippath; - if (!device || device_path == NULL) { + if (!device || !device_path) { return SDL_FALSE; } @@ -320,7 +320,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, { DIPROPDWORD dipdw; - if (!device || vendor_id == NULL || product_id == NULL) { + if (!device || !vendor_id || !product_id) { return SDL_FALSE; } @@ -342,7 +342,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, void FreeRumbleEffectData(DIEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -358,7 +358,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -382,7 +382,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= DIEFF_CARTESIAN; periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -422,7 +422,7 @@ int SDL_DINPUT_JoystickInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); - if (instance == NULL) { + if (!instance) { IDirectInput8_Release(dinput); dinput = NULL; return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); @@ -437,6 +437,17 @@ int SDL_DINPUT_JoystickInit(void) return 0; } +static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const char *device_path) +{ + int slot = -1; + + if (vendor_id == USB_VENDOR_VALVE && + product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { + (void)SDL_sscanf(device_path, "\\\\?\\HID#VID_28DE&PID_11FF&IG_0%d", &slot); + } + return slot; +} + /* helper function for direct input, gets called for each connected joystick */ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInstance, LPVOID pContext) { @@ -453,7 +464,6 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta char *hidPath = NULL; char *name = NULL; LPDIRECTINPUTDEVICE8 device = NULL; - DIDEVCAPS caps; /* We are only supporting HID devices. */ CHECK(pDeviceInstance->dwDevType & DIDEVTYPE_HID); @@ -463,13 +473,6 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta CHECK(QueryDevicePath(device, &hidPath)); CHECK(QueryDeviceInfo(device, &vendor, &product)); - /* Check to make sure the device has buttons and axes. - * This fixes incorrectly detecting the ROG CHAKRAM X mouse as a game controller on Windows 10 - */ - caps.dwSize = sizeof(caps); - CHECK(SUCCEEDED(IDirectInputDevice8_GetCapabilities(device, &caps))); - CHECK(caps.dwAxes > 0 && caps.dwButtons > 0); - CHECK(!SDL_IsXInputDevice(vendor, product, hidPath)); pNewJoystick = *(JoyStick_DeviceData **)pContext; @@ -497,10 +500,10 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta pNewJoystick = pNewJoystick->pNext; } - pNewJoystick = (JoyStick_DeviceData *)SDL_malloc(sizeof(JoyStick_DeviceData)); + pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData)); CHECK(pNewJoystick); - SDL_zerop(pNewJoystick); + pNewJoystick->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(vendor, product, hidPath); SDL_strlcpy(pNewJoystick->path, hidPath, SDL_arraysize(pNewJoystick->path)); SDL_memcpy(&pNewJoystick->dxdevice, pDeviceInstance, sizeof(DIDEVICEINSTANCE)); @@ -508,9 +511,9 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta CHECK(pNewJoystick->joystickname); if (vendor && product) { - pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, vendor, product, version, pNewJoystick->joystickname, 0, 0); + pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, vendor, product, version, NULL, name, 0, 0); } else { - pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, version, pNewJoystick->joystickname, 0, 0); + pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_BLUETOOTH, vendor, product, version, NULL, name, 0, 0); } CHECK(!SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid)); @@ -545,7 +548,7 @@ static BOOL CALLBACK EnumJoystickDetectCallback(LPCDIDEVICEINSTANCE pDeviceInsta void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { - if (dinput == NULL) { + if (!dinput) { return; } @@ -597,7 +600,7 @@ SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 { Joystick_PresentData data; - if (dinput == NULL) { + if (!dinput) { return SDL_FALSE; } @@ -852,6 +855,7 @@ int SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic } else if (FAILED(result)) { return SetDIerror("IDirectInputDevice8::SetProperty", result); } + joystick->hwdata->first_update = SDL_TRUE; /* Poll and wait for initial device state to be populated */ result = IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); @@ -1127,7 +1131,14 @@ void SDL_DINPUT_JoystickUpdate(SDL_Joystick *joystick) IDirectInputDevice8_Poll(joystick->hwdata->InputDevice); } - if (joystick->hwdata->buffered) { + if (joystick->hwdata->first_update) { + /* Poll to get the initial state of the joystick */ + UpdateDINPUTJoystickState_Polled(joystick); + joystick->hwdata->first_update = SDL_FALSE; + return; + } + + if (joystick->hwdata->buffered ) { UpdateDINPUTJoystickState_Buffered(joystick); } else { UpdateDINPUTJoystickState_Polled(joystick); diff --git a/vs/sdl2/src/joystick/windows/SDL_dinputjoystick_c.h b/vs/sdl2/src/joystick/windows/SDL_dinputjoystick_c.h index 59ead46be4..8e6d233df2 100644 --- a/vs/sdl2/src/joystick/windows/SDL_dinputjoystick_c.h +++ b/vs/sdl2/src/joystick/windows/SDL_dinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick.c b/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick.c index 167a1c5368..c911efdb91 100644 --- a/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick.c +++ b/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 2023 Sam Lantinga + Copyright (C) 2024 Sam Lantinga 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_internal.h" -#if SDL_JOYSTICK_RAWINPUT +#ifdef SDL_JOYSTICK_RAWINPUT #include "SDL_atomic.h" #include "SDL_endian.h" @@ -119,6 +119,7 @@ typedef struct _SDL_RAWINPUT_Device SDL_JoystickGUID guid; SDL_bool is_xinput; SDL_bool is_xboxone; + int steam_virtual_gamepad_slot; PHIDP_PREPARSED_DATA preparsed_data; HANDLE hDevice; @@ -321,7 +322,7 @@ static void RAWINPUT_FillMatchState(WindowsMatchState *state, Uint64 match_state static struct { - XINPUT_STATE_EX state; + XINPUT_STATE state; XINPUT_BATTERY_INFORMATION_EX battery; SDL_bool connected; /* Currently has an active XInput device */ SDL_bool used; /* Is currently mapped to an SDL device */ @@ -477,7 +478,7 @@ static const IID IID_IEventHandler_Gamepad = { 0x8a7639ee, 0x624a, 0x501a, { 0xb static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -619,7 +620,7 @@ static void RAWINPUT_UpdateWindowsGamingInput() return; } gamepad_state = SDL_calloc(1, sizeof(*gamepad_state)); - if (gamepad_state == NULL) { + if (!gamepad_state) { SDL_OutOfMemory(); return; } @@ -836,6 +837,19 @@ static SDL_RAWINPUT_Device *RAWINPUT_DeviceFromHandle(HANDLE hDevice) return NULL; } +static int GetSteamVirtualGamepadSlot(Uint16 vendor_id, Uint16 product_id, const char *device_path) +{ + int slot = -1; + + // The format for the raw input device path is documented here: + // https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices + if (vendor_id == USB_VENDOR_VALVE && + product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { + (void)SDL_sscanf(device_path, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%*X&%*X&%*X#%d#%*u", &slot); + } + return slot; +} + static void RAWINPUT_AddDevice(HANDLE hDevice) { #define CHECK(expression) \ @@ -877,6 +891,7 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) device->version = (Uint16)rdi.hid.dwVersionNumber; device->is_xinput = SDL_TRUE; device->is_xboxone = SDL_IsJoystickXboxOne(device->vendor_id, device->product_id); + device->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(device->vendor_id, device->product_id, dev_name); /* Get HID Top-Level Collection Preparsed Data */ size = 0; @@ -901,6 +916,7 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) } device->name = SDL_CreateJoystickName(device->vendor_id, device->product_id, manufacturer_string, product_string); + device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, manufacturer_string, product_string, 'r', 0); if (manufacturer_string) { SDL_free(manufacturer_string); @@ -910,8 +926,6 @@ static void RAWINPUT_AddDevice(HANDLE hDevice) } } - device->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, device->vendor_id, device->product_id, device->version, device->name, 'r', 0); - device->path = SDL_strdup(dev_name); CloseHandle(hFile); @@ -988,7 +1002,8 @@ static void RAWINPUT_DetectDevices(void) devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); if (devices) { - if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) != -1) { + device_count = GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)); + if (device_count != (UINT)-1) { for (i = 0; i < device_count; ++i) { RAWINPUT_AddDevice(devices[i].hDevice); } @@ -1182,6 +1197,11 @@ static const char *RAWINPUT_JoystickGetDevicePath(int device_index) return RAWINPUT_GetDeviceByIndex(device_index)->path; } +static int RAWINPUT_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return RAWINPUT_GetDeviceByIndex(device_index)->steam_virtual_gamepad_slot; +} + static int RAWINPUT_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -1220,7 +1240,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ULONG i; ctx = (RAWINPUT_DeviceContext *)SDL_calloc(1, sizeof(RAWINPUT_DeviceContext)); - if (ctx == NULL) { + if (!ctx) { return SDL_OutOfMemory(); } joystick->hwdata = ctx; @@ -1233,7 +1253,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_device_change = SDL_TRUE; ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE); - if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || XINPUTGETSTATE == NULL)) { + if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || !XINPUTGETSTATE)) { ctx->xinput_enabled = SDL_FALSE; } ctx->xinput_slot = XUSER_INDEX_ANY; @@ -1419,7 +1439,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ if (!rumbled && ctx->xinput_correlated) { XINPUT_VIBRATION XVibration; - if (XINPUTSETSTATE == NULL) { + if (!XINPUTSETSTATE) { return SDL_Unsupported(); } @@ -2174,6 +2194,7 @@ SDL_JoystickDriver SDL_RAWINPUT_JoystickDriver = { RAWINPUT_JoystickDetect, RAWINPUT_JoystickGetDeviceName, RAWINPUT_JoystickGetDevicePath, + RAWINPUT_JoystickGetDeviceSteamVirtualGamepadSlot, RAWINPUT_JoystickGetDevicePlayerIndex, RAWINPUT_JoystickSetDevicePlayerIndex, RAWINPUT_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick_c.h b/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick_c.h index be08c33aeb..598a22d72b 100644 --- a/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick_c.h +++ b/vs/sdl2/src/joystick/windows/SDL_rawinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/joystick/windows/SDL_windows_gaming_input.c b/vs/sdl2/src/joystick/windows/SDL_windows_gaming_input.c index 6f01b4e1bc..656f742a8e 100644 --- a/vs/sdl2/src/joystick/windows/SDL_windows_gaming_input.c +++ b/vs/sdl2/src/joystick/windows/SDL_windows_gaming_input.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +64,7 @@ typedef struct WindowsGamingInputControllerState int naxes; int nhats; int nbuttons; + int steam_virtual_gamepad_slot; } WindowsGamingInputControllerState; static struct @@ -131,12 +132,13 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); - if (raw_devices == NULL) { + if (!raw_devices) { SDL_OutOfMemory(); return SDL_FALSE; } - if (GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { + raw_device_count = GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)); + if (raw_device_count == (UINT)-1) { SDL_free(raw_devices); raw_devices = NULL; return SDL_FALSE; /* oh well. */ @@ -352,7 +354,7 @@ typedef struct RawGameControllerDelegate static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -384,6 +386,50 @@ static ULONG STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_Release(__FI return rc; } +static int GetSteamVirtualGamepadSlot(__x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller, Uint16 vendor_id, Uint16 product_id) +{ + int slot = -1; + + if (vendor_id == USB_VENDOR_VALVE && + product_id == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { + __x_ABI_CWindows_CGaming_CInput_CIRawGameController2 *controller2 = NULL; + HRESULT hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IRawGameController2, (void **)&controller2); + if (SUCCEEDED(hr)) { + HSTRING hString; + hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_get_NonRoamableId(controller2, &hString); + if (SUCCEEDED(hr)) { + typedef PCWSTR(WINAPI * WindowsGetStringRawBuffer_t)(HSTRING string, UINT32 * length); + typedef HRESULT(WINAPI * WindowsDeleteString_t)(HSTRING string); + + WindowsGetStringRawBuffer_t WindowsGetStringRawBufferFunc = NULL; + WindowsDeleteString_t WindowsDeleteStringFunc = NULL; +#ifdef __WINRT__ + WindowsGetStringRawBufferFunc = WindowsGetStringRawBuffer; + WindowsDeleteStringFunc = WindowsDeleteString; +#else + { + WindowsGetStringRawBufferFunc = (WindowsGetStringRawBuffer_t)WIN_LoadComBaseFunction("WindowsGetStringRawBuffer"); + WindowsDeleteStringFunc = (WindowsDeleteString_t)WIN_LoadComBaseFunction("WindowsDeleteString"); + } +#endif /* __WINRT__ */ + if (WindowsGetStringRawBufferFunc && WindowsDeleteStringFunc) { + PCWSTR string = WindowsGetStringRawBufferFunc(hString, NULL); + if (string) { + char *id = WIN_StringToUTF8W(string); + if (id) { + (void)SDL_sscanf(id, "{wgi/nrid/:steam-%*X&%*X&%*X#%d#%*u}", &slot); + SDL_free(id); + } + } + WindowsDeleteStringFunc(hString); + } + } + __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2); + } + } + return slot; +} + static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdded(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, IInspectable *sender, __x_ABI_CWindows_CGaming_CInput_CIRawGameController *e) { HRESULT hr; @@ -442,7 +488,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2); } - if (name == NULL) { + if (!name) { name = SDL_strdup(""); } @@ -481,7 +527,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde __x_ABI_CWindows_CGaming_CInput_CIGameController_Release(gamecontroller); } - guid = SDL_CreateJoystickGUID(bus, vendor, product, version, name, 'w', (Uint8)type); + guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, name, 'w', (Uint8)type); if (SDL_ShouldIgnoreJoystick(name, guid)) { ignore_joystick = SDL_TRUE; @@ -501,6 +547,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde state->name = name; state->guid = guid; state->type = type; + state->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(controller, vendor, product); __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_ButtonCount(controller, &state->nbuttons); __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_AxisCount(controller, &state->naxes); @@ -687,6 +734,11 @@ static const char *WGI_JoystickGetDevicePath(int device_index) return NULL; } +static int WGI_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + return wgi.controllers[device_index].steam_virtual_gamepad_slot; +} + static int WGI_JoystickGetDevicePlayerIndex(int device_index) { return -1; @@ -713,7 +765,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) boolean wireless = SDL_FALSE; hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } joystick->hwdata = hwdata; @@ -1003,6 +1055,7 @@ SDL_JoystickDriver SDL_WGI_JoystickDriver = { WGI_JoystickDetect, WGI_JoystickGetDeviceName, WGI_JoystickGetDevicePath, + WGI_JoystickGetDeviceSteamVirtualGamepadSlot, WGI_JoystickGetDevicePlayerIndex, WGI_JoystickSetDevicePlayerIndex, WGI_JoystickGetDeviceGUID, diff --git a/vs/sdl2/src/joystick/windows/SDL_windowsjoystick.c b/vs/sdl2/src/joystick/windows/SDL_windowsjoystick.c index d94b314cd8..49e4c59757 100644 --- a/vs/sdl2/src/joystick/windows/SDL_windowsjoystick.c +++ b/vs/sdl2/src/joystick/windows/SDL_windowsjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT +#if defined(SDL_JOYSTICK_DINPUT) || defined(SDL_JOYSTICK_XINPUT) /* DirectInput joystick driver; written by Glenn Maynard, based on Andrei de * A. Formiga's WINMM driver. @@ -182,7 +182,7 @@ static DWORD CALLBACK SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID static void SDL_CleanupDeviceNotificationFunc(void) { if (cfgmgr32_lib_handle) { - if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification != NULL) { + if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification) { CM_Unregister_Notification(s_DeviceNotificationFuncHandle); s_DeviceNotificationFuncHandle = NULL; } @@ -252,7 +252,7 @@ static LRESULT CALLBACK SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARA break; } -#if SDL_JOYSTICK_RAWINPUT +#ifdef SDL_JOYSTICK_RAWINPUT return CallWindowProc(RAWINPUT_WindowProc, hwnd, msg, wParam, lParam); #else return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); @@ -261,7 +261,7 @@ static LRESULT CALLBACK SDL_PrivateJoystickDetectProc(HWND hwnd, UINT msg, WPARA static void SDL_CleanupDeviceNotification(SDL_DeviceNotificationData *data) { -#if SDL_JOYSTICK_RAWINPUT +#ifdef SDL_JOYSTICK_RAWINPUT RAWINPUT_UnregisterNotifications(); #endif @@ -300,7 +300,7 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) } data->messageWindow = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); - if (data->messageWindow == NULL) { + if (!data->messageWindow) { WIN_SetError("Failed to create message window for joystick autodetect"); SDL_CleanupDeviceNotification(data); return -1; @@ -318,7 +318,7 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) return -1; } -#if SDL_JOYSTICK_RAWINPUT +#ifdef SDL_JOYSTICK_RAWINPUT RAWINPUT_RegisterNotifications(data->messageWindow); #endif return 0; @@ -356,7 +356,7 @@ static SDL_DeviceNotificationData s_notification_data; /* Function/thread to scan the system for joysticks. */ static int SDLCALL SDL_JoystickThread(void *_data) { -#if SDL_JOYSTICK_XINPUT +#ifdef SDL_JOYSTICK_XINPUT SDL_bool bOpenedXInputDevices[XUSER_MAX_COUNT]; SDL_zeroa(bOpenedXInputDevices); #endif @@ -374,7 +374,7 @@ static int SDLCALL SDL_JoystickThread(void *_data) #else { #endif -#if SDL_JOYSTICK_XINPUT +#ifdef SDL_JOYSTICK_XINPUT /* WM_DEVICECHANGE not working, poll for new XINPUT controllers */ SDL_CondWaitTimeout(s_condJoystickThread, s_mutexJoyStickEnum, 1000); if (SDL_XINPUT_Enabled() && XINPUTGETCAPABILITIES) { @@ -410,18 +410,18 @@ static int SDLCALL SDL_JoystickThread(void *_data) static int SDL_StartJoystickThread(void) { s_mutexJoyStickEnum = SDL_CreateMutex(); - if (s_mutexJoyStickEnum == NULL) { + if (!s_mutexJoyStickEnum) { return -1; } s_condJoystickThread = SDL_CreateCond(); - if (s_condJoystickThread == NULL) { + if (!s_condJoystickThread) { return -1; } s_bJoystickThreadQuit = SDL_FALSE; s_joystickThread = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL); - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return -1; } return 0; @@ -429,7 +429,7 @@ static int SDL_StartJoystickThread(void) static void SDL_StopJoystickThread(void) { - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return; } @@ -558,11 +558,11 @@ void WINDOWS_JoystickDetect(void) JoyStick_DeviceData *pListNext = NULL; if (pCurList->bXInputDevice) { -#if SDL_HAPTIC_XINPUT +#ifdef SDL_HAPTIC_XINPUT SDL_XINPUT_HapticMaybeRemoveDevice(pCurList->XInputUserId); #endif } else { -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT SDL_DINPUT_HapticMaybeRemoveDevice(&pCurList->dxdevice); #endif } @@ -578,11 +578,11 @@ void WINDOWS_JoystickDetect(void) for (pCurList = SYS_Joystick; pCurList; pCurList = pCurList->pNext) { if (pCurList->send_add_event) { if (pCurList->bXInputDevice) { -#if SDL_HAPTIC_XINPUT +#ifdef SDL_HAPTIC_XINPUT SDL_XINPUT_HapticMaybeAddDevice(pCurList->XInputUserId); #endif } else { -#if SDL_HAPTIC_DINPUT +#ifdef SDL_HAPTIC_DINPUT SDL_DINPUT_HapticMaybeAddDevice(&pCurList->dxdevice); #endif } @@ -618,6 +618,23 @@ static const char *WINDOWS_JoystickGetDevicePath(int device_index) return device->path; } +static int WINDOWS_JoystickGetDeviceSteamVirtualGamepadSlot(int device_index) +{ + JoyStick_DeviceData *device = SYS_Joystick; + int index; + + for (index = device_index; index > 0; index--) { + device = device->pNext; + } + + if (device->bXInputDevice) { + /* The slot for XInput devices can change as controllers are seated */ + return SDL_XINPUT_GetSteamVirtualGamepadSlot(device->XInputUserId); + } else { + return device->steam_virtual_gamepad_slot; + } +} + static int WINDOWS_JoystickGetDevicePlayerIndex(int device_index) { JoyStick_DeviceData *device = SYS_Joystick; @@ -676,12 +693,10 @@ static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) /* allocate memory for system specific hardware data */ joystick->instance_id = device->nInstanceID; - joystick->hwdata = - (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata)); - if (joystick->hwdata == NULL) { + joystick->hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(struct joystick_hwdata)); + if (!joystick->hwdata) { return SDL_OutOfMemory(); } - SDL_zerop(joystick->hwdata); joystick->hwdata->guid = device->guid; if (device->bXInputDevice) { @@ -800,6 +815,7 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = { WINDOWS_JoystickDetect, WINDOWS_JoystickGetDeviceName, WINDOWS_JoystickGetDevicePath, + WINDOWS_JoystickGetDeviceSteamVirtualGamepadSlot, WINDOWS_JoystickGetDevicePlayerIndex, WINDOWS_JoystickSetDevicePlayerIndex, WINDOWS_JoystickGetDeviceGUID, @@ -824,9 +840,9 @@ SDL_JoystickDriver SDL_WINDOWS_JoystickDriver = { #else -#if SDL_JOYSTICK_RAWINPUT +#ifdef SDL_JOYSTICK_RAWINPUT /* The RAWINPUT driver needs the device notification setup above */ -#error SDL_JOYSTICK_RAWINPUT requires SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT +#error SDL_JOYSTICK_RAWINPUT requires SDL_JOYSTICK_DINPUT || defined(SDL_JOYSTICK_XINPUT) #endif #endif /* SDL_JOYSTICK_DINPUT || SDL_JOYSTICK_XINPUT */ diff --git a/vs/sdl2/src/joystick/windows/SDL_windowsjoystick_c.h b/vs/sdl2/src/joystick/windows/SDL_windowsjoystick_c.h index 8c601a4212..18c39e8038 100644 --- a/vs/sdl2/src/joystick/windows/SDL_windowsjoystick_c.h +++ b/vs/sdl2/src/joystick/windows/SDL_windowsjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ typedef struct JoyStick_DeviceData Uint8 XInputUserId; DIDEVICEINSTANCE dxdevice; char path[MAX_PATH]; + int steam_virtual_gamepad_slot; struct JoyStick_DeviceData *pNext; } JoyStick_DeviceData; @@ -72,10 +73,11 @@ struct joystick_hwdata { SDL_JoystickGUID guid; -#if SDL_JOYSTICK_DINPUT +#ifdef SDL_JOYSTICK_DINPUT LPDIRECTINPUTDEVICE8 InputDevice; DIDEVCAPS Capabilities; SDL_bool buffered; + SDL_bool first_update; input_t Inputs[MAX_INPUTS]; int NumInputs; int NumSliders; @@ -90,7 +92,7 @@ struct joystick_hwdata DWORD dwPacketNumber; }; -#if SDL_JOYSTICK_DINPUT +#ifdef SDL_JOYSTICK_DINPUT extern const DIDATAFORMAT SDL_c_dfDIJoystick2; #endif diff --git a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c index e3c3bb92d3..1ae7fb4899 100644 --- a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c +++ b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../SDL_sysjoystick.h" -#if SDL_JOYSTICK_XINPUT +#ifdef SDL_JOYSTICK_XINPUT #include "SDL_hints.h" #include "SDL_timer.h" @@ -40,7 +40,6 @@ extern "C" { * Internal stuff. */ static SDL_bool s_bXInputEnabled = SDL_TRUE; -static char *s_arrXInputDevicePath[XUSER_MAX_COUNT]; static SDL_bool SDL_XInputUseOldJoystickMapping() { @@ -116,119 +115,48 @@ static const char *GetXInputName(const Uint8 userid, BYTE SubType) return name; } -/* We can't really tell what device is being used for XInput, but we can guess - and we'll be correct for the case where only one device is connected. - */ -static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) +static SDL_bool GetXInputDeviceInfo(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 *pVersion) { -#if !defined(__WINRT__) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* TODO: remove this ifndef __WINRT__ block, but only after integrating with UWP/WinRT's HID API */ - PRAWINPUTDEVICELIST devices = NULL; - UINT i, j, device_count = 0; + SDL_XINPUT_CAPABILITIES_EX capabilities; - if ((GetRawInputDeviceList(NULL, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!device_count)) { - return; /* oh well. */ + if (!XINPUTGETCAPABILITIESEX || XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) != ERROR_SUCCESS) { + return SDL_FALSE; } - devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); - if (devices == NULL) { - return; + /* Fixup for Wireless Xbox 360 Controller */ + if (capabilities.ProductId == 0 && capabilities.Capabilities.Flags & XINPUT_CAPS_WIRELESS) { + capabilities.VendorId = USB_VENDOR_MICROSOFT; + capabilities.ProductId = USB_PRODUCT_XBOX360_XUSB_CONTROLLER; } - if (GetRawInputDeviceList(devices, &device_count, sizeof(RAWINPUTDEVICELIST)) == -1) { - SDL_free(devices); - return; /* oh well. */ - } - - /* First see if we have a cached entry for this index */ - if (s_arrXInputDevicePath[userid]) { - for (i = 0; i < device_count; i++) { - RID_DEVICE_INFO rdi; - char devName[128]; - UINT rdiSize = sizeof(rdi); - UINT nameSize = SDL_arraysize(devName); - - rdi.cbSize = sizeof(rdi); - if (devices[i].dwType == RIM_TYPEHID && - GetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != (UINT)-1 && - GetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != (UINT)-1) { - if (SDL_strcmp(devName, s_arrXInputDevicePath[userid]) == 0) { - *pVID = (Uint16)rdi.hid.dwVendorId; - *pPID = (Uint16)rdi.hid.dwProductId; - *pVersion = (Uint16)rdi.hid.dwVersionNumber; - SDL_free(devices); - return; - } - } - } + if (pVID) { + *pVID = capabilities.VendorId; + } + if (pPID) { + *pPID = capabilities.ProductId; } + if (pVersion) { + *pVersion = capabilities.ProductVersion; + } + return SDL_TRUE; +} - for (i = 0; i < device_count; i++) { - RID_DEVICE_INFO rdi; - char devName[MAX_PATH]; - UINT rdiSize = sizeof(rdi); - UINT nameSize = SDL_arraysize(devName); +int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid) +{ + SDL_XINPUT_CAPABILITIES_EX capabilities; - rdi.cbSize = sizeof(rdi); - if (devices[i].dwType == RIM_TYPEHID && - GetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) != (UINT)-1 && - GetRawInputDeviceInfoA(devices[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) != (UINT)-1) { -#ifdef DEBUG_JOYSTICK - SDL_Log("Raw input device: VID = 0x%x, PID = 0x%x, %s\n", rdi.hid.dwVendorId, rdi.hid.dwProductId, devName); -#endif - if (SDL_strstr(devName, "IG_") != NULL) { - SDL_bool found = SDL_FALSE; - for (j = 0; j < SDL_arraysize(s_arrXInputDevicePath); ++j) { - if (!s_arrXInputDevicePath[j]) { - continue; - } - if (SDL_strcmp(devName, s_arrXInputDevicePath[j]) == 0) { - found = SDL_TRUE; - break; - } - } - if (found) { - /* We already have this device in our XInput device list */ - continue; - } - - /* We don't actually know if this is the right device for this - * userid, but we'll record it so we'll at least be consistent - * when the raw device list changes. - */ - if (rdi.hid.dwVendorId == USB_VENDOR_VALVE && - rdi.hid.dwProductId == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { - /* Steam encodes the real device in the path */ - int realVID = rdi.hid.dwVendorId; - int realPID = rdi.hid.dwProductId; - (void)SDL_sscanf(devName, "\\\\.\\pipe\\HID#VID_045E&PID_028E&IG_00#%x&%x&", &realVID, &realPID); - *pVID = (Uint16)realVID; - *pPID = (Uint16)realPID; - *pVersion = 0; - } else { - *pVID = (Uint16)rdi.hid.dwVendorId; - *pPID = (Uint16)rdi.hid.dwProductId; - *pVersion = (Uint16)rdi.hid.dwVersionNumber; - } - if (s_arrXInputDevicePath[userid]) { - SDL_free(s_arrXInputDevicePath[userid]); - } - s_arrXInputDevicePath[userid] = SDL_strdup(devName); - SDL_free(devices); - return; - } - } + if (XINPUTGETCAPABILITIESEX && + XINPUTGETCAPABILITIESEX(1, userid, 0, &capabilities) == ERROR_SUCCESS && + capabilities.VendorId == USB_VENDOR_VALVE && + capabilities.ProductId == USB_PRODUCT_STEAM_VIRTUAL_GAMEPAD) { + return (int)capabilities.unk2; } - SDL_free(devices); -#endif /* !__WINRT__ */ - - /* The device wasn't in the raw HID device list, it's probably Bluetooth */ - *pVID = 0x045e; /* Microsoft */ - *pPID = 0x02fd; /* XBox One S Bluetooth */ - *pVersion = 0; + return -1; } static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext) { + const char *name = NULL; Uint16 vendor = 0; Uint16 product = 0; Uint16 version = 0; @@ -276,21 +204,21 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC } pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData)); - if (pNewJoystick == NULL) { + if (!pNewJoystick) { return; /* better luck next time? */ } + name = GetXInputName(userid, SubType); + GetXInputDeviceInfo(userid, &vendor, &product, &version); pNewJoystick->bXInputDevice = SDL_TRUE; - pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, GetXInputName(userid, SubType)); + pNewJoystick->joystickname = SDL_CreateJoystickName(vendor, product, NULL, name); if (!pNewJoystick->joystickname) { SDL_free(pNewJoystick); return; /* better luck next time? */ } (void)SDL_snprintf(pNewJoystick->path, sizeof(pNewJoystick->path), "XInput#%d", userid); if (!SDL_XInputUseOldJoystickMapping()) { - GuessXInputDevice(userid, &vendor, &product, &version); - - pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, vendor, product, version, pNewJoystick->joystickname, 'x', SubType); + pNewJoystick->guid = SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_USB, vendor, product, version, NULL, name, 'x', SubType); } pNewJoystick->SubType = SubType; pNewJoystick->XInputUserId = userid; @@ -302,7 +230,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC #ifdef SDL_JOYSTICK_HIDAPI /* Since we're guessing about the VID/PID, use a hard-coded VID/PID to represent XInput */ - if (HIDAPI_IsDevicePresent(USB_VENDOR_MICROSOFT, USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER, version, pNewJoystick->joystickname)) { + if (HIDAPI_IsDevicePresent(USB_VENDOR_MICROSOFT, USB_PRODUCT_XBOX360_XUSB_CONTROLLER, version, pNewJoystick->joystickname)) { /* The HIDAPI driver is taking care of this device */ SDL_free(pNewJoystick); return; @@ -320,14 +248,6 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC WINDOWS_AddJoystickDevice(pNewJoystick); } -static void DelXInputDevice(Uint8 userid) -{ - if (s_arrXInputDevicePath[userid]) { - SDL_free(s_arrXInputDevicePath[userid]); - s_arrXInputDevicePath[userid] = NULL; - } -} - void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { int iuserid; @@ -341,21 +261,7 @@ void SDL_XINPUT_JoystickDetect(JoyStick_DeviceData **pContext) const Uint8 userid = (Uint8)iuserid; XINPUT_CAPABILITIES capabilities; if (XINPUTGETCAPABILITIES(userid, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS) { - /* Adding a new device, must handle all removes first, or GuessXInputDevice goes terribly wrong (returns - a product/vendor ID that is not even attached to the system) when we get a remove and add on the same tick - (e.g. when disconnecting a device and the OS reassigns which userid an already-attached controller is) - */ - int iuserid2; - for (iuserid2 = iuserid - 1; iuserid2 >= 0; iuserid2--) { - const Uint8 userid2 = (Uint8)iuserid2; - XINPUT_CAPABILITIES capabilities2; - if (XINPUTGETCAPABILITIES(userid2, XINPUT_FLAG_GAMEPAD, &capabilities2) != ERROR_SUCCESS) { - DelXInputDevice(userid2); - } - } AddXInputDevice(userid, capabilities.SubType, pContext); - } else { - DelXInputDevice(userid); } } } @@ -422,7 +328,7 @@ static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPU } } -static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) +static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { static WORD s_XInputButtons[] = { XINPUT_GAMEPAD_DPAD_UP, XINPUT_GAMEPAD_DPAD_DOWN, XINPUT_GAMEPAD_DPAD_LEFT, XINPUT_GAMEPAD_DPAD_RIGHT, @@ -448,7 +354,7 @@ static void UpdateXInputJoystickState_OLD(SDL_Joystick *joystick, XINPUT_STATE_E UpdateXInputJoystickBatteryInformation(joystick, pBatteryInformation); } -static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) +static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation) { static WORD s_XInputButtons[] = { XINPUT_GAMEPAD_A, XINPUT_GAMEPAD_B, XINPUT_GAMEPAD_X, XINPUT_GAMEPAD_Y, @@ -462,13 +368,9 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE_EX *p SDL_PrivateJoystickAxis(joystick, 0, pXInputState->Gamepad.sThumbLX); SDL_PrivateJoystickAxis(joystick, 1, ~pXInputState->Gamepad.sThumbLY); - //SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); - //SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX); - //SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY); - // Fixes for DOSBox-X - SDL_PrivateJoystickAxis(joystick, 2, pXInputState->Gamepad.sThumbRX); - SDL_PrivateJoystickAxis(joystick, 3, ~pXInputState->Gamepad.sThumbRY); - SDL_PrivateJoystickAxis(joystick, 4, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); + SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); + SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX); + SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY); SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768); for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) { @@ -516,7 +418,7 @@ Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick) void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick) { HRESULT result; - XINPUT_STATE_EX XInputState; + XINPUT_STATE XInputState; XINPUT_BATTERY_INFORMATION_EX XBatteryInformation; if (!XINPUTGETSTATE) { diff --git a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick_c.h b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick_c.h index 05950fd4c7..8eaa849a7c 100644 --- a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick_c.h +++ b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ extern Uint32 SDL_XINPUT_JoystickGetCapabilities(SDL_Joystick *joystick); extern void SDL_XINPUT_JoystickUpdate(SDL_Joystick *joystick); extern void SDL_XINPUT_JoystickClose(SDL_Joystick *joystick); extern void SDL_XINPUT_JoystickQuit(void); +extern int SDL_XINPUT_GetSteamVirtualGamepadSlot(Uint8 userid); /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/vs/sdl2/src/libm/math_libm.h b/vs/sdl2/src/libm/math_libm.h index e1ac4ac975..831a184767 100644 --- a/vs/sdl2/src/libm/math_libm.h +++ b/vs/sdl2/src/libm/math_libm.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/loadso/dlopen/SDL_sysloadso.c b/vs/sdl2/src/loadso/dlopen/SDL_sysloadso.c index 7e80cbfbe9..f08209c1d7 100644 --- a/vs/sdl2/src/loadso/dlopen/SDL_sysloadso.c +++ b/vs/sdl2/src/loadso/dlopen/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +30,7 @@ #include "SDL_loadso.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "../../video/uikit/SDL_uikitvideo.h" #endif @@ -39,7 +39,7 @@ void *SDL_LoadObject(const char *sofile) void *handle; const char *loaderror; -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT if (!UIKit_IsSystemVersionAtLeast(8.0)) { SDL_SetError("SDL_LoadObject requires iOS 8+"); return NULL; @@ -48,7 +48,7 @@ void *SDL_LoadObject(const char *sofile) handle = dlopen(sofile, RTLD_NOW | RTLD_LOCAL); loaderror = dlerror(); - if (handle == NULL) { + if (!handle) { SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return handle; @@ -57,7 +57,7 @@ void *SDL_LoadObject(const char *sofile) void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = dlsym(handle, name); - if (symbol == NULL) { + if (!symbol) { /* prepend an underscore for platforms that need that. */ SDL_bool isstack; size_t len = SDL_strlen(name) + 1; @@ -66,7 +66,7 @@ void *SDL_LoadFunction(void *handle, const char *name) SDL_memcpy(&_name[1], name, len); symbol = dlsym(handle, _name); SDL_small_free(_name, isstack); - if (symbol == NULL) { + if (!symbol) { SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); } @@ -76,7 +76,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { dlclose(handle); } } diff --git a/vs/sdl2/src/loadso/dummy/SDL_sysloadso.c b/vs/sdl2/src/loadso/dummy/SDL_sysloadso.c index e9c2e28a51..b03703b16e 100644 --- a/vs/sdl2/src/loadso/dummy/SDL_sysloadso.c +++ b/vs/sdl2/src/loadso/dummy/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/loadso/os2/SDL_sysloadso.c b/vs/sdl2/src/loadso/os2/SDL_sysloadso.c index c5c8b3b32c..a48db99d5b 100644 --- a/vs/sdl2/src/loadso/os2/SDL_sysloadso.c +++ b/vs/sdl2/src/loadso/os2/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +90,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { DosFreeModule((HMODULE)handle); } } diff --git a/vs/sdl2/src/loadso/windows/SDL_sysloadso.c b/vs/sdl2/src/loadso/windows/SDL_sysloadso.c index ca43370c84..1fcee3d42e 100644 --- a/vs/sdl2/src/loadso/windows/SDL_sysloadso.c +++ b/vs/sdl2/src/loadso/windows/SDL_sysloadso.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +34,7 @@ void *SDL_LoadObject(const char *sofile) void *handle; LPTSTR tstr; - if (sofile == NULL) { + if (!sofile) { SDL_InvalidParamError("sofile"); return NULL; } @@ -51,7 +51,7 @@ void *SDL_LoadObject(const char *sofile) SDL_free(tstr); /* Generate an error message if all loads failed */ - if (handle == NULL) { + if (!handle) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf)); @@ -63,7 +63,7 @@ void *SDL_LoadObject(const char *sofile) void *SDL_LoadFunction(void *handle, const char *name) { void *symbol = (void *)GetProcAddress((HMODULE)handle, name); - if (symbol == NULL) { + if (!symbol) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, name, SDL_arraysize(errbuf)); @@ -74,7 +74,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { FreeLibrary((HMODULE)handle); } } diff --git a/vs/sdl2/src/locale/SDL_locale.c b/vs/sdl2/src/locale/SDL_locale.c index 0c8f611ac4..ea3e858a10 100644 --- a/vs/sdl2/src/locale/SDL_locale.c +++ b/vs/sdl2/src/locale/SDL_locale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) SDL_Locale *loc; SDL_Locale *retval; - if (csv == NULL || !csv[0]) { + if (!csv || !csv[0]) { return NULL; /* nothing to report */ } @@ -48,7 +48,7 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) alloclen = slen + (num_locales * sizeof(SDL_Locale)); loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; /* oh well */ } diff --git a/vs/sdl2/src/locale/SDL_syslocale.h b/vs/sdl2/src/locale/SDL_syslocale.h index 6072036ad3..32171604c5 100644 --- a/vs/sdl2/src/locale/SDL_syslocale.h +++ b/vs/sdl2/src/locale/SDL_syslocale.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/android/SDL_syslocale.c b/vs/sdl2/src/locale/android/SDL_syslocale.c index d8c6ebfb2d..9a447d0786 100644 --- a/vs/sdl2/src/locale/android/SDL_syslocale.c +++ b/vs/sdl2/src/locale/android/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/dummy/SDL_syslocale.c b/vs/sdl2/src/locale/dummy/SDL_syslocale.c index f5cf9dace3..89a7b1de86 100644 --- a/vs/sdl2/src/locale/dummy/SDL_syslocale.c +++ b/vs/sdl2/src/locale/dummy/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/emscripten/SDL_syslocale.c b/vs/sdl2/src/locale/emscripten/SDL_syslocale.c index dee403c300..3b148acbf6 100644 --- a/vs/sdl2/src/locale/emscripten/SDL_syslocale.c +++ b/vs/sdl2/src/locale/emscripten/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/haiku/SDL_syslocale.cc b/vs/sdl2/src/locale/haiku/SDL_syslocale.cc index 70af4df7b2..016a17c6b9 100644 --- a/vs/sdl2/src/locale/haiku/SDL_syslocale.cc +++ b/vs/sdl2/src/locale/haiku/SDL_syslocale.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/macosx/SDL_syslocale.m b/vs/sdl2/src/locale/macosx/SDL_syslocale.m index 3a0e5db9e1..57f40fef94 100644 --- a/vs/sdl2/src/locale/macosx/SDL_syslocale.m +++ b/vs/sdl2/src/locale/macosx/SDL_syslocale.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/n3ds/SDL_syslocale.c b/vs/sdl2/src/locale/n3ds/SDL_syslocale.c index fcc01fd0eb..1573f28bc0 100644 --- a/vs/sdl2/src/locale/n3ds/SDL_syslocale.c +++ b/vs/sdl2/src/locale/n3ds/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +33,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) { /* The 3DS only supports these 12 languages, only one can be active at a time */ static const char AVAILABLE_LOCALES[][6] = { "ja_JP", "en_US", "fr_FR", "de_DE", - "it_IT", "es_ES", "zn_CN", "ko_KR", + "it_IT", "es_ES", "zh_CN", "ko_KR", "nl_NL", "pt_PT", "ru_RU", "zh_TW" }; u8 current_locale = GetLocaleIndex(); if (current_locale != BAD_LOCALE) { @@ -45,14 +45,13 @@ SDL_FORCE_INLINE u8 GetLocaleIndex(void) { u8 current_locale; + Result result; if (R_FAILED(cfguInit())) { return BAD_LOCALE; } - if (R_FAILED(CFGU_GetSystemLanguage(¤t_locale))) { - return BAD_LOCALE; - } + result = CFGU_GetSystemLanguage(¤t_locale); cfguExit(); - return current_locale; + return R_SUCCEEDED(result) ? current_locale : BAD_LOCALE; } /* vi: set sts=4 ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/locale/unix/SDL_syslocale.c b/vs/sdl2/src/locale/unix/SDL_syslocale.c index 2b9f877fc3..f1e59cc965 100644 --- a/vs/sdl2/src/locale/unix/SDL_syslocale.c +++ b/vs/sdl2/src/locale/unix/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 +27,12 @@ static void normalize_locale_str(char *dst, char *str, size_t buflen) char *ptr; ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } @@ -71,7 +71,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) SDL_assert(buflen > 0); tmp = SDL_small_alloc(char, buflen, &isstack); - if (tmp == NULL) { + if (!tmp) { SDL_OutOfMemory(); return; } diff --git a/vs/sdl2/src/locale/vita/SDL_syslocale.c b/vs/sdl2/src/locale/vita/SDL_syslocale.c index d0d91e0b61..780b9ad9a3 100644 --- a/vs/sdl2/src/locale/vita/SDL_syslocale.c +++ b/vs/sdl2/src/locale/vita/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/locale/windows/SDL_syslocale.c b/vs/sdl2/src/locale/windows/SDL_syslocale.c index 169df915af..2449b15686 100644 --- a/vs/sdl2/src/locale/windows/SDL_syslocale.c +++ b/vs/sdl2/src/locale/windows/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +65,7 @@ static void SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen); wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack); - if (wbuf == NULL) { + if (!wbuf) { SDL_OutOfMemory(); return; } @@ -102,7 +102,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } } - if (pGetUserPreferredUILanguages == NULL) { + if (!pGetUserPreferredUILanguages) { SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */ } else { SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */ diff --git a/vs/sdl2/src/locale/winrt/SDL_syslocale.c b/vs/sdl2/src/locale/winrt/SDL_syslocale.c index 3995f9a2bc..8fdeec7038 100644 --- a/vs/sdl2/src/locale/winrt/SDL_syslocale.c +++ b/vs/sdl2/src/locale/winrt/SDL_syslocale.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +33,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) int ret = 0; /* !!! FIXME: do we not have GetUserPreferredUILanguages on WinPhone or UWP? */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE ret = GetLocaleInfoEx(LOCALE_NAME_SYSTEM_DEFAULT, LOCALE_SNAME, wbuffer, SDL_arraysize(wbuffer)); #else ret = GetSystemDefaultLocaleName(wbuffer, SDL_arraysize(wbuffer)); diff --git a/vs/sdl2/src/main/gdk/SDL_gdk_main.c b/vs/sdl2/src/main/gdk/SDL_gdk_main.c index a38afa44ac..7bfd9cc958 100644 --- a/vs/sdl2/src/main/gdk/SDL_gdk_main.c +++ b/vs/sdl2/src/main/gdk/SDL_gdk_main.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/main/haiku/SDL_BApp.h b/vs/sdl2/src/main/haiku/SDL_BApp.h index 0368081677..284445d986 100644 --- a/vs/sdl2/src/main/haiku/SDL_BApp.h +++ b/vs/sdl2/src/main/haiku/SDL_BApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ #include #include #include -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL #include #endif @@ -85,7 +85,7 @@ class SDL_BLooper : public BLooper public: SDL_BLooper(const char* name) : BLooper(name) { -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL _current_context = NULL; #endif } @@ -199,7 +199,7 @@ class SDL_BLooper : public BLooper return _window_map[winID]; } -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *GetCurrentContext() { return _current_context; @@ -419,7 +419,7 @@ class SDL_BLooper : public BLooper /* Members */ std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *_current_context; #endif }; diff --git a/vs/sdl2/src/main/haiku/SDL_BeApp.cc b/vs/sdl2/src/main/haiku/SDL_BeApp.cc index 63af36bdb1..a736a9f097 100644 --- a/vs/sdl2/src/main/haiku/SDL_BeApp.cc +++ b/vs/sdl2/src/main/haiku/SDL_BeApp.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -109,13 +109,13 @@ static int StartBeLooper() { if (!be_app) { SDL_AppThread = SDL_CreateThreadInternal(StartBeApp, "SDLApplication", 0, NULL); - if (SDL_AppThread == NULL) { + if (!SDL_AppThread) { return SDL_SetError("Couldn't create BApplication thread"); } do { SDL_Delay(10); - } while ((be_app == NULL) || be_app->IsLaunching()); + } while ((!be_app) || be_app->IsLaunching()); } /* Change working directory to that of executable */ @@ -168,7 +168,7 @@ void SDL_QuitBeApp(void) SDL_Looper->Lock(); SDL_Looper->Quit(); SDL_Looper = NULL; - if (SDL_AppThread != NULL) { + if (SDL_AppThread) { if (be_app != NULL) { /* Not tested */ be_app->PostMessage(B_QUIT_REQUESTED); } diff --git a/vs/sdl2/src/main/haiku/SDL_BeApp.h b/vs/sdl2/src/main/haiku/SDL_BeApp.h index 9a5adb8ef9..8b8cc0f15e 100644 --- a/vs/sdl2/src/main/haiku/SDL_BeApp.h +++ b/vs/sdl2/src/main/haiku/SDL_BeApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/main/n3ds/SDL_n3ds_main.c b/vs/sdl2/src/main/n3ds/SDL_n3ds_main.c index db8177c84c..844416ff95 100644 --- a/vs/sdl2/src/main/n3ds/SDL_n3ds_main.c +++ b/vs/sdl2/src/main/n3ds/SDL_n3ds_main.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/main/nacl/SDL_nacl_main.c b/vs/sdl2/src/main/nacl/SDL_nacl_main.c index 10d94e227b..174b85b0a6 100644 --- a/vs/sdl2/src/main/nacl/SDL_nacl_main.c +++ b/vs/sdl2/src/main/nacl/SDL_nacl_main.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL /* Include the SDL main definition header */ #include "SDL_main.h" diff --git a/vs/sdl2/src/main/ngage/SDL_ngage_main.cpp b/vs/sdl2/src/main/ngage/SDL_ngage_main.cpp index 10d848870a..7439a2fd12 100644 --- a/vs/sdl2/src/main/ngage/SDL_ngage_main.cpp +++ b/vs/sdl2/src/main/ngage/SDL_ngage_main.cpp @@ -58,7 +58,7 @@ TInt E32Main() newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); - if (newHeap == NULL) { + if (!newHeap) { ret = 3; goto cleanup; } else { diff --git a/vs/sdl2/src/main/windows/SDL_windows_main.c b/vs/sdl2/src/main/windows/SDL_windows_main.c index 189b954202..bad49b0caf 100644 --- a/vs/sdl2/src/main/windows/SDL_windows_main.c +++ b/vs/sdl2/src/main/windows/SDL_windows_main.c @@ -43,7 +43,7 @@ static int main_getcmdline(void) int i, argc, result; argvw = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argvw == NULL) { + if (!argvw) { return OutOfMemory(); } @@ -54,13 +54,13 @@ static int main_getcmdline(void) /* Parse it into argv and argc */ argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); - if (argv == NULL) { + if (!argv) { return OutOfMemory(); } for (i = 0; i < argc; ++i) { DWORD len; char *arg = WIN_StringToUTF8W(argvw[i]); - if (arg == NULL) { + if (!arg) { return OutOfMemory(); } len = (DWORD)SDL_strlen(arg); diff --git a/vs/sdl2/src/main/windows/version.rc b/vs/sdl2/src/main/windows/version.rc index 69f17e37ae..4862fdd649 100644 --- a/vs/sdl2/src/main/windows/version.rc +++ b/vs/sdl2/src/main/windows/version.rc @@ -9,8 +9,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,28,2,0 - PRODUCTVERSION 2,28,2,0 + FILEVERSION 2,30,4,0 + PRODUCTVERSION 2,30,4,0 FILEFLAGSMASK 0x3fL FILEFLAGS 0x0L FILEOS 0x40004L @@ -23,12 +23,12 @@ BEGIN BEGIN VALUE "CompanyName", "\0" VALUE "FileDescription", "SDL\0" - VALUE "FileVersion", "2, 28, 2, 0\0" + VALUE "FileVersion", "2, 30, 4, 0\0" VALUE "InternalName", "SDL\0" - VALUE "LegalCopyright", "Copyright (C) 2023 Sam Lantinga\0" + VALUE "LegalCopyright", "Copyright (C) 2024 Sam Lantinga\0" VALUE "OriginalFilename", "SDL2.dll\0" VALUE "ProductName", "Simple DirectMedia Layer\0" - VALUE "ProductVersion", "2, 28, 2, 0\0" + VALUE "ProductVersion", "2, 30, 4, 0\0" END END BLOCK "VarFileInfo" diff --git a/vs/sdl2/src/misc/SDL_sysurl.h b/vs/sdl2/src/misc/SDL_sysurl.h index ae769320a0..f2a4f9b925 100644 --- a/vs/sdl2/src/misc/SDL_sysurl.h +++ b/vs/sdl2/src/misc/SDL_sysurl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/SDL_url.c b/vs/sdl2/src/misc/SDL_url.c index 22faa8417b..9876bf21a6 100644 --- a/vs/sdl2/src/misc/SDL_url.c +++ b/vs/sdl2/src/misc/SDL_url.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ int SDL_OpenURL(const char *url) { - if (url == NULL) { + if (!url) { return SDL_InvalidParamError("url"); } return SDL_SYS_OpenURL(url); diff --git a/vs/sdl2/src/misc/android/SDL_sysurl.c b/vs/sdl2/src/misc/android/SDL_sysurl.c index 577e0c3888..e7e21d272b 100644 --- a/vs/sdl2/src/misc/android/SDL_sysurl.c +++ b/vs/sdl2/src/misc/android/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/dummy/SDL_sysurl.c b/vs/sdl2/src/misc/dummy/SDL_sysurl.c index 3f43628eb0..a5fa7cbab9 100644 --- a/vs/sdl2/src/misc/dummy/SDL_sysurl.c +++ b/vs/sdl2/src/misc/dummy/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/emscripten/SDL_sysurl.c b/vs/sdl2/src/misc/emscripten/SDL_sysurl.c index 12cb156a72..87c1a0ca3d 100644 --- a/vs/sdl2/src/misc/emscripten/SDL_sysurl.c +++ b/vs/sdl2/src/misc/emscripten/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +23,11 @@ #include +EM_JS_DEPS(sdlsysurl, "$UTF8ToString"); + int SDL_SYS_OpenURL(const char *url) { - EM_ASM({ - window.open(UTF8ToString($0), "_blank"); - }, - url); - + EM_ASM(window.open(UTF8ToString($0), "_blank"), url); return 0; } diff --git a/vs/sdl2/src/misc/haiku/SDL_sysurl.cc b/vs/sdl2/src/misc/haiku/SDL_sysurl.cc index 68b0310212..85fd622a01 100644 --- a/vs/sdl2/src/misc/haiku/SDL_sysurl.cc +++ b/vs/sdl2/src/misc/haiku/SDL_sysurl.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/ios/SDL_sysurl.m b/vs/sdl2/src/misc/ios/SDL_sysurl.m index 61c931ead9..76363b50dc 100644 --- a/vs/sdl2/src/misc/ios/SDL_sysurl.m +++ b/vs/sdl2/src/misc/ios/SDL_sysurl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/macosx/SDL_sysurl.m b/vs/sdl2/src/misc/macosx/SDL_sysurl.m index 657c8f5209..d6088d1330 100644 --- a/vs/sdl2/src/misc/macosx/SDL_sysurl.m +++ b/vs/sdl2/src/misc/macosx/SDL_sysurl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/riscos/SDL_sysurl.c b/vs/sdl2/src/misc/riscos/SDL_sysurl.c index f4d588ee01..bbb78c9ce5 100644 --- a/vs/sdl2/src/misc/riscos/SDL_sysurl.c +++ b/vs/sdl2/src/misc/riscos/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/unix/SDL_sysurl.c b/vs/sdl2/src/misc/unix/SDL_sysurl.c index 75d692bd55..050446df58 100644 --- a/vs/sdl2/src/misc/unix/SDL_sysurl.c +++ b/vs/sdl2/src/misc/unix/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int SDL_SYS_OpenURL(const char *url) { const pid_t pid1 = fork(); if (pid1 == 0) { /* child process */ +#ifdef USE_POSIX_SPAWN + pid_t pid2; + const char *args[] = { "xdg-open", url, NULL }; + /* Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam */ + unsetenv("LD_PRELOAD"); + if (posix_spawnp(&pid2, args[0], NULL, NULL, (char **)args, environ) == 0) { + /* Child process doesn't wait for possibly-blocking grandchild. */ + _exit(EXIT_SUCCESS); + } else { + _exit(EXIT_FAILURE); + } +#else pid_t pid2; /* Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam */ unsetenv("LD_PRELOAD"); @@ -46,6 +58,7 @@ int SDL_SYS_OpenURL(const char *url) /* Child process doesn't wait for possibly-blocking grandchild. */ _exit(EXIT_SUCCESS); } +#endif /* USE_POSIX_SPAWN */ } else if (pid1 < 0) { return SDL_SetError("fork() failed: %s", strerror(errno)); } else { diff --git a/vs/sdl2/src/misc/vita/SDL_sysurl.c b/vs/sdl2/src/misc/vita/SDL_sysurl.c index e96c18e5ad..fca6b2f326 100644 --- a/vs/sdl2/src/misc/vita/SDL_sysurl.c +++ b/vs/sdl2/src/misc/vita/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/misc/windows/SDL_sysurl.c b/vs/sdl2/src/misc/windows/SDL_sysurl.c index 6f9c46d4f8..8462babe5e 100644 --- a/vs/sdl2/src/misc/windows/SDL_sysurl.c +++ b/vs/sdl2/src/misc/windows/SDL_sysurl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ int SDL_SYS_OpenURL(const char *url) } wurl = WIN_UTF8ToStringW(url); - if (wurl == NULL) { + if (!wurl) { WIN_CoUninitialize(); return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/misc/winrt/SDL_sysurl.cpp b/vs/sdl2/src/misc/winrt/SDL_sysurl.cpp index 93fd7b0e75..f435ab97d1 100644 --- a/vs/sdl2/src/misc/winrt/SDL_sysurl.cpp +++ b/vs/sdl2/src/misc/winrt/SDL_sysurl.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/power/SDL_power.c b/vs/sdl2/src/power/SDL_power.c index 63ba38221e..a64cace49c 100644 --- a/vs/sdl2/src/power/SDL_power.c +++ b/vs/sdl2/src/power/SDL_power.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +95,10 @@ SDL_PowerState SDL_GetPowerInfo(int *seconds, int *percent) int _seconds, _percent; /* Make these never NULL for platform-specific implementations. */ - if (seconds == NULL) { + if (!seconds) { seconds = &_seconds; } - if (percent == NULL) { + if (!percent) { percent = &_percent; } diff --git a/vs/sdl2/src/power/SDL_syspower.h b/vs/sdl2/src/power/SDL_syspower.h index 5401a0ee30..25b22fc1cb 100644 --- a/vs/sdl2/src/power/SDL_syspower.h +++ b/vs/sdl2/src/power/SDL_syspower.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/power/android/SDL_syspower.c b/vs/sdl2/src/power/android/SDL_syspower.c index 3dccdecdae..3da49e5d8a 100644 --- a/vs/sdl2/src/power/android/SDL_syspower.c +++ b/vs/sdl2/src/power/android/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_ANDROID +#ifdef SDL_POWER_ANDROID #include "SDL_power.h" #include "../SDL_syspower.h" diff --git a/vs/sdl2/src/power/emscripten/SDL_syspower.c b/vs/sdl2/src/power/emscripten/SDL_syspower.c index 6a1f3176ca..aed93b0c41 100644 --- a/vs/sdl2/src/power/emscripten/SDL_syspower.c +++ b/vs/sdl2/src/power/emscripten/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_EMSCRIPTEN +#ifdef SDL_POWER_EMSCRIPTEN #include diff --git a/vs/sdl2/src/power/haiku/SDL_syspower.c b/vs/sdl2/src/power/haiku/SDL_syspower.c index 6e7dd928e2..ec3d4b9f5d 100644 --- a/vs/sdl2/src/power/haiku/SDL_syspower.c +++ b/vs/sdl2/src/power/haiku/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ /* !!! FIXME: does this thing even work on Haiku? */ #ifndef SDL_POWER_DISABLED -#if SDL_POWER_HAIKU +#ifdef SDL_POWER_HAIKU #include #include diff --git a/vs/sdl2/src/power/linux/SDL_syspower.c b/vs/sdl2/src/power/linux/SDL_syspower.c index 84100e8561..7899e3d190 100644 --- a/vs/sdl2/src/power/linux/SDL_syspower.c +++ b/vs/sdl2/src/power/linux/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_LINUX +#ifdef SDL_POWER_LINUX #include #include @@ -46,7 +46,7 @@ static int open_power_file(const char *base, const char *node, const char *key) int fd; const size_t pathlen = SDL_strlen(base) + SDL_strlen(node) + SDL_strlen(key) + 3; char *path = SDL_stack_alloc(char, pathlen); - if (path == NULL) { + if (!path) { return -1; /* oh well. */ } @@ -242,7 +242,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i *state = SDL_POWERSTATE_UNKNOWN; dirp = opendir(proc_acpi_battery_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -254,7 +254,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i } dirp = opendir(proc_acpi_ac_adapter_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -425,7 +425,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in DIR *dirp; dirp = opendir(base); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; } @@ -521,7 +521,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in } /* d-bus queries to org.freedesktop.UPower. */ -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS #define UPOWER_DBUS_NODE "org.freedesktop.UPower" #define UPOWER_DBUS_PATH "/org/freedesktop/UPower" #define UPOWER_DBUS_INTERFACE "org.freedesktop.UPower" @@ -562,9 +562,17 @@ static void check_upower_device(DBusConnection *conn, const char *path, SDL_Powe st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ } else if (ui32 == 1) { /* 1 == charging */ st = SDL_POWERSTATE_CHARGING; - } else if ((ui32 == 2) || (ui32 == 3)) { /* 2 == discharging, 3 == empty. */ + } else if ((ui32 == 2) || (ui32 == 3) || (ui32 == 6)) { + /* 2 == discharging; + * 3 == empty; + * 6 == "pending discharge" which GNOME interprets as equivalent + * to discharging */ st = SDL_POWERSTATE_ON_BATTERY; - } else if (ui32 == 4) { /* 4 == full */ + } else if ((ui32 == 4) || (ui32 == 5)) { + /* 4 == full; + * 5 == "pending charge" which GNOME shows as "Not charging", + * used when a battery is configured to stop charging at a + * lower than 100% threshold */ st = SDL_POWERSTATE_CHARGED; } else { st = SDL_POWERSTATE_UNKNOWN; /* uh oh */ @@ -611,12 +619,12 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in { SDL_bool retval = SDL_FALSE; -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS SDL_DBusContext *dbus = SDL_DBus_GetContext(); char **paths = NULL; int i, numpaths = 0; - if (dbus == NULL || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", + if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { return SDL_FALSE; /* try a different approach than UPower. */ diff --git a/vs/sdl2/src/power/macosx/SDL_syspower.c b/vs/sdl2/src/power/macosx/SDL_syspower.c index b6af7682b3..a3881f3746 100644 --- a/vs/sdl2/src/power/macosx/SDL_syspower.c +++ b/vs/sdl2/src/power/macosx/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_MACOSX +#ifdef SDL_POWER_MACOSX #include #include diff --git a/vs/sdl2/src/power/n3ds/SDL_syspower.c b/vs/sdl2/src/power/n3ds/SDL_syspower.c index b565643e93..9b5555ee1b 100644 --- a/vs/sdl2/src/power/n3ds/SDL_syspower.c +++ b/vs/sdl2/src/power/n3ds/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/power/psp/SDL_syspower.c b/vs/sdl2/src/power/psp/SDL_syspower.c index 2811978587..4b9d145311 100644 --- a/vs/sdl2/src/power/psp/SDL_syspower.c +++ b/vs/sdl2/src/power/psp/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_PSP +#ifdef SDL_POWER_PSP #include "SDL_power.h" #include diff --git a/vs/sdl2/src/power/uikit/SDL_syspower.h b/vs/sdl2/src/power/uikit/SDL_syspower.h index 73149c8a35..9d5c6a88bd 100644 --- a/vs/sdl2/src/power/uikit/SDL_syspower.h +++ b/vs/sdl2/src/power/uikit/SDL_syspower.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_POWER_UIKIT +#ifdef SDL_POWER_UIKIT #include "SDL_power.h" diff --git a/vs/sdl2/src/power/uikit/SDL_syspower.m b/vs/sdl2/src/power/uikit/SDL_syspower.m index 5b9076b573..d366d6548c 100644 --- a/vs/sdl2/src/power/uikit/SDL_syspower.m +++ b/vs/sdl2/src/power/uikit/SDL_syspower.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_UIKIT +#ifdef SDL_POWER_UIKIT #import diff --git a/vs/sdl2/src/power/vita/SDL_syspower.c b/vs/sdl2/src/power/vita/SDL_syspower.c index 6c28e92232..644b72a425 100644 --- a/vs/sdl2/src/power/vita/SDL_syspower.c +++ b/vs/sdl2/src/power/vita/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_VITA +#ifdef SDL_POWER_VITA #include "SDL_power.h" #include diff --git a/vs/sdl2/src/power/windows/SDL_syspower.c b/vs/sdl2/src/power/windows/SDL_syspower.c index f1d7d8897f..58fa9a8eab 100644 --- a/vs/sdl2/src/power/windows/SDL_syspower.c +++ b/vs/sdl2/src/power/windows/SDL_syspower.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" #ifndef SDL_POWER_DISABLED -#if SDL_POWER_WINDOWS +#ifdef SDL_POWER_WINDOWS #include "../../core/windows/SDL_windows.h" diff --git a/vs/sdl2/src/power/winrt/SDL_syspower.cpp b/vs/sdl2/src/power/winrt/SDL_syspower.cpp index 2a46de7c94..1fc971fac4 100644 --- a/vs/sdl2/src/power/winrt/SDL_syspower.cpp +++ b/vs/sdl2/src/power/winrt/SDL_syspower.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/SDL_d3dmath.c b/vs/sdl2/src/render/SDL_d3dmath.c index d1cac1388b..021b8c2eec 100644 --- a/vs/sdl2/src/render/SDL_d3dmath.c +++ b/vs/sdl2/src/render/SDL_d3dmath.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../SDL_internal.h" -#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED +#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) #include "SDL_stdinc.h" #include "SDL_d3dmath.h" @@ -130,6 +130,6 @@ Float4X4 MatrixRotationZ(float r) return m; } -#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */ +#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/SDL_d3dmath.h b/vs/sdl2/src/render/SDL_d3dmath.h index 7383873c11..9ef2f53ed4 100644 --- a/vs/sdl2/src/render/SDL_d3dmath.h +++ b/vs/sdl2/src/render/SDL_d3dmath.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../SDL_internal.h" -#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED +#if (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -78,6 +78,6 @@ Float4X4 MatrixRotationZ(float r); } #endif -#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) && !SDL_RENDER_DISABLED */ +#endif /* (SDL_VIDEO_RENDER_D3D || SDL_VIDEO_RENDER_D3D11 || SDL_VIDEO_RENDER_D3D12) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/SDL_render.c b/vs/sdl2/src/render/SDL_render.c index 21d6324cb1..f7fcc52c99 100644 --- a/vs/sdl2/src/render/SDL_render.c +++ b/vs/sdl2/src/render/SDL_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ this should probably be removed at some point in the future. --ryan. */ SDL_COMPOSE_BLENDMODE(SDL_BLENDFACTOR_DST_COLOR, SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA, SDL_BLENDOPERATION_ADD, \ SDL_BLENDFACTOR_ZERO, SDL_BLENDFACTOR_ONE, SDL_BLENDOPERATION_ADD) -#if !SDL_RENDER_DISABLED +#ifndef SDL_RENDER_DISABLED static const SDL_RenderDriver *render_drivers[] = { #if SDL_VIDEO_RENDER_D3D &D3D_RenderDriver, @@ -239,7 +239,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (renderer->render_commands == NULL) { /* nothing to do! */ + if (!renderer->render_commands) { /* nothing to do! */ SDL_assert(renderer->vertex_data_used == 0); return 0; } @@ -249,7 +249,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) retval = renderer->RunCommandQueue(renderer, renderer->render_commands, renderer->vertex_data, renderer->vertex_data_used); /* Move the whole render command queue to the unused pool so we can reuse them next time. */ - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; renderer->render_commands_pool = renderer->render_commands; renderer->render_commands_tail = NULL; @@ -301,7 +301,7 @@ void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, ptr = SDL_realloc(renderer->vertex_data, newsize); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -324,19 +324,19 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) /* !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. */ retval = renderer->render_commands_pool; - if (retval != NULL) { + if (retval) { renderer->render_commands_pool = retval->next; retval->next = NULL; } else { retval = SDL_calloc(1, sizeof(*retval)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } } SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = retval; } else { renderer->render_commands = retval; @@ -352,7 +352,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) if (!renderer->viewport_queued || (SDL_memcmp(&renderer->viewport, &renderer->last_queued_viewport, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETVIEWPORT; cmd->data.viewport.first = 0; /* render backend will fill this in. */ /* Convert SDL_DRect to SDL_Rect */ @@ -379,7 +379,7 @@ static int QueueCmdSetClipRect(SDL_Renderer *renderer) (renderer->clipping_enabled != renderer->last_queued_cliprect_enabled) || (SDL_memcmp(&renderer->clip_rect, &renderer->last_queued_cliprect, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { retval = -1; } else { cmd->command = SDL_RENDERCMD_SETCLIPRECT; @@ -406,7 +406,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETDRAWCOLOR; cmd->data.color.first = 0; /* render backend will fill this in. */ cmd->data.color.r = col->r; @@ -428,7 +428,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) static int QueueCmdClear(SDL_Renderer *renderer) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { return -1; } @@ -472,7 +472,7 @@ static SDL_RenderCommand *PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_Ren if (retval == 0) { cmd = AllocateRenderCommand(renderer); - if (cmd != NULL) { + if (cmd) { cmd->command = cmdtype; cmd->data.draw.first = 0; /* render backend will fill this in. */ cmd->data.draw.count = 0; /* render backend will fill this in. */ @@ -491,7 +491,7 @@ static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_POINTS, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawPoints(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -504,7 +504,7 @@ static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, c { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_LINES, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawLines(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -517,11 +517,11 @@ static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, con { SDL_RenderCommand *cmd; int retval = -1; - const int use_rendergeometry = (renderer->QueueFillRects == NULL); + const int use_rendergeometry = (!renderer->QueueFillRects); cmd = PrepQueueCmdDraw(renderer, (use_rendergeometry ? SDL_RENDERCMD_GEOMETRY : SDL_RENDERCMD_FILL_RECTS), NULL); - if (cmd != NULL) { + if (cmd) { if (use_rendergeometry) { SDL_bool isstack1; SDL_bool isstack2; @@ -591,7 +591,7 @@ static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_ { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopy(renderer, cmd, texture, srcrect, dstrect); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -606,7 +606,7 @@ static int QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY_EX, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopyEx(renderer, cmd, texture, srcquad, dstrect, angle, center, flip, scale_x, scale_y); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -626,7 +626,7 @@ static int QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, SDL_RenderCommand *cmd; int retval = -1; cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_GEOMETRY, texture); - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueGeometry(renderer, cmd, texture, xy, xy_stride, color, color_stride, uv, uv_stride, @@ -643,7 +643,7 @@ static int UpdateLogicalSize(SDL_Renderer *renderer, SDL_bool flush_viewport_cmd int SDL_GetNumRenderDrivers(void) { -#if !SDL_RENDER_DISABLED +#ifndef SDL_RENDER_DISABLED return SDL_arraysize(render_drivers); #else return 0; @@ -652,7 +652,7 @@ int SDL_GetNumRenderDrivers(void) int SDL_GetRenderDriverInfo(int index, SDL_RendererInfo *info) { -#if !SDL_RENDER_DISABLED +#ifndef SDL_RENDER_DISABLED if (index < 0 || index >= SDL_GetNumRenderDrivers()) { return SDL_SetError("index must be in the range of 0 - %d", SDL_GetNumRenderDrivers() - 1); @@ -799,6 +799,20 @@ static int SDLCALL SDL_RendererEventWatch(void *userdata, SDL_Event *event) event->button.y = (int)(event->button.y / (scale.y * renderer->dpi_scale.y)); } } + } else if (event->type == SDL_MOUSEWHEEL) { + SDL_Window *window = SDL_GetWindowFromID(event->wheel.windowID); + if (window == renderer->window) { + int logical_w, logical_h; + SDL_DRect viewport; + SDL_FPoint scale; + GetWindowViewportValues(renderer, &logical_w, &logical_h, &viewport, &scale); + if (logical_w) { + event->wheel.mouseX -= (int)(viewport.x * renderer->dpi_scale.x); + event->wheel.mouseY -= (int)(viewport.y * renderer->dpi_scale.y); + event->wheel.mouseX = (int)(event->wheel.mouseX / (scale.x * renderer->dpi_scale.x)); + event->wheel.mouseY = (int)(event->wheel.mouseY / (scale.y * renderer->dpi_scale.y)); + } + } } else if (event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP || event->type == SDL_FINGERMOTION) { @@ -878,7 +892,7 @@ int SDL_CreateWindowAndRenderer(int width, int height, Uint32 window_flags, return 0; } -#if !SDL_RENDER_DISABLED +#ifndef SDL_RENDER_DISABLED static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) { /* all of these functions are required to be implemented, even as no-ops, so we don't @@ -892,7 +906,7 @@ static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) SDL_assert(renderer->RunCommandQueue != NULL); } -static SDL_RenderLineMethod SDL_GetRenderLineMethod() +static SDL_RenderLineMethod SDL_GetRenderLineMethod(void) { const char *hint = SDL_GetHint(SDL_HINT_RENDER_LINE_METHOD); @@ -935,7 +949,7 @@ static void SDL_CalculateSimulatedVSyncInterval(SDL_Renderer *renderer, SDL_Wind SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) { -#if !SDL_RENDER_DISABLED +#ifndef SDL_RENDER_DISABLED SDL_Renderer *renderer = NULL; int n = SDL_GetNumRenderDrivers(); SDL_bool batching = SDL_TRUE; @@ -945,7 +959,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) Android_ActivityMutex_Lock_Running(); #endif - if (window == NULL) { + if (!window) { SDL_InvalidParamError("window"); goto error; } @@ -986,7 +1000,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } - if (renderer == NULL) { + if (!renderer) { for (index = 0; index < n; ++index) { const SDL_RenderDriver *driver = render_drivers[index]; @@ -1000,7 +1014,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } } - if (renderer == NULL) { + if (!renderer) { SDL_SetError("Couldn't find matching render driver"); goto error; } @@ -1013,7 +1027,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) /* Create a new renderer instance */ renderer = render_drivers[index]->CreateRenderer(window, flags); batching = SDL_FALSE; - if (renderer == NULL) { + if (!renderer) { goto error; } } @@ -1108,7 +1122,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) SDL_Renderer *SDL_CreateSoftwareRenderer(SDL_Surface *surface) { -#if !SDL_RENDER_DISABLED && SDL_VIDEO_RENDER_SW +#if SDL_VIDEO_RENDER_SW SDL_Renderer *renderer; renderer = SW_CreateRendererForSurface(surface); @@ -1228,7 +1242,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void) { const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); - if (hint == NULL || SDL_strcasecmp(hint, "nearest") == 0) { + if (!hint || SDL_strcasecmp(hint, "nearest") == 0) { return SDL_ScaleModeNearest; } else if (SDL_strcasecmp(hint, "linear") == 0) { return SDL_ScaleModeLinear; @@ -1269,7 +1283,7 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access return NULL; } texture = (SDL_Texture *)SDL_calloc(1, sizeof(*texture)); - if (texture == NULL) { + if (!texture) { SDL_OutOfMemory(); return NULL; } @@ -1360,7 +1374,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s CHECK_RENDERER_MAGIC(renderer, NULL); - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface"); return NULL; } @@ -1424,7 +1438,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, surface->w, surface->h); - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1468,7 +1482,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); - if (dst_fmt == NULL) { + if (!dst_fmt) { SDL_DestroyTexture(texture); return NULL; } @@ -1687,7 +1701,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1727,7 +1741,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_ConvertPixels(rect->w, rect->h, @@ -1747,7 +1761,7 @@ int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (pixels == NULL) { + if (!pixels) { return SDL_InvalidParamError("pixels"); } if (!pitch) { @@ -1821,7 +1835,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1871,7 +1885,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1896,19 +1910,19 @@ int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (Uplane == NULL) { + if (!Uplane) { return SDL_InvalidParamError("Uplane"); } if (!Upitch) { return SDL_InvalidParamError("Upitch"); } - if (Vplane == NULL) { + if (!Vplane) { return SDL_InvalidParamError("Vplane"); } if (!Vpitch) { @@ -1962,13 +1976,13 @@ int SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (UVplane == NULL) { + if (!UVplane) { return SDL_InvalidParamError("UVplane"); } if (!UVpitch) { @@ -2042,7 +2056,7 @@ int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, return SDL_SetError("SDL_LockTexture(): texture must be streaming"); } - if (rect == NULL) { + if (!rect) { full_rect.x = 0; full_rect.y = 0; full_rect.w = texture->w; @@ -2078,7 +2092,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, int pitch = 0; /* fix static analysis */ int ret; - if (texture == NULL || surface == NULL) { + if (!texture || !surface) { return -1; } @@ -2096,7 +2110,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, } texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format); - if (texture->locked_surface == NULL) { + if (!texture->locked_surface) { SDL_UnlockTexture(texture); return -1; } @@ -2172,7 +2186,7 @@ void SDL_UnlockTexture(SDL_Texture *texture) SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer) { - if (renderer == NULL || !renderer->SetRenderTarget) { + if (!renderer || !renderer->SetRenderTarget) { return SDL_FALSE; } return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; @@ -2481,7 +2495,7 @@ int SDL_RenderSetClipRect(SDL_Renderer *renderer, const SDL_Rect *rect) int retval; CHECK_RENDERER_MAGIC(renderer, -1) - if (rect && rect->w > 0 && rect->h > 0) { + if (rect && rect->w >= 0 && rect->h >= 0) { renderer->clipping_enabled = SDL_TRUE; renderer->clip_rect.x = (double)rect->x * renderer->scale.x; renderer->clip_rect.y = (double)rect->y * renderer->scale.y; @@ -2660,7 +2674,7 @@ static int RenderDrawPointsWithRects(SDL_Renderer *renderer, } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2688,7 +2702,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPoints(): points"); } if (count < 1) { @@ -2706,7 +2720,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, retval = RenderDrawPointsWithRects(renderer, points, count); } else { fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -2734,7 +2748,7 @@ static int RenderDrawPointsWithRectsF(SDL_Renderer *renderer, } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2759,7 +2773,7 @@ int SDL_RenderDrawPointsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPointsF(): points"); } if (count < 1) { @@ -2810,6 +2824,18 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x int retval; SDL_bool isstack; SDL_FPoint *points; + SDL_Rect clip_rect; + + /* the backend might clip this further to the clipping rect, but we + just want a basic safety against generating millions of points for + massive lines. */ + clip_rect.x = 0; + clip_rect.y = 0; + clip_rect.w = (int) renderer->viewport.w; + clip_rect.h = (int) renderer->viewport.h; + if (!SDL_IntersectRectAndLine(&clip_rect, &x1, &y1, &x2, &y2)) { + return 0; + } deltax = SDL_abs(x2 - x1); deltay = SDL_abs(y2 - y1); @@ -2851,7 +2877,7 @@ static int RenderDrawLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x } points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack); - if (points == NULL) { + if (!points) { return SDL_OutOfMemory(); } for (i = 0; i < numpixels; ++i) { @@ -2894,7 +2920,7 @@ static int RenderDrawLinesWithRectsF(SDL_Renderer *renderer, SDL_bool draw_last = SDL_FALSE; frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2964,7 +2990,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLines(): points"); } if (count < 2) { @@ -2979,7 +3005,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, #endif fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } @@ -3002,7 +3028,7 @@ int SDL_RenderDrawLinesF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLinesF(): points"); } if (count < 2) { @@ -3171,7 +3197,7 @@ int SDL_RenderDrawRectF(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then outline the whole surface */ - if (rect == NULL) { + if (!rect) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3196,7 +3222,7 @@ int SDL_RenderDrawRects(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRects(): rects"); } if (count < 1) { @@ -3225,7 +3251,7 @@ int SDL_RenderDrawRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRectsF(): rects"); } if (count < 1) { @@ -3272,7 +3298,7 @@ int SDL_RenderFillRectF(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then outline the whole surface */ - if (rect == NULL) { + if (!rect) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3289,7 +3315,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRects(): rects"); } if (count < 1) { @@ -3304,7 +3330,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -3331,7 +3357,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRectsF(): rects"); } if (count < 1) { @@ -3346,7 +3372,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -3400,7 +3426,7 @@ int SDL_RenderCopyF(SDL_Renderer *renderer, SDL_Texture *texture, } #endif - use_rendergeometry = (renderer->QueueCopy == NULL); + use_rendergeometry = (!renderer->QueueCopy); real_srcrect.x = 0; real_srcrect.y = 0; @@ -3540,7 +3566,7 @@ int SDL_RenderCopyExF(SDL_Renderer *renderer, SDL_Texture *texture, } #endif - use_rendergeometry = (renderer->QueueCopyEx == NULL); + use_rendergeometry = (!renderer->QueueCopyEx); real_srcrect.x = 0; real_srcrect.y = 0; @@ -4071,15 +4097,15 @@ int SDL_RenderGeometryRaw(SDL_Renderer *renderer, } } - if (xy == NULL) { + if (!xy) { return SDL_InvalidParamError("xy"); } - if (color == NULL) { + if (!color) { return SDL_InvalidParamError("color"); } - if (texture && uv == NULL) { + if (texture && !uv) { return SDL_InvalidParamError("uv"); } @@ -4171,7 +4197,7 @@ int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, FlushRenderCommands(renderer); /* we need to render before we read the results. */ if (!format) { - if (renderer->target == NULL) { + if (!renderer->target) { format = SDL_GetWindowPixelFormat(renderer->window); } else { format = renderer->target->format; @@ -4300,7 +4326,7 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer) SDL_DelEventWatch(SDL_RendererEventWatch, renderer); - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; cmd = renderer->render_commands; } else { @@ -4311,7 +4337,7 @@ void SDL_DestroyRenderer(SDL_Renderer *renderer) renderer->render_commands_tail = NULL; renderer->render_commands = NULL; - while (cmd != NULL) { + while (cmd) { SDL_RenderCommand *next = cmd->next; SDL_free(cmd); cmd = next; diff --git a/vs/sdl2/src/render/SDL_sysrender.h b/vs/sdl2/src/render/SDL_sysrender.h index 36e9555bb1..a4eef4d7d9 100644 --- a/vs/sdl2/src/render/SDL_sysrender.h +++ b/vs/sdl2/src/render/SDL_sysrender.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/SDL_yuv_sw.c b/vs/sdl2/src/render/SDL_yuv_sw.c index c4385e2886..903279b3db 100644 --- a/vs/sdl2/src/render/SDL_yuv_sw.c +++ b/vs/sdl2/src/render/SDL_yuv_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) } swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata)); - if (swdata == NULL) { + if (!swdata) { SDL_OutOfMemory(); return NULL; } diff --git a/vs/sdl2/src/render/SDL_yuv_sw_c.h b/vs/sdl2/src/render/SDL_yuv_sw_c.h index 8b7b0ba003..c123c51691 100644 --- a/vs/sdl2/src/render/SDL_yuv_sw_c.h +++ b/vs/sdl2/src/render/SDL_yuv_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/direct3d/SDL_render_d3d.c b/vs/sdl2/src/render/direct3d/SDL_render_d3d.c index 5470a7d401..f117bd664d 100644 --- a/vs/sdl2/src/render/direct3d/SDL_render_d3d.c +++ b/vs/sdl2/src/render/direct3d/SDL_render_d3d.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_render.h" #include "SDL_system.h" -#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D #include "../../core/windows/SDL_windows.h" @@ -443,7 +443,7 @@ static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *te { HRESULT result; - if (texture->staging == NULL) { + if (!texture->staging) { result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0, texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); if (FAILED(result)) { @@ -535,7 +535,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) DWORD usage; texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata)); - if (texturedata == NULL) { + if (!texturedata) { return SDL_OutOfMemory(); } texturedata->scaleMode = (texture->scaleMode == SDL_ScaleModeNearest) ? D3DTEXF_POINT : D3DTEXF_LINEAR; @@ -573,7 +573,7 @@ static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return 0; } @@ -600,7 +600,7 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -636,7 +636,7 @@ static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -660,7 +660,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; IDirect3DDevice9 *device = data->device; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -710,7 +710,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } #if SDL_HAVE_YUV @@ -738,7 +738,7 @@ static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } @@ -754,18 +754,18 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text IDirect3DDevice9 *device = data->device; /* Release the previous render target if it wasn't the default one */ - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget); return 0; } texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -820,7 +820,7 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -845,7 +845,7 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL int count = indices ? num_indices : num_vertices; Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -941,7 +941,7 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIREC SDL_assert(*shader == NULL); - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -993,11 +993,11 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) LPDIRECT3DPIXELSHADER9 shader = NULL; /* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */ - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetTexture(data->device, 0, NULL); } #if SDL_HAVE_YUV - if ((newtexturedata == NULL || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { + if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { IDirect3DDevice9_SetTexture(data->device, 1, NULL); IDirect3DDevice9_SetTexture(data->device, 2, NULL); } @@ -1170,6 +1170,7 @@ static int D3D_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = SDL_TRUE; } break; } @@ -1391,7 +1392,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) #endif } - if (data == NULL) { + if (!data) { return; } @@ -1417,7 +1418,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1468,7 +1469,7 @@ static int D3D_Reset(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1562,13 +1563,13 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -1731,7 +1732,7 @@ SDL_RenderDriver D3D_RenderDriver = { 0, 0 } }; -#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D */ #if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ @@ -1739,7 +1740,7 @@ IDirect3DDevice9 *SDL_RenderGetD3D9Device(SDL_Renderer *renderer) { IDirect3DDevice9 *device = NULL; -#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ @@ -1752,7 +1753,7 @@ IDirect3DDevice9 *SDL_RenderGetD3D9Device(SDL_Renderer *renderer) if (device) { IDirect3DDevice9_AddRef(device); } -#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D */ return device; } diff --git a/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.c b/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.c index e8fd6ae738..2f55d80ca7 100644 --- a/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.c +++ b/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_render.h" #include "SDL_system.h" -#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D #include "../../core/windows/SDL_windows.h" @@ -268,6 +268,6 @@ HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, return IDirect3DDevice9_CreatePixelShader(d3dDevice, D3D9_shaders[shader], pixelShader); } -#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.h b/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.h index 03b5634f6e..89cd1ea604 100644 --- a/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.h +++ b/vs/sdl2/src/render/direct3d/SDL_shaders_d3d.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/direct3d11/SDL_render_d3d11.c b/vs/sdl2/src/render/direct3d11/SDL_render_d3d11.c index 2d8ee3c0a0..8249256faf 100644 --- a/vs/sdl2/src/render/direct3d11/SDL_render_d3d11.c +++ b/vs/sdl2/src/render/direct3d11/SDL_render_d3d11.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_render.h" #include "SDL_system.h" -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 #define COBJMACROS #include "../../core/windows/SDL_windows.h" @@ -385,7 +385,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen } blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes)); - if (blendModes == NULL) { + if (!blendModes) { SAFE_RELEASE(blendState); SDL_OutOfMemory(); return NULL; @@ -442,7 +442,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -740,7 +740,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; #ifdef __WINRT__ IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); - const BOOL usingXAML = (coreWindow == NULL); + const BOOL usingXAML = (!coreWindow); #else IUnknown *coreWindow = NULL; const BOOL usingXAML = FALSE; @@ -758,7 +758,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) swapChainDesc.SampleDesc.Quality = 0; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.BufferCount = 2; /* Use double-buffering to minimize latency. */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE swapChainDesc.Scaling = DXGI_SCALING_STRETCH; /* On phone, only stretch and aspect-ratio stretch scaling are allowed. */ swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; /* On phone, no swap effects are supported. */ /* TODO, WinRT: see if Win 8.x DXGI_SWAP_CHAIN_DESC1 settings are available on Windows Phone 8.1, and if there's any advantage to having them on */ @@ -907,7 +907,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) if (data->swapChain) { /* IDXGISwapChain::ResizeBuffers is not available on Windows Phone 8. */ -#if !defined(__WINRT__) || (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) +#if !defined(__WINRT__) || !SDL_WINAPI_FAMILY_PHONE /* If the swap chain already exists, resize it. */ result = IDXGISwapChain_ResizeBuffers(data->swapChain, 0, @@ -929,12 +929,12 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) #endif } else { result = D3D11_CreateSwapChain(renderer, w, h); - if (FAILED(result) || data->swapChain == NULL) { + if (FAILED(result) || !data->swapChain) { goto done; } } -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#if !SDL_WINAPI_FAMILY_PHONE /* Set the proper rotation for the swap chain. * * To note, the call for this, IDXGISwapChain1::SetRotation, is not necessary @@ -1071,7 +1071,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1232,7 +1232,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer, { D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; - if (data == NULL) { + if (!data) { return; } @@ -1339,7 +1339,7 @@ static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1384,7 +1384,7 @@ static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1408,7 +1408,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1432,7 +1432,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -1511,7 +1511,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -1547,7 +1547,7 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1559,7 +1559,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { rendererData->currentOffscreenRenderTargetView = NULL; return 0; } @@ -1590,7 +1590,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1617,7 +1617,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1842,6 +1842,19 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c ID3D11BlendState *blendState = NULL; SDL_bool updateSubresource = SDL_FALSE; + if (numShaderResources > 0) { + shaderResource = shaderResources[0]; + } else { + shaderResource = NULL; + } + + /* Make sure the render target isn't bound to a shader */ + if (shaderResource != rendererData->currentShaderResource) { + ID3D11ShaderResourceView *pNullResource = NULL; + ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, 1, &pNullResource); + rendererData->currentShaderResource = NULL; + } + if (renderTargetView != rendererData->currentRenderTargetView) { ID3D11DeviceContext_OMSetRenderTargets(rendererData->d3dContext, 1, @@ -1889,9 +1902,9 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c break; } } - if (blendState == NULL) { + if (!blendState) { blendState = D3D11_CreateBlendState(renderer, blendMode); - if (blendState == NULL) { + if (!blendState) { return -1; } } @@ -1905,11 +1918,6 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c ID3D11DeviceContext_PSSetShader(rendererData->d3dContext, shader, NULL, 0); rendererData->currentShader = shader; } - if (numShaderResources > 0) { - shaderResource = shaderResources[0]; - } else { - shaderResource = NULL; - } if (shaderResource != rendererData->currentShaderResource) { ID3D11DeviceContext_PSSetShaderResources(rendererData->d3dContext, 0, numShaderResources, shaderResources); rendererData->currentShaderResource = shaderResource; @@ -2039,6 +2047,7 @@ static int D3D11_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); rendererData->viewportDirty = SDL_TRUE; + rendererData->cliprectDirty = SDL_TRUE; } break; } @@ -2144,13 +2153,13 @@ static int D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, D3D11_MAPPED_SUBRESOURCE textureMemory; renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); - if (renderTargetView == NULL) { + if (!renderTargetView) { SDL_SetError("%s, ID3D11DeviceContext::OMGetRenderTargets failed", __FUNCTION__); goto done; } ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer); - if (backBuffer == NULL) { + if (!backBuffer) { SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__); goto done; } @@ -2237,7 +2246,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer) SDL_zero(parameters); -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE syncInterval = 1; presentFlags = 0; result = IDXGISwapChain_Present(data->swapChain, syncInterval, presentFlags); @@ -2285,7 +2294,7 @@ static int D3D11_RenderPresent(SDL_Renderer *renderer) return 0; } -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE /* no-op. */ #else static int D3D11_SetVSync(SDL_Renderer *renderer, const int vsync) @@ -2305,13 +2314,13 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags) D3D11_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -2348,7 +2357,7 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE); renderer->driverdata = data; -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE /* VSync is required in Windows Phone, at least for Win Phone 8.0 and 8.1. * Failure to use it seems to either result in: * @@ -2407,7 +2416,7 @@ SDL_RenderDriver D3D11_RenderDriver = { } }; -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D11 */ #if defined(__WIN32__) || defined(__WINGDK__) /* This function needs to always exist on Windows, for the Dynamic API. */ @@ -2415,7 +2424,7 @@ ID3D11Device *SDL_RenderGetD3D11Device(SDL_Renderer *renderer) { ID3D11Device *device = NULL; -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ @@ -2428,7 +2437,7 @@ ID3D11Device *SDL_RenderGetD3D11Device(SDL_Renderer *renderer) if (device) { ID3D11Device_AddRef(device); } -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D11 */ return device; } diff --git a/vs/sdl2/src/render/direct3d11/SDL_render_winrt.cpp b/vs/sdl2/src/render/direct3d11/SDL_render_winrt.cpp index 3f24d0f212..0ed7addbd2 100644 --- a/vs/sdl2/src/render/direct3d11/SDL_render_winrt.cpp +++ b/vs/sdl2/src/render/direct3d11/SDL_render_winrt.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 #include "SDL_syswm.h" #include "../../video/winrt/SDL_winrtvideo_cpp.h" @@ -46,7 +46,7 @@ extern "C" void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) { SDL_Window *sdlWindow = renderer->window; - if (renderer->window == NULL) { + if (!renderer->window) { return NULL; } @@ -83,7 +83,7 @@ D3D11_GetCurrentRotation() switch (currentOrientation) { -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE /* Windows Phone rotations */ case DisplayOrientations::Landscape: return DXGI_MODE_ROTATION_ROTATE90; @@ -103,12 +103,12 @@ D3D11_GetCurrentRotation() return DXGI_MODE_ROTATION_ROTATE180; case DisplayOrientations::PortraitFlipped: return DXGI_MODE_ROTATION_ROTATE90; -#endif /* WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP */ +#endif /* SDL_WINAPI_FAMILY_PHONE */ } return DXGI_MODE_ROTATION_IDENTITY; } -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D11 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d11/SDL_render_winrt.h b/vs/sdl2/src/render/direct3d11/SDL_render_winrt.h index efc8c90aed..dd9a17631c 100644 --- a/vs/sdl2/src/render/direct3d11/SDL_render_winrt.h +++ b/vs/sdl2/src/render/direct3d11/SDL_render_winrt.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 #include "SDL_render.h" @@ -35,6 +35,6 @@ DXGI_MODE_ROTATION D3D11_GetCurrentRotation(); } #endif -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D11 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.c b/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.c index e8c0a48d07..5f3a9a41f5 100644 --- a/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.c +++ b/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D11 #include "SDL_stdinc.h" @@ -58,7 +58,7 @@ hexdump -v -e '6/4 "0x%08.8x, " "\n"' */ -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE #define D3D11_USE_SHADER_MODEL_4_0_level_9_3 #else #define D3D11_USE_SHADER_MODEL_4_0_level_9_1 @@ -1949,6 +1949,6 @@ int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D1 return 0; } -#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D11 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.h b/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.h index 9c35bad6ed..010cd93b3c 100644 --- a/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.h +++ b/vs/sdl2/src/render/direct3d11/SDL_shaders_d3d11.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12.c b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12.c index 5ad8e26f2d..8a607bfbe0 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12.c +++ b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_render.h" #include "SDL_system.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D12 #define SDL_D3D12_NUM_BUFFERS 2 #define SDL_D3D12_NUM_VERTEX_BUFFERS 256 @@ -48,6 +48,7 @@ #include #include #include +#include #endif #include "SDL_shaders_d3d12.h" @@ -58,6 +59,11 @@ #define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str #endif +/* DXGI_PRESENT flags are removed on Xbox */ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) +#define DXGI_PRESENT_ALLOW_TEARING 0 +#endif + #ifdef __cplusplus #define SAFE_RELEASE(X) \ if (X) { \ @@ -78,6 +84,54 @@ #define D3D_GUID(X) &(X) #endif +/* + * Older MS Windows SDK headers declare some d3d12 functions with the wrong function prototype. + * - ID3D12Heap::GetDesc + * - ID3D12Resource::GetDesc + * - ID3D12DescriptorHeap::GetDesc + * (and 9 more)+ + * This is fixed in SDKs since WDK_NTDDI_VERSION >= NTDDI_WIN10_FE (0x0A00000A) + */ + +#if !(defined(__MINGW32__) || defined(__XBOXONE__) || defined(__XBOXSERIES__)) \ + && (WDK_NTDDI_VERSION < 0x0A00000A) + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_CPU_DESCRIPTOR_HANDLE * Handle) = \ + (void*)(THIS)->lpVtbl->GetCPUDescriptorHandleForHeapStart; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12DescriptorHeap * This, D3D12_GPU_DESCRIPTOR_HANDLE * Handle) = \ + (void*)(THIS)->lpVtbl->GetGPUDescriptorHandleForHeapStart; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) do { \ + void (STDMETHODCALLTYPE * func)(ID3D12Resource * This, D3D12_RESOURCE_DESC * Desc) = \ + (void*)(THIS)->lpVtbl->GetDesc; \ + func((THIS), ##__VA_ARGS__); \ + } while (0) + +#else + +/* + * MinGW has correct function prototypes in the vtables, but defines wrong functions + * Xbox just needs these macros defined as used below (because CINTERFACE doesn't exist) + */ + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(THIS, ...) \ + D3D_CALL_RET(THIS, GetCPUDescriptorHandleForHeapStart, ##__VA_ARGS__); + +#define D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(THIS, ...) \ + D3D_CALL_RET(THIS, GetGPUDescriptorHandleForHeapStart, ##__VA_ARGS__); + +#define D3D_CALL_RET_ID3D12Resource_GetDesc(THIS, ...) \ + D3D_CALL_RET(THIS, GetDesc, ##__VA_ARGS__); + +#endif + /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus extern "C" { @@ -393,10 +447,10 @@ static D3D12_GPU_DESCRIPTOR_HANDLE D3D12_CPUtoGPUHandle(ID3D12DescriptorHeap *he SIZE_T offset; /* Calculate the correct offset into the heap */ - D3D_CALL_RET(heap, GetCPUDescriptorHandleForHeapStart, &CPUHeapStart); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(heap, &CPUHeapStart); offset = CPUHandle.ptr - CPUHeapStart.ptr; - D3D_CALL_RET(heap, GetGPUDescriptorHandleForHeapStart, &GPUHandle); + D3D_CALL_RET_ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(heap, &GPUHandle); GPUHandle.ptr += offset; return GPUHandle; @@ -427,7 +481,7 @@ static D3D12_CPU_DESCRIPTOR_HANDLE D3D12_GetCurrentRenderTargetView(SDL_Renderer } SDL_zero(rtvDescriptor); - D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor); rtvDescriptor.ptr += data->currentBackBufferIndex * data->rtvDescriptorSize; return rtvDescriptor; } @@ -633,7 +687,7 @@ static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer, } pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates)); - if (pipelineStates == NULL) { + if (!pipelineStates) { SAFE_RELEASE(pipelineState); SDL_OutOfMemory(); return NULL; @@ -748,7 +802,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } } #endif - if (CreateEventExFunc == NULL) { + if (!CreateEventExFunc) { result = E_FAIL; goto done; } @@ -761,7 +815,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -805,7 +859,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) /* If the debug hint is set, also create the DXGI factory in debug mode */ DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); - if (DXGIGetDebugInterfaceFunc == NULL) { + if (!DXGIGetDebugInterfaceFunc) { result = E_FAIL; goto done; } @@ -1047,7 +1101,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) samplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS; samplerDesc.MinLOD = 0.0f; samplerDesc.MaxLOD = D3D12_FLOAT32_MAX; - D3D_CALL_RET(data->samplerDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &data->nearestPixelSampler); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->samplerDescriptorHeap, &data->nearestPixelSampler); D3D_CALL(data->d3dDevice, CreateSampler, &samplerDesc, data->nearestPixelSampler); samplerDesc.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR; @@ -1141,7 +1195,7 @@ static int D3D12_GetViewportAlignedD3DRect(SDL_Renderer *renderer, const SDL_Rec static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) { D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; - IDXGISwapChain1* swapChain; + IDXGISwapChain1* swapChain = NULL; HRESULT result = S_OK; SDL_SysWMinfo windowinfo; @@ -1166,7 +1220,13 @@ static HRESULT D3D12_CreateSwapChain(SDL_Renderer *renderer, int w, int h) DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING; /* To support presenting with allow tearing on */ SDL_VERSION(&windowinfo.version); - SDL_GetWindowWMInfo(renderer->window, &windowinfo); + if (!SDL_GetWindowWMInfo(renderer->window, &windowinfo) || + windowinfo.subsystem != SDL_SYSWM_WINDOWS) + { + SDL_SetError("Couldn't get window handle"); + result = E_FAIL; + goto done; + } result = D3D_CALL(data->dxgiFactory, CreateSwapChainForHwnd, (IUnknown *)data->commandQueue, @@ -1330,7 +1390,7 @@ static HRESULT D3D12_CreateWindowSizeDependentResources(SDL_Renderer *renderer) rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; SDL_zero(rtvDescriptor); - D3D_CALL_RET(data->rtvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &rtvDescriptor); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(data->rtvDescriptorHeap, &rtvDescriptor); rtvDescriptor.ptr += i * data->rtvDescriptorSize; D3D_CALL(data->d3dDevice, CreateRenderTargetView, data->renderTargets[i], &rtvDesc, rtvDescriptor); } @@ -1432,7 +1492,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1544,7 +1604,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) resourceViewDesc.Texture2D.MipLevels = textureDesc.MipLevels; textureData->mainSRVIndex = D3D12_GetAvailableSRVIndex(renderer); - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceView); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceView); textureData->mainTextureResourceView.ptr += textureData->mainSRVIndex * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1553,7 +1613,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) textureData->mainTextureResourceView); #if SDL_HAVE_YUV if (textureData->yuv) { - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewU); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewU); textureData->mainSRVIndexU = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewU.ptr += textureData->mainSRVIndexU * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1561,7 +1621,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) &resourceViewDesc, textureData->mainTextureResourceViewU); - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewV); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewV); textureData->mainSRVIndexV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewV.ptr += textureData->mainSRVIndexV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1575,7 +1635,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM; - D3D_CALL_RET(rendererData->srvDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureResourceViewNV); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->srvDescriptorHeap, &textureData->mainTextureResourceViewNV); textureData->mainSRVIndexNV = D3D12_GetAvailableSRVIndex(renderer); textureData->mainTextureResourceViewNV.ptr += textureData->mainSRVIndexNV * rendererData->srvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateShaderResourceView, @@ -1592,7 +1652,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderTargetViewDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D; renderTargetViewDesc.Texture2D.MipSlice = 0; - D3D_CALL_RET(rendererData->textureRTVDescriptorHeap, GetCPUDescriptorHandleForHeapStart, &textureData->mainTextureRenderTargetView); + D3D_CALL_RET_ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(rendererData->textureRTVDescriptorHeap, &textureData->mainTextureRenderTargetView); textureData->mainTextureRenderTargetView.ptr += textureData->mainSRVIndex * rendererData->rtvDescriptorSize; D3D_CALL(rendererData->d3dDevice, CreateRenderTargetView, @@ -1610,7 +1670,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1657,7 +1717,7 @@ static int D3D12_UpdateTextureInternal(D3D12_RenderData *rendererData, ID3D12Res /* Create an upload buffer, which will be used to write to the main texture. */ SDL_zero(textureDesc); - D3D_CALL_RET(texture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(texture, &textureDesc); textureDesc.Width = w; textureDesc.Height = h; @@ -1788,7 +1848,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1833,7 +1893,7 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1857,7 +1917,7 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1886,7 +1946,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, BYTE *textureMemory; int bpp; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -1913,7 +1973,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, /* Create an upload buffer, which will be used to write to the main texture. */ SDL_zero(textureDesc); - D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc); textureDesc.Width = rect->w; textureDesc.Height = rect->h; @@ -2005,7 +2065,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_TEXTURE_COPY_LOCATION dstLocation; int bpp; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -2022,7 +2082,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_CALL(textureData->stagingBuffer, Unmap, 0, NULL); SDL_zero(textureDesc); - D3D_CALL_RET(textureData->mainTexture, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(textureData->mainTexture, &textureDesc); textureDesc.Width = textureData->lockedRect.w; textureDesc.Height = textureData->lockedRect.h; @@ -2076,7 +2136,7 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -2088,7 +2148,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { if (rendererData->textureRenderTarget) { D3D12_TransitionResource(rendererData, rendererData->textureRenderTarget->mainTexture, @@ -2131,7 +2191,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -2158,7 +2218,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -2602,6 +2662,7 @@ static int D3D12_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); rendererData->viewportDirty = SDL_TRUE; + rendererData->cliprectDirty = SDL_TRUE; } break; } @@ -2732,7 +2793,7 @@ static int D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, /* Create a staging texture to copy the screen's data to: */ SDL_zero(textureDesc); - D3D_CALL_RET(backBuffer, GetDesc, &textureDesc); + D3D_CALL_RET_ID3D12Resource_GetDesc(backBuffer, &textureDesc); textureDesc.Width = rect->w; textureDesc.Height = rect->h; @@ -2837,8 +2898,8 @@ static int D3D12_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, NULL, (void **)&textureMemory); if (FAILED(result)) { - SAFE_RELEASE(readbackBuffer); - return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result); + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D12Resource::Map [map staging texture]"), result); + goto done; } /* Copy the data into the desired buffer, converting pixels to the @@ -2959,13 +3020,13 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags) D3D12_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -3049,7 +3110,7 @@ SDL_RenderDriver D3D12_RenderDriver = { } #endif -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D12 */ #if defined(__WIN32__) || defined(__GDK__) #ifdef __cplusplus @@ -3061,7 +3122,7 @@ extern "C" { ID3D12Device *device = NULL; -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D12 D3D12_RenderData *data = (D3D12_RenderData *)renderer->driverdata; /* Make sure that this is a D3D renderer */ @@ -3074,7 +3135,7 @@ extern "C" if (device) { D3D_CALL(device, AddRef); } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_D3D12 */ return device; } diff --git a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.cpp b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.cpp index 3775c94486..7b598c016a 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.cpp +++ b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +20,155 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && (defined(__XBOXONE__) || defined(__XBOXSERIES__)) +#if SDL_VIDEO_RENDER_D3D12 && (defined(__XBOXONE__) || defined(__XBOXSERIES__)) #include "SDL_render_d3d12_xbox.h" +#include "../../core/windows/SDL_windows.h" +#include + +#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 + +static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } }; +static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } }; +static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } }; + +extern "C" HRESULT +D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug) +{ + HRESULT result; + D3D12XBOX_CREATE_DEVICE_PARAMETERS params; + IDXGIDevice1 *dxgiDevice; + IDXGIAdapter *dxgiAdapter; + IDXGIOutput *dxgiOutput; + SDL_zero(params); + + params.Version = D3D12_SDK_VERSION; + params.ProcessDebugFlags = createDebug ? D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED : D3D12XBOX_PROCESS_DEBUG_FLAG_NONE; + params.GraphicsCommandQueueRingSizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES; + params.GraphicsScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES; + params.ComputeScratchMemorySizeBytes = D3D12XBOX_DEFAULT_SIZE_BYTES; + + result = D3D12XboxCreateDevice(NULL, ¶ms, SDL_IID_ID3D12Device1, (void **) device); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] D3D12XboxCreateDevice"), result); + goto done; + } + + result = (*device)->QueryInterface(SDL_IID_IDXGIDevice1, (void **) &dxgiDevice); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ID3D12Device to IDXGIDevice1"), result); + goto done; + } + + result = dxgiDevice->GetAdapter(&dxgiAdapter); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiDevice->GetAdapter"), result); + goto done; + } + + result = dxgiAdapter->EnumOutputs(0, &dxgiOutput); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiAdapter->EnumOutputs"), result); + goto done; + } + + /* Set frame interval */ + result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result); + goto done; + } + + result = (*device)->ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, NULL, D3D12XBOX_SCHEDULE_FRAME_EVENT_FLAG_NONE); + if (FAILED(result)) { + WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ScheduleFrameEventX"), result); + goto done; + } + +done: + return result; +} + +extern "C" HRESULT +D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource) +{ + + D3D12_HEAP_PROPERTIES heapProps; + D3D12_RESOURCE_DESC resourceDesc; + + SDL_zero(heapProps); + heapProps.Type = D3D12_HEAP_TYPE_DEFAULT; + heapProps.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN; + heapProps.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN; + heapProps.CreationNodeMask = 1; + heapProps.VisibleNodeMask = 1; + + SDL_zero(resourceDesc); + resourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + resourceDesc.Alignment = 0; + resourceDesc.Width = width; + resourceDesc.Height = height; + resourceDesc.DepthOrArraySize = 1; + resourceDesc.MipLevels = 1; + resourceDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; + resourceDesc.SampleDesc.Count = 1; + resourceDesc.SampleDesc.Quality = 0; + resourceDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN; + resourceDesc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + + return device->CreateCommittedResource(&heapProps, + D3D12_HEAP_FLAG_ALLOW_DISPLAY, + &resourceDesc, + D3D12_RESOURCE_STATE_PRESENT, + NULL, + SDL_IID_ID3D12Resource, + resource + ); +} + +extern "C" HRESULT +D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken) +{ + *outToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL; + return device->WaitFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, INFINITE, NULL, D3D12XBOX_WAIT_FRAME_EVENT_FLAG_NONE, outToken); +} + +extern "C" HRESULT +D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget) +{ + D3D12XBOX_PRESENT_PLANE_PARAMETERS planeParameters; + SDL_zero(planeParameters); + planeParameters.Token = token; + planeParameters.ResourceCount = 1; + planeParameters.ppResources = &renderTarget; + return commandQueue->PresentX(1, &planeParameters, NULL); +} + +extern "C" void +D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height) +{ + switch (XSystemGetDeviceType()) { + case XSystemDeviceType::XboxScarlettLockhart: + *width = 2560; + *height = 1440; + break; + + case XSystemDeviceType::XboxOneX: + case XSystemDeviceType::XboxScarlettAnaconda: + case XSystemDeviceType::XboxOneXDevkit: + case XSystemDeviceType::XboxScarlettDevkit: + *width = 3840; + *height = 2160; + break; + + default: + *width = 1920; + *height = 1080; + break; + } +} -#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." #endif diff --git a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.h b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.h index fd725d9f42..6db955a422 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.h +++ b/vs/sdl2/src/render/direct3d12/SDL_render_d3d12_xbox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,4 +19,31 @@ 3. This notice may not be removed or altered from any source distribution. */ -#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." +#ifndef SDL_render_d3d12_xbox_h_ +#define SDL_render_d3d12_xbox_h_ + +#include "../../SDL_internal.h" + +#if defined(__XBOXONE__) +#include +#else /* __XBOXSERIES__ */ +#include +#endif + +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +extern HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, SDL_bool createDebug); +extern HRESULT D3D12_XBOX_CreateBackBufferTarget(ID3D12Device1 *device, int width, int height, void **resource); +extern HRESULT D3D12_XBOX_StartFrame(ID3D12Device1 *device, UINT64 *outToken); +extern HRESULT D3D12_XBOX_PresentFrame(ID3D12CommandQueue *commandQueue, UINT64 token, ID3D12Resource *renderTarget); +extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.c b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.c index 3b1327291c..29862d4640 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.c +++ b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if SDL_VIDEO_RENDER_D3D12 && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_stdinc.h" @@ -6934,6 +6934,6 @@ void D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECO outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; } -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ +#endif /* SDL_VIDEO_RENDER_D3D12 && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.h b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.h index f91179f69f..f0c528daf6 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.h +++ b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp index 6a86b2c29f..cc5c84f2f4 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp +++ b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxone.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +20,125 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) +#if SDL_VIDEO_RENDER_D3D12 && defined(__XBOXONE__) -#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." +#include -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXONE__) */ +#include "../../core/windows/SDL_windows.h" +#include + +#include "SDL_shaders_d3d12.h" + +#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str + +/* Shader blob headers are generated with a pre-build step using buildshaders.bat */ +#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_One.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_One.h" + +#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_One.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_One.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_One.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_One.h" + +#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_One.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_One.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_One.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_One.h" + +static struct +{ + const void *ps_shader_data; + SIZE_T ps_shader_size; + const void *vs_shader_data; + SIZE_T vs_shader_size; + D3D12_RootSignature root_sig; +} D3D12_shaders[NUM_SHADERS] = { + { D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors), + D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color), + ROOTSIG_COLOR }, + { D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures), + D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture), + ROOTSIG_TEXTURE }, +#if SDL_HAVE_YUV + { D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, +#endif +}; + +static struct +{ + const void *rs_shader_data; + SIZE_T rs_shader_size; +} D3D12_rootsigs[NUM_ROOTSIGS] = { + { D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) }, + { D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) }, +#if SDL_HAVE_YUV + { D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) }, + { D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) }, +#endif +}; + +extern "C" void +D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data; + outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size; +} + +extern "C" void +D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data; + outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size; +} + +extern "C" D3D12_RootSignature +D3D12_GetRootSignatureType(D3D12_Shader shader) +{ + return D3D12_shaders[shader].root_sig; +} + +extern "C" void +D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data; + outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; +} + +#endif /* SDL_VIDEO_RENDER_D3D12 && defined(__XBOXONE__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp index 28651173f9..f1e4063179 100644 --- a/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp +++ b/vs/sdl2/src/render/direct3d12/SDL_shaders_d3d12_xboxseries.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +20,125 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) +#if SDL_VIDEO_RENDER_D3D12 && defined(__XBOXSERIES__) -#error "This is a placeholder Xbox file, as the real one is under NDA. See README-gdk.md for more info." +#include -#endif /* SDL_VIDEO_RENDER_D3D12 && !SDL_RENDER_DISABLED && defined(__XBOXSERIES__) */ +#include "../../core/windows/SDL_windows.h" +#include + +#include "SDL_shaders_d3d12.h" + +#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str + +/* Shader blob headers are generated with a pre-build step using buildshaders.bat */ +#include "../VisualC-GDK/shaders/D3D12_PixelShader_Colors_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_Textures_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT601_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_BT709_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV12_JPEG_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT601_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_BT709_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_NV21_JPEG_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT601_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_BT709_Series.h" +#include "../VisualC-GDK/shaders/D3D12_PixelShader_YUV_JPEG_Series.h" + +#include "../VisualC-GDK/shaders/D3D12_VertexShader_Color_Series.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_Texture_Series.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_NV_Series.h" +#include "../VisualC-GDK/shaders/D3D12_VertexShader_YUV_Series.h" + +#include "../VisualC-GDK/shaders/D3D12_RootSig_Color_Series.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_Texture_Series.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_YUV_Series.h" +#include "../VisualC-GDK/shaders/D3D12_RootSig_NV_Series.h" + +static struct +{ + const void *ps_shader_data; + SIZE_T ps_shader_size; + const void *vs_shader_data; + SIZE_T vs_shader_size; + D3D12_RootSignature root_sig; +} D3D12_shaders[NUM_SHADERS] = { + { D3D12_PixelShader_Colors, sizeof(D3D12_PixelShader_Colors), + D3D12_VertexShader_Color, sizeof(D3D12_VertexShader_Color), + ROOTSIG_COLOR }, + { D3D12_PixelShader_Textures, sizeof(D3D12_PixelShader_Textures), + D3D12_VertexShader_Texture, sizeof(D3D12_VertexShader_Texture), + ROOTSIG_TEXTURE }, +#if SDL_HAVE_YUV + { D3D12_PixelShader_YUV_JPEG, sizeof(D3D12_PixelShader_YUV_JPEG), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT601, sizeof(D3D12_PixelShader_YUV_BT601), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_YUV_BT709, sizeof(D3D12_PixelShader_YUV_BT709), + D3D12_VertexShader_YUV, sizeof(D3D12_VertexShader_YUV), + ROOTSIG_YUV }, + { D3D12_PixelShader_NV12_JPEG, sizeof(D3D12_PixelShader_NV12_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT601, sizeof(D3D12_PixelShader_NV12_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV12_BT709, sizeof(D3D12_PixelShader_NV12_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_JPEG, sizeof(D3D12_PixelShader_NV21_JPEG), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT601, sizeof(D3D12_PixelShader_NV21_BT601), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, + { D3D12_PixelShader_NV21_BT709, sizeof(D3D12_PixelShader_NV21_BT709), + D3D12_VertexShader_NV, sizeof(D3D12_VertexShader_NV), + ROOTSIG_NV }, +#endif +}; + +static struct +{ + const void *rs_shader_data; + SIZE_T rs_shader_size; +} D3D12_rootsigs[NUM_ROOTSIGS] = { + { D3D12_RootSig_Color, sizeof(D3D12_RootSig_Color) }, + { D3D12_RootSig_Texture, sizeof(D3D12_RootSig_Texture) }, +#if SDL_HAVE_YUV + { D3D12_RootSig_YUV, sizeof(D3D12_RootSig_YUV) }, + { D3D12_RootSig_NV, sizeof(D3D12_RootSig_NV) }, +#endif +}; + +extern "C" void +D3D12_GetVertexShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_shaders[shader].vs_shader_data; + outBytecode->BytecodeLength = D3D12_shaders[shader].vs_shader_size; +} + +extern "C" void +D3D12_GetPixelShader(D3D12_Shader shader, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_shaders[shader].ps_shader_data; + outBytecode->BytecodeLength = D3D12_shaders[shader].ps_shader_size; +} + +extern "C" D3D12_RootSignature +D3D12_GetRootSignatureType(D3D12_Shader shader) +{ + return D3D12_shaders[shader].root_sig; +} + +extern "C" void +D3D12_GetRootSignatureData(D3D12_RootSignature rootSig, D3D12_SHADER_BYTECODE *outBytecode) +{ + outBytecode->pShaderBytecode = D3D12_rootsigs[rootSig].rs_shader_data; + outBytecode->BytecodeLength = D3D12_rootsigs[rootSig].rs_shader_size; +} + +#endif /* SDL_VIDEO_RENDER_D3D12 && defined(__XBOXSERIES__) */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/metal/SDL_render_metal.m b/vs/sdl2/src/render/metal/SDL_render_metal.m index c2265601fa..ee6b882093 100644 --- a/vs/sdl2/src/render/metal/SDL_render_metal.m +++ b/vs/sdl2/src/render/metal/SDL_render_metal.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_METAL #include "SDL_hints.h" #include "SDL_syswm.h" @@ -1654,8 +1654,22 @@ static SDL_MetalView GetWindowView(SDL_Window *window) return NULL; } - // !!! FIXME: MTLCopyAllDevices() can find other GPUs on macOS... - mtldevice = MTLCreateSystemDefaultDevice(); +#ifdef __MACOSX__ + if (SDL_GetHintBoolean(SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE, SDL_TRUE)) { + NSArray> *devices = MTLCopyAllDevices(); + + for (id device in devices) { + if (device.isLowPower) { + mtldevice = device; + break; + } + } + } +#endif + + if (mtldevice == nil) { + mtldevice = MTLCreateSystemDefaultDevice(); + } if (mtldevice == nil) { SDL_free(renderer); @@ -1882,6 +1896,6 @@ in case we want to use it later (recreating the renderer) } }; -#endif /* SDL_VIDEO_RENDER_METAL && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_METAL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengl/SDL_glfuncs.h b/vs/sdl2/src/render/opengl/SDL_glfuncs.h index 42f9ef1828..860b9c07a3 100644 --- a/vs/sdl2/src/render/opengl/SDL_glfuncs.h +++ b/vs/sdl2/src/render/opengl/SDL_glfuncs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/opengl/SDL_render_gl.c b/vs/sdl2/src/render/opengl/SDL_render_gl.c index 291afba5d0..9c266191a6 100644 --- a/vs/sdl2/src/render/opengl/SDL_render_gl.c +++ b/vs/sdl2/src/render/opengl/SDL_render_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_OGL #include "SDL_hints.h" #include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult */ #include "SDL_opengl.h" @@ -186,7 +186,7 @@ GL_ClearErrors(SDL_Renderer *renderer) data->errors = 0; data->error_messages = NULL; } - } else if (data->glGetError != NULL) { + } else if (data->glGetError) { while (data->glGetError() != GL_NO_ERROR) { /* continue; */ } @@ -306,7 +306,7 @@ static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GL_FBOList)); if (result) { result->w = w; @@ -458,6 +458,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) GL_ActivateRenderer(renderer); renderdata->drawstate.texture = NULL; /* we trash this state. */ + renderdata->drawstate.texturing = SDL_FALSE; /* we trash this state. */ if (texture->access == SDL_TEXTUREACCESS_TARGET && !renderdata->GL_EXT_framebuffer_object_supported) { @@ -471,7 +472,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GL_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -888,7 +889,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return 0; } @@ -918,7 +919,7 @@ static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -938,7 +939,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con const size_t vertlen = (sizeof(GLfloat) * 2) * count; GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } cmd->data.draw.count = count; @@ -983,7 +984,7 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ size_t sz = 2 * sizeof(GLfloat) + 4 * sizeof(Uint8) + (texture ? 2 : 0) * sizeof(GLfloat); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1089,7 +1090,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const } if ((cmd->data.draw.texture != NULL) != data->drawstate.texturing) { - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { data->glDisable(data->textype); data->drawstate.texturing = SDL_FALSE; } else { @@ -1223,6 +1224,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = SDL_TRUE; } break; } @@ -1294,7 +1296,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1328,7 +1330,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1437,7 +1439,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1502,7 +1504,7 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1524,7 +1526,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (data) { - if (data->context != NULL) { + if (data->context) { /* make sure we delete the right resources! */ GL_ActivateRenderer(renderer); } @@ -1664,7 +1666,7 @@ static int GL_SetVSync(SDL_Renderer *renderer, const int vsync) if (retval != 0) { return retval; } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } else { renderer->info.flags &= ~SDL_RENDERER_PRESENTVSYNC; @@ -1730,13 +1732,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) #endif renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GL_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; @@ -1809,7 +1811,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) } else { SDL_GL_SetSwapInterval(0); } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } @@ -1831,7 +1833,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) } hint = SDL_getenv("GL_ARB_texture_non_power_of_two"); - if (hint == NULL || *hint != '0') { + if (!hint || *hint != '0') { SDL_bool isGL2 = SDL_FALSE; const char *verstr = (const char *)data->glGetString(GL_VERSION); if (verstr) { @@ -1968,6 +1970,6 @@ SDL_RenderDriver GL_RenderDriver = { 0 } }; -#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_OGL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengl/SDL_shaders_gl.c b/vs/sdl2/src/render/opengl/SDL_shaders_gl.c index 82b04cea89..e24a36af9d 100644 --- a/vs/sdl2/src/render/opengl/SDL_shaders_gl.c +++ b/vs/sdl2/src/render/opengl/SDL_shaders_gl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_OGL #include "SDL_stdinc.h" #include "SDL_opengl.h" @@ -497,7 +497,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) int i; ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { return NULL; } @@ -577,6 +577,6 @@ void GL_DestroyShaderContext(GL_ShaderContext *ctx) SDL_free(ctx); } -#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_OGL */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengl/SDL_shaders_gl.h b/vs/sdl2/src/render/opengl/SDL_shaders_gl.h index abc34b3ce7..d237b3ec25 100644 --- a/vs/sdl2/src/render/opengl/SDL_shaders_gl.h +++ b/vs/sdl2/src/render/opengl/SDL_shaders_gl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/opengles/SDL_glesfuncs.h b/vs/sdl2/src/render/opengles/SDL_glesfuncs.h index 2b81b85dd3..971b44554a 100644 --- a/vs/sdl2/src/render/opengles/SDL_glesfuncs.h +++ b/vs/sdl2/src/render/opengles/SDL_glesfuncs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/opengles/SDL_render_gles.c b/vs/sdl2/src/render/opengles/SDL_render_gles.c index 962acba523..9906b46d8b 100644 --- a/vs/sdl2/src/render/opengles/SDL_render_gles.c +++ b/vs/sdl2/src/render/opengles/SDL_render_gles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_OGL_ES #include "SDL_hints.h" #include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult */ @@ -150,11 +150,11 @@ static int GLES_SetError(const char *prefix, GLenum result) static int GLES_LoadFunctions(GLES_RenderData *data) { -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID +#elif defined(SDL_VIDEO_DRIVER_ANDROID) #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA +#elif defined(SDL_VIDEO_DRIVER_PANDORA) #define __SDL_NOGETPROCADDR__ #endif @@ -187,7 +187,7 @@ static GLES_FBOList *GLES_GetFBO(GLES_RenderData *data, Uint32 w, Uint32 h) while ((result) && ((result->w != w) || (result->h != h))) { result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GLES_FBOList)); result->w = w; result->h = h; @@ -322,7 +322,7 @@ static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) GLES_ActivateRenderer(renderer); switch (texture->format) { - case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA32: internalFormat = GL_RGBA; format = GL_RGBA; type = GL_UNSIGNED_BYTE; @@ -332,7 +332,7 @@ static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -424,7 +424,7 @@ static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, src = (Uint8 *)pixels; if (pitch != srcPitch) { blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -510,7 +510,7 @@ static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); return 0; } @@ -537,7 +537,7 @@ static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -557,7 +557,7 @@ static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c const size_t vertlen = (sizeof(GLfloat) * 2) * count; GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } cmd->data.draw.count = count; @@ -602,7 +602,7 @@ static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD int sz = 2 + 4 + (texture ? 2 : 0); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -900,7 +900,7 @@ static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 pixel_format, void *pixels, int pitch) { GLES_RenderData *data = (GLES_RenderData *)renderer->driverdata; - Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32; void *temp_pixels; int temp_pitch; Uint8 *src, *dst, *tmp; @@ -911,7 +911,7 @@ static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc(rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -970,7 +970,7 @@ static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1046,7 +1046,7 @@ static int GLES_SetVSync(SDL_Renderer *renderer, const int vsync) if (retval != 0) { return retval; } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } else { renderer->info.flags &= ~SDL_RENDERER_PRESENTVSYNC; @@ -1082,13 +1082,13 @@ static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags) } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { GLES_DestroyRenderer(renderer); SDL_OutOfMemory(); goto error; @@ -1141,7 +1141,7 @@ static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags) } else { SDL_GL_SetSwapInterval(0); } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } @@ -1210,11 +1210,11 @@ SDL_RenderDriver GLES_RenderDriver = { { "opengles", (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), 1, - { SDL_PIXELFORMAT_ABGR8888 }, + { SDL_PIXELFORMAT_RGBA32 }, 0, 0 } }; -#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_OGL_ES */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengles2/SDL_gles2funcs.h b/vs/sdl2/src/render/opengles2/SDL_gles2funcs.h index 4a90bced9a..b808b767c2 100644 --- a/vs/sdl2/src/render/opengles2/SDL_gles2funcs.h +++ b/vs/sdl2/src/render/opengles2/SDL_gles2funcs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ SDL_PROC(void, glPixelStorei, (GLenum, GLint)) SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *)) SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei)) SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei)) -#if __NACL__ +#ifdef __NACL__ SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *)) #else SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *)) diff --git a/vs/sdl2/src/render/opengles2/SDL_render_gles2.c b/vs/sdl2/src/render/opengles2/SDL_render_gles2.c index c5f53af2d9..43aebda0f4 100644 --- a/vs/sdl2/src/render/opengles2/SDL_render_gles2.c +++ b/vs/sdl2/src/render/opengles2/SDL_render_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_OGL_ES2 #include "SDL_hints.h" #include "../../video/SDL_sysvideo.h" /* For SDL_GL_SwapWindowWithResult */ @@ -220,7 +220,7 @@ GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, for (;;) { GLenum error = data->glGetError(); if (error != GL_NO_ERROR) { - if (prefix == NULL || prefix[0] == '\0') { + if (!prefix || prefix[0] == '\0') { prefix = "generic"; } SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); @@ -244,11 +244,11 @@ GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const char *file, static int GLES2_LoadFunctions(GLES2_RenderData *data) { -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID +#elif defined(SDL_VIDEO_DRIVER_ANDROID) #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA +#elif defined(SDL_VIDEO_DRIVER_PANDORA) #define __SDL_NOGETPROCADDR__ #endif @@ -275,7 +275,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h) while ((result) && ((result->w != w) || (result->h != h))) { result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GLES2_FBOList)); result->w = w; result->h = h; @@ -427,7 +427,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin /* Create a program cache entry */ entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return NULL; } @@ -488,7 +488,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { data->glDeleteProgram(data->program_cache.tail->id); data->program_cache.tail = data->program_cache.tail->prev; - if (data->program_cache.tail != NULL) { + if (data->program_cache.tail) { SDL_free(data->program_cache.tail->next); data->program_cache.tail->next = NULL; } @@ -505,7 +505,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G const GLchar *shader_src_list[3]; const GLchar *shader_body = GLES2_GetShader(type); - if (shader_body == NULL) { + if (!shader_body) { SDL_SetError("No shader body src"); return 0; } @@ -715,7 +715,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, /* Generate a matching program */ program = GLES2_CacheProgram(data, vertex, fragment); - if (program == NULL) { + if (!program) { goto fault; } @@ -739,7 +739,7 @@ static int GLES2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); + const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); int i; SDL_Color color; @@ -748,7 +748,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -771,7 +771,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, const SDL_FPoint *points, int count) { - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); + const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); int i; GLfloat prevx, prevy; SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); @@ -781,7 +781,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -831,7 +831,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S float scale_x, float scale_y) { int i; - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); + const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); int count = indices ? num_indices : num_vertices; cmd->data.draw.count = count; @@ -839,7 +839,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S if (texture) { SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -879,7 +879,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S } else { SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -959,7 +959,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co } if ((texture != NULL) != data->drawstate.texturing) { - if (texture == NULL) { + if (!texture) { data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); data->drawstate.texturing = SDL_FALSE; } else { @@ -1029,50 +1029,50 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo /* Check if we need to do color mapping between the source and render target textures */ if (renderer->target->format != texture->format) { switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_BGRA32: switch (renderer->target->format) { - case SDL_PIXELFORMAT_ABGR8888: - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_RGBA32: + case SDL_PIXELFORMAT_RGBX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; - case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGRX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; break; } break; - case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA32: switch (renderer->target->format) { - case SDL_PIXELFORMAT_ARGB8888: - case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGRA32: + case SDL_PIXELFORMAT_BGRX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_RGBX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; break; } break; - case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGRX32: switch (renderer->target->format) { - case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; - case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_BGRA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; break; - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_RGBX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; } break; - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_RGBX32: switch (renderer->target->format) { - case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; break; - case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_BGRA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; break; - case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGRX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; } @@ -1100,16 +1100,16 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo } } else { switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_BGRA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ARGB; break; - case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA32: sourceType = GLES2_IMAGESOURCE_TEXTURE_ABGR; break; - case SDL_PIXELFORMAT_RGB888: + case SDL_PIXELFORMAT_BGRX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_RGB; break; - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_RGBX32: sourceType = GLES2_IMAGESOURCE_TEXTURE_BGR; break; #if SDL_HAVE_YUV @@ -1162,7 +1162,7 @@ static int SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *cmd, vo static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; - const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_ARGB8888 || renderer->target->format == SDL_PIXELFORMAT_RGB888)); + const SDL_bool colorswap = (renderer->target && (renderer->target->format == SDL_PIXELFORMAT_BGRA32 || renderer->target->format == SDL_PIXELFORMAT_BGRX32)); #if USE_VERTEX_BUFFER_OBJECTS const int vboidx = data->current_vertex_buffer; @@ -1216,6 +1216,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = SDL_TRUE; } break; } @@ -1282,7 +1283,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1316,7 +1317,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1422,10 +1423,10 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Determine the corresponding GLES texture format params */ switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: - case SDL_PIXELFORMAT_ABGR8888: - case SDL_PIXELFORMAT_RGB888: - case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_BGRA32: + case SDL_PIXELFORMAT_RGBA32: + case SDL_PIXELFORMAT_BGRX32: + case SDL_PIXELFORMAT_RGBX32: format = GL_RGBA; type = GL_UNSIGNED_BYTE; break; @@ -1455,7 +1456,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Allocate a texture struct */ data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->texture = 0; @@ -1574,9 +1575,6 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels, GLint pitch, GLint bpp) { Uint8 *blob = NULL; -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - Uint32 *blob2 = NULL; -#endif Uint8 *src; size_t src_pitch; int y; @@ -1590,7 +1588,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff src = (Uint8 *)pixels; if (pitch != src_pitch) { blob = (Uint8 *)SDL_malloc(src_pitch * height); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -1602,33 +1600,10 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff src = blob; } -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - if (format == GL_RGBA) { - int i; - Uint32 *src32 = (Uint32 *)src; - blob2 = (Uint32 *)SDL_malloc(src_pitch * height); - if (blob2 == NULL) { - if (blob) { - SDL_free(blob); - } - return SDL_OutOfMemory(); - } - for (i = 0; i < (src_pitch * height) / 4; i++) { - blob2[i] = SDL_Swap32(src32[i]); - } - src = (Uint8 *)blob2; - } -#endif - data->glTexSubImage2D(target, 0, xoffset, yoffset, width, height, format, type, src); if (blob) { SDL_free(blob); } -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - if (blob2) { - SDL_free(blob2); - } -#endif return 0; } @@ -1868,7 +1843,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); } else { texturedata = (GLES2_TextureData *)texture->driverdata; @@ -1919,7 +1894,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 pixel_format, void *pixels, int pitch) { GLES2_RenderData *data = (GLES2_RenderData *)renderer->driverdata; - Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_ABGR8888; + Uint32 temp_format = renderer->target ? renderer->target->format : SDL_PIXELFORMAT_RGBA32; size_t buflen; void *temp_pixels; int temp_pitch; @@ -1934,7 +1909,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1989,7 +1964,7 @@ static int GLES2_SetVSync(SDL_Renderer *renderer, const int vsync) if (retval != 0) { return retval; } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } else { renderer->info.flags &= ~SDL_RENDERER_PRESENTVSYNC; @@ -2093,13 +2068,13 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) /* Create the renderer struct */ renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; @@ -2137,7 +2112,7 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) goto error; } -#if __WINRT__ +#ifdef __WINRT__ /* DLudwig, 2013-11-29: ANGLE for WinRT doesn't seem to work unless VSync * is turned on. Not doing so will freeze the screen's contents to that * of the first drawn frame. @@ -2150,7 +2125,7 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) } else { SDL_GL_SetSwapInterval(0); } - if (SDL_GL_GetSwapInterval() > 0) { + if (SDL_GL_GetSwapInterval() != 0) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } @@ -2262,14 +2237,14 @@ SDL_RenderDriver GLES2_RenderDriver = { { "opengles2", (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE), 4, - { SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888 }, + { SDL_PIXELFORMAT_RGBA32, + SDL_PIXELFORMAT_BGRA32, + SDL_PIXELFORMAT_BGRX32, + SDL_PIXELFORMAT_RGBX32 }, 0, 0 } }; -#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.c b/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.c index 50c86d6ea2..9a434f40b1 100644 --- a/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.c +++ b/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_OGL_ES2 #include "SDL_hints.h" #include "SDL_video.h" @@ -380,7 +380,7 @@ const char *GLES2_GetShaderInclude(GLES2_ShaderIncludeType type) } } -GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint() +GLES2_ShaderIncludeType GLES2_GetTexCoordPrecisionEnumFromHint(void) { const char *texcoord_hint = SDL_GetHint("SDL_RENDER_OPENGLES2_TEXCOORD_PRECISION"); GLES2_ShaderIncludeType value = GLES2_SHADER_FRAGMENT_INCLUDE_BEST_TEXCOORD_PRECISION; @@ -444,6 +444,6 @@ const char *GLES2_GetShader(GLES2_ShaderType type) } } -#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.h b/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.h index b358f38f2a..0be234f3ce 100644 --- a/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.h +++ b/vs/sdl2/src/render/opengles2/SDL_shaders_gles2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/ps2/SDL_render_ps2.c b/vs/sdl2/src/render/ps2/SDL_render_ps2.c index dc4bafaabc..ec17323cd4 100644 --- a/vs/sdl2/src/render/ps2/SDL_render_ps2.c +++ b/vs/sdl2/src/render/ps2/SDL_render_ps2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +47,7 @@ typedef struct { GSGLOBAL *gsGlobal; uint64_t drawColor; + SDL_Rect *viewport; int32_t vsync_callback_id; uint8_t vsync; /* 0 (Disabled), 1 (Enabled), 2 (Dynamic) */ } PS2_RenderData; @@ -105,7 +106,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE)); - if (ps2_tex == NULL) { + if (!ps2_tex) { return SDL_OutOfMemory(); } @@ -190,6 +191,19 @@ static int PS2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) } static int PS2_QueueSetViewport(SDL_Renderer *renderer, SDL_RenderCommand *cmd) +{ + PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; + const SDL_Rect *viewport = &cmd->data.viewport.rect; + data->viewport = (SDL_Rect *)viewport; + + data->gsGlobal->OffsetX = (int)((2048.0f + (float)viewport->x) * 16.0f); + data->gsGlobal->OffsetY = (int)((2048.0f + (float)viewport->y) * 16.0f); + gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h)); + + return 0; +} + +static int PS2_QueueSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { return 0; /* nothing to do in this backend. */ } @@ -202,16 +216,16 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c gs_rgbaq rgbaq; int i; - if (vertices == NULL) { + if (!vertices) { return -1; } cmd->data.draw.count = count; - colorR = cmd->data.draw.r >> 1; - colorG = cmd->data.draw.g >> 1; - colorB = cmd->data.draw.b >> 1; - colorA = cmd->data.draw.a >> 1; + colorR = cmd->data.draw.r; + colorG = cmd->data.draw.g; + colorB = cmd->data.draw.b; + colorA = cmd->data.draw.a; rgbaq = color_to_RGBAQ(colorR, colorG, colorB, colorA, 0.0f); for (i = 0; i < count; i++, vertices++, points++) { @@ -237,7 +251,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL GSPRIMUVPOINT *vertices = (GSPRIMUVPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMUVPOINT), 4, &cmd->data.draw.first); GSTEXTURE *ps2_tex = (GSTEXTURE *) texture->driverdata; - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -261,7 +275,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL uv_ = (float *)((char *)uv + j * uv_stride); vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0); - vertices->rgbaq = color_to_RGBAQ(col_.r >> 1, col_.g >> 1, col_.b >> 1, col_.a >> 1, 0); + vertices->rgbaq = color_to_RGBAQ(col_.r, col_.g, col_.b, col_.a, 0); vertices->uv = vertex_to_UV(ps2_tex, uv_[0] * ps2_tex->Width, uv_[1] * ps2_tex->Height); vertices++; @@ -270,7 +284,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL } else { GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -292,7 +306,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL col_ = *(SDL_Color *)((char *)color + j * color_stride); vertices->xyz2 = vertex_to_XYZ2(data->gsGlobal, xy_[0] * scale_x, xy_[1] * scale_y, 0); - vertices->rgbaq = color_to_RGBAQ(col_.r >> 1, col_.g >> 1, col_.b >> 1, col_.a >> 1, 0.0f); + vertices->rgbaq = color_to_RGBAQ(col_.r, col_.g, col_.b, col_.a, 0.0f); vertices++; } @@ -303,26 +317,24 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL static int PS2_RenderSetViewPort(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - const SDL_Rect *viewport = &cmd->data.viewport.rect; - - gsKit_set_display_offset(data->gsGlobal, viewport->x, viewport->y); - gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->y, viewport->w, viewport->h)); - - return 0; + return 0; /* nothing to do in this backend. */ } static int PS2_RenderSetClipRect(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; + SDL_Rect *viewport = data->viewport; const SDL_Rect *rect = &cmd->data.cliprect.rect; if (cmd->data.cliprect.enabled) { - gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(rect->x, rect->y, rect->w, rect->h)); - } else { - gsKit_set_scissor(data->gsGlobal, GS_SCISSOR_RESET); + /* We need to do it relative to saved viewport */ + viewport->x += rect->x; + viewport->y += rect->y; + viewport->w = SDL_min(viewport->w, rect->w); + viewport->h = SDL_min(viewport->h, rect->h); } + gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h)); return 0; } @@ -333,26 +345,43 @@ static int PS2_RenderSetDrawColor(SDL_Renderer *renderer, SDL_RenderCommand *cmd PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - colorR = (cmd->data.color.r) >> 1; - colorG = (cmd->data.color.g) >> 1; - colorB = (cmd->data.color.b) >> 1; - colorA = (cmd->data.color.a) >> 1; + colorR = (cmd->data.color.r); + colorG = (cmd->data.color.g); + colorB = (cmd->data.color.b); + colorA = (cmd->data.color.a); data->drawColor = GS_SETREG_RGBAQ(colorR, colorG, colorB, colorA, 0x00); return 0; } static int PS2_RenderClear(SDL_Renderer *renderer, SDL_RenderCommand *cmd) { - int colorR, colorG, colorB, colorA; + int colorR, colorG, colorB, colorA, offsetX, offsetY; + SDL_Rect *viewport; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - colorR = (cmd->data.color.r) >> 1; - colorG = (cmd->data.color.g) >> 1; - colorB = (cmd->data.color.b) >> 1; - colorA = (cmd->data.color.a) >> 1; + colorR = (cmd->data.color.r); + colorG = (cmd->data.color.g); + colorB = (cmd->data.color.b); + colorA = (cmd->data.color.a); + + /* Clear the screen, so let's put default viewport */ + gsKit_set_scissor(data->gsGlobal, GS_SCISSOR_RESET); + /* Put back original offset */ + offsetX = data->gsGlobal->OffsetX; + offsetY = data->gsGlobal->OffsetY; + data->gsGlobal->OffsetX = (int)(2048.0f * 16.0f); + data->gsGlobal->OffsetY = (int)(2048.0f * 16.0f); gsKit_clear(data->gsGlobal, GS_SETREG_RGBAQ(colorR, colorG, colorB, colorA, 0x00)); + /* Put back original offset */ + data->gsGlobal->OffsetX = offsetX; + data->gsGlobal->OffsetY = offsetY; + + // /* Put back view port */ + viewport = data->viewport; + gsKit_set_scissor(data->gsGlobal, GS_SETREG_SCISSOR(viewport->x, viewport->x + viewport->w, viewport->y, viewport->y + viewport->h)); + return 0; } @@ -448,6 +477,7 @@ static int PS2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v case SDL_RENDERCMD_SETVIEWPORT: { PS2_RenderSetViewPort(renderer, cmd); + /* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */ break; } case SDL_RENDERCMD_SETCLIPRECT: @@ -531,11 +561,11 @@ static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - if (data == NULL) { + if (!data) { return; } - if (ps2_texture == NULL) { + if (!ps2_texture) { return; } @@ -584,13 +614,13 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_bool dynamicVsync; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PS2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; @@ -645,7 +675,7 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags) renderer->SetTextureScaleMode = PS2_SetTextureScaleMode; renderer->SetRenderTarget = PS2_SetRenderTarget; renderer->QueueSetViewport = PS2_QueueSetViewport; - renderer->QueueSetDrawColor = PS2_QueueSetViewport; + renderer->QueueSetDrawColor = PS2_QueueSetDrawColor; renderer->QueueDrawPoints = PS2_QueueDrawPoints; renderer->QueueDrawLines = PS2_QueueDrawPoints; renderer->QueueGeometry = PS2_QueueGeometry; diff --git a/vs/sdl2/src/render/psp/SDL_render_psp.c b/vs/sdl2/src/render/psp/SDL_render_psp.c index 95a48d9ff9..47fab82c15 100644 --- a/vs/sdl2/src/render/psp/SDL_render_psp.c +++ b/vs/sdl2/src/render/psp/SDL_render_psp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -282,11 +282,11 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst) src = (unsigned int *)psp_texture->data; data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -344,11 +344,11 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst) data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -392,7 +392,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture if (psp_texture->swizzled) { // Texture was swizzled in vram, just copy to system memory void *sdata = SDL_malloc(psp_texture->size); - if (sdata == NULL) { + if (!sdata) { return SDL_OutOfMemory(); } @@ -484,7 +484,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *data = renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture)); - if (psp_texture == NULL) { + if (!psp_texture) { return SDL_OutOfMemory(); } @@ -630,7 +630,7 @@ static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -656,10 +656,10 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL cmd->data.draw.count = count; size_indices = indices ? size_indices : 0; - if (texture == NULL) { + if (!texture) { VertCV *verts; verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -692,7 +692,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; VertTCV *verts; verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -737,7 +737,7 @@ static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -773,7 +773,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) { verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -809,7 +809,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex cmd->data.draw.count = count; verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -860,7 +860,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T float u1 = srcrect->x + srcrect->w; float v1 = srcrect->y + srcrect->h; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1011,7 +1011,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) } if (state->texture != current->texture) { - if (state->texture != NULL) { + if (state->texture) { TextureActivate(state->texture); sceGuEnable(GU_TEXTURE_2D); } else { @@ -1035,7 +1035,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v rendering backends report a reasonable maximum, so the higher level can flush if we appear to be exceeding that. */ gpumem = (Uint8 *)sceGuGetMemory(vertsize); - if (gpumem == NULL) { + if (!gpumem) { return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int)vertsize); } SDL_memcpy(gpumem, vertices, vertsize); @@ -1053,6 +1053,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v sceGuOffset(2048 - (viewport->w >> 1), 2048 - (viewport->h >> 1)); sceGuViewport(2048, 2048, viewport->w, viewport->h); sceGuScissor(viewport->x, viewport->y, viewport->w, viewport->h); + /* FIXME: We need to update the clip rect too, see https://github.com/libsdl-org/SDL/issues/9094 */ break; } @@ -1177,7 +1178,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v case SDL_RENDERCMD_GEOMETRY: { const size_t count = cmd->data.draw.count; - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first); sceGuDisable(GU_TEXTURE_2D); /* In GU_SMOOTH mode */ @@ -1245,11 +1246,11 @@ static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *renderdata = (PSP_RenderData *)renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; - if (renderdata == NULL) { + if (!renderdata) { return; } - if (psp_texture == NULL) { + if (!psp_texture) { return; } @@ -1300,13 +1301,13 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, Uint32 flags) void *doublebuffer = NULL; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PSP_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; diff --git a/vs/sdl2/src/render/software/SDL_blendfillrect.c b/vs/sdl2/src/render/software/SDL_blendfillrect.c index 2489eb11a1..2026cb885d 100644 --- a/vs/sdl2/src/render/software/SDL_blendfillrect.c +++ b/vs/sdl2/src/render/software/SDL_blendfillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "SDL_draw.h" #include "SDL_blendfillrect.h" @@ -211,7 +211,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, { SDL_Rect clipped; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRect(): dst"); } @@ -281,7 +281,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRects(): dst"); } @@ -325,7 +325,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendFillRect_RGB; } else { @@ -343,6 +343,6 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_blendfillrect.h b/vs/sdl2/src/render/software/SDL_blendfillrect.h index 4379a8eb2b..eb9ba7d264 100644 --- a/vs/sdl2/src/render/software/SDL_blendfillrect.h +++ b/vs/sdl2/src/render/software/SDL_blendfillrect.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_blendline.c b/vs/sdl2/src/render/software/SDL_blendline.c index 0d6365619b..19e2cdb0d6 100644 --- a/vs/sdl2/src/render/software/SDL_blendline.c +++ b/vs/sdl2/src/render/software/SDL_blendline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "SDL_draw.h" #include "SDL_blendline.h" @@ -798,12 +798,12 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, { BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendLine(): dst"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLine(): Unsupported surface format"); } @@ -826,12 +826,12 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLines(): Unsupported surface format"); } @@ -859,6 +859,6 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_blendline.h b/vs/sdl2/src/render/software/SDL_blendline.h index 4abcbb5b13..993dd47338 100644 --- a/vs/sdl2/src/render/software/SDL_blendline.h +++ b/vs/sdl2/src/render/software/SDL_blendline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_blendpoint.c b/vs/sdl2/src/render/software/SDL_blendpoint.c index 3fc68f45ef..c380371103 100644 --- a/vs/sdl2/src/render/software/SDL_blendpoint.c +++ b/vs/sdl2/src/render/software/SDL_blendpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "SDL_draw.h" #include "SDL_blendpoint.h" @@ -209,7 +209,7 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoint(): dst"); } @@ -277,7 +277,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoints(): dst"); } @@ -323,7 +323,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendPoint_RGB; } else { @@ -348,6 +348,6 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, return status; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_blendpoint.h b/vs/sdl2/src/render/software/SDL_blendpoint.h index 74ed964564..86ee766ea8 100644 --- a/vs/sdl2/src/render/software/SDL_blendpoint.h +++ b/vs/sdl2/src/render/software/SDL_blendpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_draw.h b/vs/sdl2/src/render/software/SDL_draw.h index db593f4d35..ab80b87f82 100644 --- a/vs/sdl2/src/render/software/SDL_draw.h +++ b/vs/sdl2/src/render/software/SDL_draw.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_drawline.c b/vs/sdl2/src/render/software/SDL_drawline.c index 8acf5ee89b..e164a8f08c 100644 --- a/vs/sdl2/src/render/software/SDL_drawline.c +++ b/vs/sdl2/src/render/software/SDL_drawline.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "SDL_draw.h" #include "SDL_drawline.h" @@ -137,12 +137,12 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) { DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLine(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLine(): Unsupported surface format"); } @@ -165,12 +165,12 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLines(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLines(): Unsupported surface format"); } @@ -197,6 +197,6 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_drawline.h b/vs/sdl2/src/render/software/SDL_drawline.h index 5ef98ad6de..0d406c8584 100644 --- a/vs/sdl2/src/render/software/SDL_drawline.h +++ b/vs/sdl2/src/render/software/SDL_drawline.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_drawpoint.c b/vs/sdl2/src/render/software/SDL_drawpoint.c index 77404421a5..16bb9fac29 100644 --- a/vs/sdl2/src/render/software/SDL_drawpoint.c +++ b/vs/sdl2/src/render/software/SDL_drawpoint.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +20,14 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "SDL_draw.h" #include "SDL_drawpoint.h" int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoint(): dst"); } @@ -67,7 +67,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, int i; int x, y; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoints(): dst"); } @@ -106,6 +106,6 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, return 0; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_drawpoint.h b/vs/sdl2/src/render/software/SDL_drawpoint.h index 1a1c8d6ba3..1e74d59737 100644 --- a/vs/sdl2/src/render/software/SDL_drawpoint.h +++ b/vs/sdl2/src/render/software/SDL_drawpoint.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_render_sw.c b/vs/sdl2/src/render/software/SDL_render_sw.c index edf4923277..b7843340f6 100644 --- a/vs/sdl2/src/render/software/SDL_render_sw.c +++ b/vs/sdl2/src/render/software/SDL_render_sw.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #include "../SDL_sysrender.h" #include "SDL_render_sw_c.h" @@ -196,7 +196,7 @@ static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -215,7 +215,7 @@ static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -236,7 +236,7 @@ static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Text { SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -270,7 +270,7 @@ static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Te { CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -324,7 +324,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex int blitRequired = SDL_FALSE; int isOpaque = SDL_FALSE; - if (surface == NULL) { + if (!surface) { return -1; } @@ -346,7 +346,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); - if (src_clone == NULL) { + if (!src_clone) { if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } @@ -390,7 +390,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (mask == NULL) { + if (!mask) { retval = -1; } else { SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD); @@ -404,7 +404,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex SDL_Rect scale_rect = tmp_rect; src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (src_scaled == NULL) { + if (!src_scaled) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); @@ -427,15 +427,15 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated = SDLgfx_rotateSurface(src_clone, angle, (texture->scaleMode == SDL_ScaleModeNearest) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, &rect_dest, cangle, sangle, center); - if (src_rotated == NULL) { + if (!src_rotated) { retval = -1; } - if (!retval && mask != NULL) { + if (!retval && mask) { /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ mask_rotated = SDLgfx_rotateSurface(mask, angle, SDL_FALSE, 0, 0, &rect_dest, cangle, sangle, center); - if (mask_rotated == NULL) { + if (!mask_rotated) { retval = -1; } } @@ -487,7 +487,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated->format->BitsPerPixel, src_rotated->pitch, src_rotated->format->Rmask, src_rotated->format->Gmask, src_rotated->format->Bmask, 0); - if (src_rotated_rgb == NULL) { + if (!src_rotated_rgb) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD); @@ -499,7 +499,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex } SDL_FreeSurface(mask_rotated); } - if (src_rotated != NULL) { + if (src_rotated) { SDL_FreeSurface(src_rotated); } } @@ -508,10 +508,10 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } - if (mask != NULL) { + if (mask) { SDL_FreeSurface(mask); } - if (src_clone != NULL) { + if (src_clone) { SDL_FreeSurface(src_clone); } return retval; @@ -538,10 +538,10 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ int i; int count = indices ? num_indices : num_vertices; void *verts; - size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); + size_t sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -643,7 +643,7 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) const SDL_Rect *cliprect = drawstate->cliprect; SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ - if (cliprect != NULL) { + if (cliprect) { SDL_Rect clip_rect; clip_rect.x = cliprect->x + viewport->x; clip_rect.y = cliprect->y + viewport->y; @@ -663,7 +663,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_Surface *surface = SW_ActivateRenderer(renderer); SW_DrawStateCache drawstate; - if (surface == NULL) { + if (!surface) { return -1; } @@ -712,7 +712,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -739,7 +739,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -766,7 +766,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -794,7 +794,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { dstrect->x += drawstate.viewport->x; dstrect->y += drawstate.viewport->y; } @@ -852,7 +852,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { copydata->dstrect.x += drawstate.viewport->x; copydata->dstrect.y += drawstate.viewport->y; } @@ -880,7 +880,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -903,7 +903,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo GeometryFillData *ptr = (GeometryFillData *) verts; /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -938,7 +938,7 @@ static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 src_format; void *src_pixels; - if (surface == NULL) { + if (!surface) { return -1; } @@ -965,7 +965,7 @@ static int SW_RenderPresent(SDL_Renderer *renderer) { SDL_Window *window = renderer->window; - if (window == NULL) { + if (!window) { return -1; } return SDL_UpdateWindowSurface(window); @@ -980,8 +980,12 @@ static void SW_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) static void SW_DestroyRenderer(SDL_Renderer *renderer) { + SDL_Window *window = renderer->window; SW_RenderData *data = (SW_RenderData *)renderer->driverdata; + if (window) { + SDL_DestroyWindowSurface(window); + } SDL_free(data); SDL_free(renderer); } @@ -991,19 +995,19 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface) SDL_Renderer *renderer; SW_RenderData *data; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SW_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; @@ -1035,8 +1039,6 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface) renderer->info = SW_RenderDriver.info; renderer->driverdata = data; - SW_ActivateRenderer(renderer); - return renderer; } @@ -1048,7 +1050,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) /* Set the vsync hint based on our flags, if it's not already set */ hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); - if (hint == NULL || !*hint) { + if (!hint || !*hint) { no_hint_set = SDL_TRUE; } else { no_hint_set = SDL_FALSE; @@ -1065,7 +1067,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_SetHint(SDL_HINT_RENDER_VSYNC, ""); } - if (surface == NULL) { + if (!surface) { return NULL; } return SW_CreateRendererForSurface(surface); @@ -1091,6 +1093,6 @@ SDL_RenderDriver SW_RenderDriver = { 0} }; -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_render_sw_c.h b/vs/sdl2/src/render/software/SDL_render_sw_c.h index f6c54c02f5..1d7901fc87 100644 --- a/vs/sdl2/src/render/software/SDL_render_sw_c.h +++ b/vs/sdl2/src/render/software/SDL_render_sw_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_rotate.c b/vs/sdl2/src/render/software/SDL_rotate.c index d51df2f1fe..d29b92d68b 100644 --- a/vs/sdl2/src/render/software/SDL_rotate.c +++ b/vs/sdl2/src/render/software/SDL_rotate.c @@ -30,7 +30,7 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW #if defined(__WIN32__) || defined(__GDK__) #include "../../core/windows/SDL_windows.h" @@ -500,7 +500,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in double sangleinv, cangleinv; /* Sanity check */ - if (src == NULL) { + if (!src) { return NULL; } @@ -524,7 +524,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (is8bit) { /* Target surface is 8 bit */ rz_dst = SDL_CreateRGBSurfaceWithFormat(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 8, src->format->format); - if (rz_dst != NULL) { + if (rz_dst) { if (src->format->palette) { for (i = 0; i < src->format->palette->ncolors; i++) { rz_dst->format->palette->colors[i] = src->format->palette->colors[i]; @@ -540,7 +540,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in } /* Check target */ - if (rz_dst == NULL) { + if (!rz_dst) { return NULL; } @@ -617,4 +617,4 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in return rz_dst; } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ diff --git a/vs/sdl2/src/render/software/SDL_rotate.h b/vs/sdl2/src/render/software/SDL_rotate.h index 43e90e8af3..9e08e53abb 100644 --- a/vs/sdl2/src/render/software/SDL_rotate.h +++ b/vs/sdl2/src/render/software/SDL_rotate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/software/SDL_triangle.c b/vs/sdl2/src/render/software/SDL_triangle.c index fc429db6e2..f6af3dcabe 100644 --- a/vs/sdl2/src/render/software/SDL_triangle.c +++ b/vs/sdl2/src/render/software/SDL_triangle.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,9 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_SW + +#include #include "SDL_surface.h" #include "SDL_triangle.h" @@ -87,9 +89,9 @@ int SDL_FillTriangle(SDL_Surface *dst, const SDL_Point points[3], Uint32 color) #endif /* cross product AB x AC */ -static int cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int c_y) +static Sint64 cross_product(const SDL_Point *a, const SDL_Point *b, int c_x, int c_y) { - return (b->x - a->x) * (c_y - a->y) - (b->y - a->y) * (c_x - a->x); + return ((Sint64)(b->x - a->x)) * ((Sint64)(c_y - a->y)) - ((Sint64)(b->y - a->y)) * ((Sint64)(c_x - a->x)); } /* check for top left rules */ @@ -113,10 +115,23 @@ static int is_top_left(const SDL_Point *a, const SDL_Point *b, int is_clockwise) return 0; } +/* x = (y << FP_BITS) */ +/* prevent runtime error: left shift of negative value */ +#define PRECOMP(x, y) \ + val = y; \ + if (val >= 0) { \ + x = val << FP_BITS; \ + } else { \ + val *= -1; \ + x = val << FP_BITS; \ + x *= -1; \ + } + void trianglepoint_2_fixedpoint(SDL_Point *a) { - a->x <<= FP_BITS; - a->y <<= FP_BITS; + int val; + PRECOMP(a->x, a->x); + PRECOMP(a->y, a->y); } /* bounding rect of three points (in fixed point) */ @@ -158,9 +173,9 @@ static void bounding_rect(const SDL_Point *a, const SDL_Point *b, const SDL_Poin int x, y; \ for (y = 0; y < dstrect.h; y++) { \ /* y start */ \ - int w0 = w0_row; \ - int w1 = w1_row; \ - int w2 = w2_row; \ + Sint64 w0 = w0_row; \ + Sint64 w1 = w1_row; \ + Sint64 w2 = w2_row; \ for (x = 0; x < dstrect.w; x++) { \ /* In triangle */ \ if (w0 + bias_w0 >= 0 && w1 + bias_w1 >= 0 && w2 + bias_w2 >= 0) { \ @@ -210,17 +225,18 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin Uint8 *dst_ptr; int dst_pitch; - int area, is_clockwise; + Sint64 area; + int is_clockwise; int d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x; - int w0_row, w1_row, w2_row; + Sint64 w0_row, w1_row, w2_row; int bias_w0, bias_w1, bias_w2; int is_uniform; SDL_Surface *tmp = NULL; - if (dst == NULL) { + if (!dst) { return -1; } @@ -272,7 +288,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin /* Use an intermediate surface */ tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect.w, dstrect.h, 0, format); - if (tmp == NULL) { + if (!tmp) { ret = -1; goto end; } @@ -296,14 +312,19 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin } is_clockwise = area > 0; - area = SDL_abs(area); + if (area < 0) { + area = -area; + } - d2d1_y = (d1->y - d2->y) << FP_BITS; - d0d2_y = (d2->y - d0->y) << FP_BITS; - d1d0_y = (d0->y - d1->y) << FP_BITS; - d1d2_x = (d2->x - d1->x) << FP_BITS; - d2d0_x = (d0->x - d2->x) << FP_BITS; - d0d1_x = (d1->x - d0->x) << FP_BITS; + { + int val; + PRECOMP(d2d1_y, d1->y - d2->y) + PRECOMP(d0d2_y, d2->y - d0->y) + PRECOMP(d1d0_y, d0->y - d1->y) + PRECOMP(d1d2_x, d2->x - d1->x) + PRECOMP(d2d0_x, d0->x - d2->x) + PRECOMP(d0d1_x, d1->x - d0->x) + } /* Starting point for rendering, at the middle of a pixel */ { @@ -339,12 +360,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin if (is_uniform) { Uint32 color; if (tmp) { - if (dst->format->Amask) { - color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a); - } else { - // color = SDL_MapRGB(tmp->format, c0.r, c0.g, c0.b); - color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a); - } + color = SDL_MapRGBA(tmp->format, c0.r, c0.g, c0.b, c0.a); } else { color = SDL_MapRGBA(dst->format, c0.r, c0.g, c0.b, c0.a); } @@ -453,20 +469,24 @@ int SDL_SW_BlitTriangle( int *src_ptr; int src_pitch; - int area, is_clockwise; + Sint64 area, tmp64; + int is_clockwise; int d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x; int s2s0_x, s2s1_x, s2s0_y, s2s1_y; - int w0_row, w1_row, w2_row; + Sint64 w0_row, w1_row, w2_row; int bias_w0, bias_w1, bias_w2; int is_uniform; int has_modulation; - if (src == NULL || dst == NULL) { - return -1; + if (!src) { + return SDL_InvalidParamError("src"); + } + if (!src) { + return SDL_InvalidParamError("dst"); } area = cross_product(d0, d1, d2->x, d2->y); @@ -568,15 +588,19 @@ int SDL_SW_BlitTriangle( src_pitch = src->pitch; is_clockwise = area > 0; - area = SDL_abs(area); - - d2d1_y = (d1->y - d2->y) << FP_BITS; - d0d2_y = (d2->y - d0->y) << FP_BITS; - d1d0_y = (d0->y - d1->y) << FP_BITS; + if (area < 0) { + area = -area; + } - d1d2_x = (d2->x - d1->x) << FP_BITS; - d2d0_x = (d0->x - d2->x) << FP_BITS; - d0d1_x = (d1->x - d0->x) << FP_BITS; + { + int val; + PRECOMP(d2d1_y, d1->y - d2->y) + PRECOMP(d0d2_y, d2->y - d0->y) + PRECOMP(d1d0_y, d0->y - d1->y) + PRECOMP(d1d2_x, d2->x - d1->x) + PRECOMP(d2d0_x, d0->x - d2->x) + PRECOMP(d0d1_x, d1->x - d0->x) + } s2s0_x = s0->x - s2->x; s2s1_x = s1->x - s2->x; @@ -615,8 +639,20 @@ int SDL_SW_BlitTriangle( bias_w2 = (is_top_left(d0, d1, is_clockwise) ? 0 : -1); /* precompute constant 's2->x * area' used in TRIANGLE_GET_TEXTCOORD */ - s2_x_area.x = s2->x * area; - s2_x_area.y = s2->y * area; + tmp64 = s2->x * area; + if (tmp64 >= INT_MIN && tmp64 <= INT_MAX) { + s2_x_area.x = (int)tmp64; + } else { + ret = SDL_SetError("triangle area overflow"); + goto end; + } + tmp64 = s2->y * area; + if (tmp64 >= INT_MIN && tmp64 <= INT_MAX) { + s2_x_area.y = (int)tmp64; + } else { + ret = SDL_SetError("triangle area overflow"); + goto end; + } if (blend != SDL_BLENDMODE_NONE || src->format->format != dst->format->format || has_modulation || !is_uniform) { /* Use SDL_BlitTriangle_Slow */ @@ -662,9 +698,18 @@ int SDL_SW_BlitTriangle( tmp_info.dst = dst_ptr; tmp_info.dst_pitch = dst_pitch; - SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, area, bias_w0, bias_w1, bias_w2, +#define CHECK_INT_RANGE(X) \ + if ((X) < INT_MIN || (X) > INT_MAX) { \ + ret = SDL_SetError("integer overflow (%s = %" SDL_PRIs64 ")", #X, X); \ + goto end; \ + } + CHECK_INT_RANGE(area); + CHECK_INT_RANGE(w0_row); + CHECK_INT_RANGE(w1_row); + CHECK_INT_RANGE(w2_row); + SDL_BlitTriangle_Slow(&tmp_info, s2_x_area, dstrect, (int)area, bias_w0, bias_w1, bias_w2, d2d1_y, d1d2_x, d0d2_y, d2d0_x, d1d0_y, d0d1_x, - s2s0_x, s2s1_x, s2s0_y, s2s1_y, w0_row, w1_row, w2_row, + s2s0_x, s2s1_x, s2s0_y, s2s1_y, (int)w0_row, (int)w1_row, (int)w2_row, c0, c1, c2, is_uniform); goto end; @@ -789,15 +834,20 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (!is_uniform) { @@ -885,6 +935,6 @@ static void SDL_BlitTriangle_Slow(SDL_BlitInfo *info, TRIANGLE_END_LOOP } -#endif /* SDL_VIDEO_RENDER_SW && !SDL_RENDER_DISABLED */ +#endif /* SDL_VIDEO_RENDER_SW */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/render/software/SDL_triangle.h b/vs/sdl2/src/render/software/SDL_triangle.h index f72fda5888..463cab60da 100644 --- a/vs/sdl2/src/render/software/SDL_triangle.h +++ b/vs/sdl2/src/render/software/SDL_triangle.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm.c b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm.c index 434a7e425f..7d8085902d 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ /* #define DEBUG_RAZOR */ -#if DEBUG_RAZOR +#ifdef DEBUG_RAZOR #include #endif @@ -169,7 +169,7 @@ void StartDrawing(SDL_Renderer *renderer) // data->colorFragmentProgram = in->color; // data->textureFragmentProgram = in->texture; - if (renderer->target == NULL) { + if (!renderer->target) { sceGxmBeginScene( data->gxm_context, 0, @@ -217,13 +217,13 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) VITA_GXM_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -266,7 +266,7 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) data->displayData.wait_vblank = SDL_FALSE; } -#if DEBUG_RAZOR +#ifdef DEBUG_RAZOR sceSysmoduleLoadModule(SCE_SYSMODULE_RAZOR_HUD); sceSysmoduleLoadModule(SCE_SYSMODULE_RAZOR_CAPTURE); #endif @@ -295,7 +295,7 @@ 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 == NULL) { + if (!vita_texture) { return SDL_OutOfMemory(); } @@ -583,7 +583,7 @@ static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, *pitch = vita_texture->pitch; // make sure that rendering is finished on render target textures - if (vita_texture->tex->gxm_rendertarget != NULL) { + if (vita_texture->tex->gxm_rendertarget) { sceGxmFinish(data->gxm_context); } @@ -733,7 +733,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(texture_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -772,7 +772,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(color_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -956,6 +956,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c if (SDL_memcmp(viewport, &cmd->data.viewport.rect, sizeof(cmd->data.viewport.rect)) != 0) { SDL_copyp(viewport, &cmd->data.viewport.rect); data->drawstate.viewport_dirty = SDL_TRUE; + data->drawstate.cliprect_dirty = SDL_TRUE; } break; } @@ -1006,7 +1007,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1103,7 +1104,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1161,7 +1162,7 @@ static int VITA_GXM_RenderPresent(SDL_Renderer *renderer) sceCommonDialogUpdate(&updateParam); -#if DEBUG_RAZOR +#ifdef DEBUG_RAZOR sceGxmPadHeartbeat( (const SceGxmColorSurface *)&data->displaySurface[data->backBufferIndex], (SceGxmSyncObject *)data->displayBufferSync[data->backBufferIndex]); @@ -1186,15 +1187,15 @@ 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 == NULL) { + if (!data) { return; } - if (vita_texture == NULL) { + if (!vita_texture) { return; } - if (vita_texture->tex == NULL) { + if (!vita_texture->tex) { return; } diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.c index a5a4aacfe8..86e33115f4 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.c +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -66,7 +66,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) { void *mem; - if (data->texturePool == NULL) { + if (!data->texturePool) { int poolsize; int ret; SceKernelFreeMemorySizeInfo info; @@ -88,7 +88,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) } data->texturePool = sceClibMspaceCreate(mem, poolsize); - if (data->texturePool == NULL) { + if (!data->texturePool) { return NULL; } ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); @@ -101,7 +101,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) { - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceFree(data->texturePool, ptr); } } @@ -109,7 +109,7 @@ void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) void vita_gpu_mem_destroy(VITA_GXM_RenderData *data) { void *mem = NULL; - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceDestroy(data->texturePool); data->texturePool = NULL; if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) { diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.h b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.h index dc3d99fec5..1f3832ee07 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.h +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_memory.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_shaders.h b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_shaders.h index 1710ca66d1..d383fd8efe 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_shaders.h +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_shaders.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 772a703f34..2c38441d1d 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1003,7 +1003,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2; } - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1017,7 +1017,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size); /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */ - if (texture_data == NULL) { + if (!texture_data) { SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n"); texture_data = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -1030,7 +1030,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig texture->cdram = 1; } - if (texture_data == NULL) { + if (!texture_data) { SDL_free(texture); return NULL; } diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.h b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.h index 789061182e..ca50e3f3c9 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.h +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_tools.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_types.h b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_types.h index 63d4bd2111..4255247d6c 100644 --- a/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_types.h +++ b/vs/sdl2/src/render/vitagxm/SDL_render_vita_gxm_types.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/SDL_sensor.c b/vs/sdl2/src/sensor/SDL_sensor.c index 6e978ac9ed..3179f7302e 100644 --- a/vs/sdl2/src/sensor/SDL_sensor.c +++ b/vs/sdl2/src/sensor/SDL_sensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_events.h" #include "SDL_syssensor.h" -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif @@ -75,7 +75,7 @@ int SDL_SensorInit(void) SDL_sensor_lock = SDL_CreateMutex(); } -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) { return -1; } @@ -108,7 +108,7 @@ int SDL_NumSensors(void) * Return the next available sensor instance ID * This may be called by drivers from multiple threads, unprotected by any locks */ -SDL_SensorID SDL_GetNextSensorInstanceID() +SDL_SensorID SDL_GetNextSensorInstanceID(void) { return SDL_AtomicIncRef(&SDL_next_sensor_instance_id); } @@ -237,7 +237,7 @@ SDL_Sensor *SDL_SensorOpen(int device_index) /* Create and initialize the sensor */ sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1); - if (sensor == NULL) { + if (!sensor) { SDL_OutOfMemory(); SDL_UnlockSensors(); return NULL; @@ -297,7 +297,7 @@ static int SDL_PrivateSensorValid(SDL_Sensor *sensor) { int valid; - if (sensor == NULL) { + if (!sensor) { SDL_SetError("Sensor hasn't been opened yet"); valid = 0; } else { @@ -454,7 +454,7 @@ void SDL_SensorQuit(void) SDL_UnlockSensors(); -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED SDL_QuitSubSystem(SDL_INIT_EVENTS); #endif @@ -479,7 +479,7 @@ int SDL_PrivateSensorUpdate(SDL_Sensor *sensor, Uint64 timestamp_us, float *data /* Post the event, if desired */ posted = 0; -#if !SDL_EVENTS_DISABLED +#ifndef SDL_EVENTS_DISABLED if (SDL_GetEventState(SDL_SENSORUPDATE) == SDL_ENABLE) { SDL_Event event; event.type = SDL_SENSORUPDATE; diff --git a/vs/sdl2/src/sensor/SDL_sensor_c.h b/vs/sdl2/src/sensor/SDL_sensor_c.h index 0c9067b60b..0d2a483199 100644 --- a/vs/sdl2/src/sensor/SDL_sensor_c.h +++ b/vs/sdl2/src/sensor/SDL_sensor_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/SDL_syssensor.h b/vs/sdl2/src/sensor/SDL_syssensor.h index 46ed1ce9aa..8f8196f530 100644 --- a/vs/sdl2/src/sensor/SDL_syssensor.h +++ b/vs/sdl2/src/sensor/SDL_syssensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/android/SDL_androidsensor.c b/vs/sdl2/src/sensor/android/SDL_androidsensor.c index 1b19791847..3f57253cd1 100644 --- a/vs/sdl2/src/sensor/android/SDL_androidsensor.c +++ b/vs/sdl2/src/sensor/android/SDL_androidsensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +54,14 @@ static int SDL_ANDROID_SensorInit(void) ASensorList sensors; SDL_sensor_manager = ASensorManager_getInstance(); - if (SDL_sensor_manager == NULL) { + if (!SDL_sensor_manager) { return SDL_SetError("Couldn't create sensor manager"); } SDL_sensor_looper = ALooper_forThread(); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { return SDL_SetError("Couldn't create sensor event loop"); } } @@ -70,7 +70,7 @@ static int SDL_ANDROID_SensorInit(void) sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors); if (sensors_count > 0) { SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } @@ -125,7 +125,7 @@ static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) int delay_us, min_delay_us; hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/sensor/android/SDL_androidsensor.h b/vs/sdl2/src/sensor/android/SDL_androidsensor.h index 64a497b46a..5a119dbf5f 100644 --- a/vs/sdl2/src/sensor/android/SDL_androidsensor.h +++ b/vs/sdl2/src/sensor/android/SDL_androidsensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.h b/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.h index befacdd9df..ae48163eb7 100644 --- a/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.h +++ b/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.m b/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.m index a8bfe3a6b4..c653c9bb9e 100644 --- a/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.m +++ b/vs/sdl2/src/sensor/coremotion/SDL_coremotionsensor.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/dummy/SDL_dummysensor.c b/vs/sdl2/src/sensor/dummy/SDL_dummysensor.c index a3983e4e16..b8840d8747 100644 --- a/vs/sdl2/src/sensor/dummy/SDL_dummysensor.c +++ b/vs/sdl2/src/sensor/dummy/SDL_dummysensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/dummy/SDL_dummysensor.h b/vs/sdl2/src/sensor/dummy/SDL_dummysensor.h index bdde5f23b0..e8bf8ef248 100644 --- a/vs/sdl2/src/sensor/dummy/SDL_dummysensor.h +++ b/vs/sdl2/src/sensor/dummy/SDL_dummysensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/n3ds/SDL_n3dssensor.c b/vs/sdl2/src/sensor/n3ds/SDL_n3dssensor.c index 26647582e5..236b64803d 100644 --- a/vs/sdl2/src/sensor/n3ds/SDL_n3dssensor.c +++ b/vs/sdl2/src/sensor/n3ds/SDL_n3dssensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/vita/SDL_vitasensor.c b/vs/sdl2/src/sensor/vita/SDL_vitasensor.c index 6513f9e081..8ff68ddf35 100644 --- a/vs/sdl2/src/sensor/vita/SDL_vitasensor.c +++ b/vs/sdl2/src/sensor/vita/SDL_vitasensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +54,7 @@ static int SDL_VITA_SensorInit(void) SDL_sensors_count = 2; SDL_sensors = (SDL_VitaSensor *)SDL_calloc(SDL_sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } @@ -121,7 +121,7 @@ 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) { + if (!hwdata) { return SDL_OutOfMemory(); } sensor->hwdata = hwdata; diff --git a/vs/sdl2/src/sensor/vita/SDL_vitasensor.h b/vs/sdl2/src/sensor/vita/SDL_vitasensor.h index a0f6555135..183c35a8b5 100644 --- a/vs/sdl2/src/sensor/vita/SDL_vitasensor.h +++ b/vs/sdl2/src/sensor/vita/SDL_vitasensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/sensor/windows/SDL_windowssensor.c b/vs/sdl2/src/sensor/windows/SDL_windowssensor.c index 29195a03ae..cba5b17699 100644 --- a/vs/sdl2/src/sensor/windows/SDL_windowssensor.c +++ b/vs/sdl2/src/sensor/windows/SDL_windowssensor.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static int DisconnectSensor(ISensor *sensor); static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensorManagerEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -107,7 +107,7 @@ static ISensorManagerEvents sensor_manager_events = { static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -286,13 +286,13 @@ static int ConnectSensor(ISensor *sensor) if (bstr_name != NULL) { SysFreeString(bstr_name); } - if (name == NULL) { + if (!name) { return SDL_OutOfMemory(); } SDL_LockSensors(); new_sensors = (SDL_Windows_Sensor *)SDL_realloc(SDL_sensors, (SDL_num_sensors + 1) * sizeof(SDL_Windows_Sensor)); - if (new_sensors == NULL) { + if (!new_sensors) { SDL_UnlockSensors(); SDL_free(name); return SDL_OutOfMemory(); diff --git a/vs/sdl2/src/sensor/windows/SDL_windowssensor.h b/vs/sdl2/src/sensor/windows/SDL_windowssensor.h index bdde5f23b0..e8bf8ef248 100644 --- a/vs/sdl2/src/sensor/windows/SDL_windowssensor.h +++ b/vs/sdl2/src/sensor/windows/SDL_windowssensor.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_crc16.c b/vs/sdl2/src/stdlib/SDL_crc16.c index f37c2d1c61..d1270f1f12 100644 --- a/vs/sdl2/src/stdlib/SDL_crc16.c +++ b/vs/sdl2/src/stdlib/SDL_crc16.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_crc32.c b/vs/sdl2/src/stdlib/SDL_crc32.c index f28b863acf..ad6eed3262 100644 --- a/vs/sdl2/src/stdlib/SDL_crc32.c +++ b/vs/sdl2/src/stdlib/SDL_crc32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_getenv.c b/vs/sdl2/src/stdlib/SDL_getenv.c index 466867ac86..13cf5a39f5 100644 --- a/vs/sdl2/src/stdlib/SDL_getenv.c +++ b/vs/sdl2/src/stdlib/SDL_getenv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ static size_t SDL_envmemlen = 0; int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -57,7 +57,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -79,7 +79,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -94,7 +94,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* This leaks. Sorry. Get a better OS so we don't have to do this. */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -111,7 +111,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -123,7 +123,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* Allocate memory for the variable */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -176,7 +176,7 @@ char *SDL_getenv(const char *name) #endif /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -188,7 +188,7 @@ char *SDL_getenv(const char *name) size_t bufferlen; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -199,7 +199,7 @@ char *SDL_getenv(const char *name) } if (bufferlen > SDL_envmemlen) { char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); - if (newmem == NULL) { + if (!newmem) { return NULL; } SDL_envmem = newmem; @@ -215,14 +215,14 @@ char *SDL_getenv(const char *name) char *value; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } value = (char *)0; if (SDL_env) { len = SDL_strlen(name); - for (i = 0; SDL_env[i] && value == NULL; ++i) { + for (i = 0; SDL_env[i] && !value; ++i) { if ((SDL_strncmp(SDL_env[i], name, len) == 0) && (SDL_env[i][len] == '=')) { value = &SDL_env[i][len + 1]; diff --git a/vs/sdl2/src/stdlib/SDL_iconv.c b/vs/sdl2/src/stdlib/SDL_iconv.c index 9448afcf58..416e199b76 100644 --- a/vs/sdl2/src/stdlib/SDL_iconv.c +++ b/vs/sdl2/src/stdlib/SDL_iconv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_endian.h" #if defined(HAVE_ICONV) && defined(HAVE_ICONV_H) -#ifdef __FreeBSD__ +#ifndef SDL_USE_LIBICONV /* Define LIBICONV_PLUG to use iconv from the base instead of ports and avoid linker errors. */ #define LIBICONV_PLUG 1 #endif @@ -166,28 +166,28 @@ static const char *getlocale(char *buffer, size_t bufsize) char *ptr; lang = SDL_getenv("LC_ALL"); - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_CTYPE"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_MESSAGES"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LANG"); } - if (lang == NULL || !*lang || SDL_strcmp(lang, "C") == 0) { + if (!lang || !*lang || SDL_strcmp(lang, "C") == 0) { lang = "ASCII"; } /* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */ ptr = SDL_strchr(lang, '.'); - if (ptr != NULL) { + if (ptr) { lang = ptr + 1; } SDL_strlcpy(buffer, lang, bufsize); ptr = SDL_strchr(buffer, '@'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; /* chop end of string. */ } @@ -202,10 +202,10 @@ SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode) char fromcode_buffer[64]; char tocode_buffer[64]; - if (fromcode == NULL || !*fromcode) { + if (!fromcode || !*fromcode) { fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer)); } - if (tocode == NULL || !*tocode) { + if (!tocode || !*tocode) { tocode = getlocale(tocode_buffer, sizeof(tocode_buffer)); } for (i = 0; i < SDL_arraysize(encodings); ++i) { @@ -245,11 +245,11 @@ SDL_iconv(SDL_iconv_t cd, Uint32 ch = 0; size_t total; - if (inbuf == NULL || !*inbuf) { + if (!inbuf || !*inbuf) { /* Reset the context */ return 0; } - if (outbuf == NULL || !*outbuf || outbytesleft == NULL || !*outbytesleft) { + if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) { return SDL_ICONV_E2BIG; } src = *inbuf; @@ -795,30 +795,26 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb size_t outbytesleft; size_t retCode = 0; - cd = SDL_iconv_open(tocode, fromcode); - if (cd == (SDL_iconv_t)-1) { - /* See if we can recover here (fixes iconv on Solaris 11) */ - if (tocode == NULL || !*tocode) { - tocode = "UTF-8"; - } - if (fromcode == NULL || !*fromcode) { - fromcode = "UTF-8"; - } - cd = SDL_iconv_open(tocode, fromcode); + if (!tocode || !*tocode) { + tocode = "UTF-8"; + } + if (!fromcode || !*fromcode) { + fromcode = "UTF-8"; } + cd = SDL_iconv_open(tocode, fromcode); if (cd == (SDL_iconv_t)-1) { return NULL; } - stringsize = inbytesleft > 4 ? inbytesleft : 4; - string = (char *)SDL_malloc(stringsize + 1); - if (string == NULL) { + stringsize = inbytesleft; + string = (char *)SDL_malloc(stringsize + sizeof(Uint32)); + if (!string) { SDL_iconv_close(cd); return NULL; } outbuf = string; outbytesleft = stringsize; - SDL_memset(outbuf, 0, 4); + SDL_memset(outbuf, 0, sizeof(Uint32)); while (inbytesleft > 0) { const size_t oldinbytesleft = inbytesleft; @@ -826,17 +822,18 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb switch (retCode) { case SDL_ICONV_E2BIG: { + const ptrdiff_t diff = (ptrdiff_t) (outbuf - string); char *oldstring = string; stringsize *= 2; - string = (char *)SDL_realloc(string, stringsize + 1); - if (string == NULL) { + string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32)); + if (!string) { SDL_free(oldstring); SDL_iconv_close(cd); return NULL; } - outbuf = string + (outbuf - oldstring); - outbytesleft = stringsize - (outbuf - string); - SDL_memset(outbuf, 0, 4); + outbuf = string + diff; + outbytesleft = stringsize - diff; + SDL_memset(outbuf, 0, sizeof(Uint32)); continue; } case SDL_ICONV_EILSEQ: @@ -855,7 +852,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb break; } } - *outbuf = '\0'; + SDL_memset(outbuf, 0, sizeof(Uint32)); SDL_iconv_close(cd); return string; diff --git a/vs/sdl2/src/stdlib/SDL_malloc.c b/vs/sdl2/src/stdlib/SDL_malloc.c index c1aa44414d..4c266611ba 100644 --- a/vs/sdl2/src/stdlib/SDL_malloc.c +++ b/vs/sdl2/src/stdlib/SDL_malloc.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -405,9 +405,9 @@ MALLINFO_FIELD_TYPE default: size_t size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set REALLOC_ZERO_BYTES_FREES default: not defined - This should be set if a call to realloc with zero bytes should - be the same as a call to free. Some people think it should. Otherwise, - since this malloc returns a unique pointer for malloc(0), so does + This should be set if a call to realloc with zero bytes should + be the same as a call to free. Some people think it should. Otherwise, + since this malloc returns a unique pointer for malloc(0), so does realloc(p, 0). LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H @@ -2263,7 +2263,7 @@ static void reset_on_error(mstate m); /* -------------------------- Debugging setup ---------------------------- */ -#if ! DEBUG +#ifndef DEBUG #define check_free_chunk(M,P) #define check_inuse_chunk(M,P) @@ -2627,7 +2627,7 @@ static int change_mparam(int param_number, int value) { } } -#if DEBUG +#ifdef DEBUG /* ------------------------- Debugging Support --------------------------- */ /* Check properties of any chunk, whether free, inuse, mmapped etc */ @@ -3583,7 +3583,7 @@ static void* sys_alloc(mstate m, size_t nb) { m->seg.sflags = mmap_flag; m->magic = mparams.magic; init_bins(m); - if (is_global(m)) + if (is_global(m)) init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); else { /* Offset top by embedded malloc_state */ @@ -3734,7 +3734,7 @@ static int sys_trim(mstate m, size_t pad) { } /* Unmap any unused mmapped segments */ - if (HAVE_MMAP) + if (HAVE_MMAP) released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ @@ -3942,7 +3942,7 @@ static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { while (a < alignment) a <<= 1; alignment = a; } - + if (bytes >= MAX_REQUEST - alignment) { if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; @@ -4125,7 +4125,7 @@ static void** ialloc(mstate m, } } -#if DEBUG +#ifdef DEBUG if (marray != chunks) { /* final element must have exactly exhausted chunk */ if (element_size != 0) { @@ -5187,7 +5187,7 @@ int mspace_mallopt(int param_number, int value) { Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) - + */ #endif /* !HAVE_MALLOC */ diff --git a/vs/sdl2/src/stdlib/SDL_mslibc.c b/vs/sdl2/src/stdlib/SDL_mslibc.c index 677f40111f..3b3e7e2761 100644 --- a/vs/sdl2/src/stdlib/SDL_mslibc.c +++ b/vs/sdl2/src/stdlib/SDL_mslibc.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_qsort.c b/vs/sdl2/src/stdlib/SDL_qsort.c index 5d1c7ef940..d1375ec40d 100644 --- a/vs/sdl2/src/stdlib/SDL_qsort.c +++ b/vs/sdl2/src/stdlib/SDL_qsort.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +28,11 @@ #include "SDL_stdinc.h" #if defined(HAVE_QSORT) -void SDL_qsort(void *base, size_t nmemb, size_t size, int (*compare) (const void *, const void *)) +void SDL_qsort(void *base, size_t nmemb, size_t size, int (SDLCALL *compare) (const void *, const void *)) { + if (!base) { + return; + } qsort(base, nmemb, size, compare); } @@ -365,7 +368,7 @@ typedef struct { char * first; char * last; } stack_entry; /* ---------------------------------------------------------------------- */ static char * pivot_big(char *first, char *mid, char *last, size_t size, - int compare(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { size_t d=(((last-first)/size)>>3)*size; #ifdef DEBUG_QSORT fprintf(stderr, "pivot_big: first=%p last=%p size=%lu n=%lu\n", first, (unsigned long)last, size, (unsigned long)((last-first+1)/size)); @@ -406,7 +409,7 @@ fprintf(stderr,"-> %d %d %d @ %p %p %p\n",*(int*)m1,*(int*)m2,*(int*)m3, m1,m2,m /* ---------------------------------------------------------------------- */ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -437,7 +440,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, } static void qsort_aligned(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -468,7 +471,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, } static void qsort_words(void *base, size_t nmemb, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { stack_entry stack[STACK_SIZE]; int stacktop=0; @@ -520,7 +523,7 @@ fprintf(stderr, "after partitioning first=#%lu last=#%lu\n", (first-(char*)base) /* ---------------------------------------------------------------------- */ extern void qsortG(void *base, size_t nmemb, size_t size, - int (*compare)(const void *, const void *)) { + int (SDLCALL * compare)(const void *, const void *)) { if (nmemb<=1) return; if (((size_t)base|size)&(WORD_BYTES-1)) @@ -533,7 +536,7 @@ extern void qsortG(void *base, size_t nmemb, size_t size, #endif /* HAVE_QSORT */ -void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (*compare)(const void *, const void *)) +void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, int (SDLCALL * compare)(const void *, const void *)) { #if defined(HAVE_BSEARCH) return bsearch(key, base, nmemb, size, compare); @@ -566,4 +569,3 @@ void *SDL_bsearch(const void *key, const void *base, size_t nmemb, size_t size, } /* vi: set ts=4 sw=4 expandtab: */ - diff --git a/vs/sdl2/src/stdlib/SDL_stdlib.c b/vs/sdl2/src/stdlib/SDL_stdlib.c index 8c9d196ac2..a90f09f7c1 100644 --- a/vs/sdl2/src/stdlib/SDL_stdlib.c +++ b/vs/sdl2/src/stdlib/SDL_stdlib.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_string.c b/vs/sdl2/src/stdlib/SDL_string.c index 616e3e125e..b66163ce6e 100644 --- a/vs/sdl2/src/stdlib/SDL_string.c +++ b/vs/sdl2/src/stdlib/SDL_string.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1114,12 +1114,45 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) return vsscanf(text, fmt, ap); } #else +static SDL_bool CharacterMatchesSet(char c, const char *set, size_t set_len) +{ + SDL_bool invert = SDL_FALSE; + SDL_bool result = SDL_FALSE; + + if (*set == '^') { + invert = SDL_TRUE; + ++set; + --set_len; + } + while (set_len > 0 && !result) { + if (set_len >= 3 && set[1] == '-') { + char low_char = SDL_min(set[0], set[2]); + char high_char = SDL_max(set[0], set[2]); + if (c >= low_char && c <= high_char) { + result = SDL_TRUE; + } + set += 3; + set_len -= 3; + } else { + if (c == *set) { + result = SDL_TRUE; + } + ++set; + --set_len; + } + } + if (invert) { + result = result ? SDL_FALSE : SDL_TRUE; + } + return result; +} + /* NOLINTNEXTLINE(readability-non-const-parameter) */ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { int retval = 0; - if (text == NULL || !*text) { + if (!text || !*text) { return -1; } @@ -1190,7 +1223,9 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) suppress = SDL_TRUE; break; case 'h': - if (inttype > DO_SHORT) { + if (inttype == DO_INT) { + inttype = DO_SHORT; + } else if (inttype > DO_SHORT) { ++inttype; } break; @@ -1385,6 +1420,44 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) } done = SDL_TRUE; break; + case '[': + { + const char *set = fmt + 1; + while (*fmt && *fmt != ']') { + ++fmt; + } + if (*fmt) { + size_t set_len = (fmt - set); + if (suppress) { + while (CharacterMatchesSet(*text, set, set_len)) { + ++text; + if (count) { + if (--count == 0) { + break; + } + } + } + } else { + SDL_bool had_match = SDL_FALSE; + char *valuep = va_arg(ap, char *); + while (CharacterMatchesSet(*text, set, set_len)) { + had_match = SDL_TRUE; + *valuep++ = *text++; + if (count) { + if (--count == 0) { + break; + } + } + } + *valuep = '\0'; + if (had_match) { + ++retval; + } + } + } + } + done = SDL_TRUE; + break; default: done = SDL_TRUE; break; @@ -1471,7 +1544,7 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c size_t length = 0; size_t slen, sz; - if (string == NULL) { + if (!string) { string = "(null)"; } @@ -1531,7 +1604,7 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf { /* left-pad num with zeroes. */ size_t sz, pad, have_sign; - if (info == NULL) { + if (!info) { return; } @@ -1662,6 +1735,20 @@ static size_t SDL_PrintFloat(char *text, size_t maxlen, SDL_FormatInfo *info, do return length; } +static size_t SDL_PrintPointer(char *text, size_t maxlen, SDL_FormatInfo *info, const void *value) +{ + char num[130]; + size_t length; + + if (!value) { + return SDL_PrintString(text, maxlen, info, NULL); + } + + SDL_ulltoa((unsigned long long)(uintptr_t)value, num, 16); + length = SDL_PrintString(text, maxlen, info, "0x"); + return length + SDL_PrintString(TEXT_AND_LEN_ARGS, info, num); +} + /* NOLINTNEXTLINE(readability-non-const-parameter) */ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *fmt, va_list ap) { @@ -1794,6 +1881,10 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *f done = SDL_TRUE; break; case 'p': + info.force_case = SDL_CASE_LOWER; + length += SDL_PrintPointer(TEXT_AND_LEN_ARGS, &info, va_arg(ap, void *)); + done = SDL_TRUE; + break; case 'x': info.force_case = SDL_CASE_LOWER; SDL_FALLTHROUGH; @@ -1804,9 +1895,6 @@ int SDL_vsnprintf(SDL_OUT_Z_CAP(maxlen) char *text, size_t maxlen, const char *f if (info.radix == 10) { info.radix = 16; } - if (*fmt == 'p') { - inttype = DO_LONG; - } SDL_FALLTHROUGH; case 'o': if (info.radix == 10) { @@ -1904,7 +1992,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) *strp = NULL; p = (char *)SDL_malloc(size); - if (p == NULL) { + if (!p) { return -1; } @@ -1916,6 +2004,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) /* Check error code */ if (retval < 0) { + SDL_free(p); return retval; } @@ -1929,7 +2018,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) size = retval + 1; /* Precisely what is needed */ np = (char *)SDL_realloc(p, size); - if (np == NULL) { + if (!np) { SDL_free(p); return -1; } else { @@ -1937,5 +2026,3 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) } } } - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/stdlib/SDL_strtokr.c b/vs/sdl2/src/stdlib/SDL_strtokr.c index edd6005f54..38dc83029a 100644 --- a/vs/sdl2/src/stdlib/SDL_strtokr.c +++ b/vs/sdl2/src/stdlib/SDL_strtokr.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/stdlib/SDL_vacopy.h b/vs/sdl2/src/stdlib/SDL_vacopy.h index dd08a3fb40..ee45bf6318 100644 --- a/vs/sdl2/src/stdlib/SDL_vacopy.h +++ b/vs/sdl2/src/stdlib/SDL_vacopy.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/test/SDL_test_assert.c b/vs/sdl2/src/test/SDL_test_assert.c index dc1eb64217..e8d0ff0d18 100644 --- a/vs/sdl2/src/test/SDL_test_assert.c +++ b/vs/sdl2/src/test/SDL_test_assert.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/test/SDL_test_common.c b/vs/sdl2/src/test/SDL_test_common.c index 8781cc5745..04ad51f2ac 100644 --- a/vs/sdl2/src/test/SDL_test_common.c +++ b/vs/sdl2/src/test/SDL_test_common.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +72,7 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags) } state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state)); - if (state == NULL) { + if (!state) { SDL_OutOfMemory(); return NULL; } @@ -134,6 +134,7 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index) return -1; } state->videodriver = argv[index]; + SDL_SetHint(SDL_HINT_VIDEODRIVER, state->videodriver); return 2; } if (SDL_strcasecmp(argv[index], "--renderer") == 0) { @@ -591,7 +592,7 @@ void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const static const char *BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2) { char *str = *pstr; - if (str == NULL) { + if (!str) { size_t len = SDL_strlen("[--trackmem]") + 2; int i; for (i = 0; i < numitems; i++) { @@ -603,7 +604,7 @@ static const char *BuildCommonUsageString(char **pstr, const char **strlist, con } } str = (char *)SDL_calloc(1, len); - if (str == NULL) { + if (!str) { return ""; /* oh well. */ } SDL_strlcat(str, "[--trackmem] ", len); @@ -802,6 +803,82 @@ static void SDLTest_PrintWindowFlags(char *text, size_t maxlen, Uint32 flags) } } +static void SDLTest_PrintModStateFlag(char *text, size_t maxlen, SDL_Keymod flag) +{ + switch (flag) { + case KMOD_LSHIFT: + SDL_snprintfcat(text, maxlen, "LSHIFT"); + break; + case KMOD_RSHIFT: + SDL_snprintfcat(text, maxlen, "RSHIFT"); + break; + case KMOD_LCTRL: + SDL_snprintfcat(text, maxlen, "LCTRL"); + break; + case KMOD_RCTRL: + SDL_snprintfcat(text, maxlen, "RCTRL"); + break; + case KMOD_LALT: + SDL_snprintfcat(text, maxlen, "LALT"); + break; + case KMOD_RALT: + SDL_snprintfcat(text, maxlen, "RALT"); + break; + case KMOD_LGUI: + SDL_snprintfcat(text, maxlen, "LGUI"); + break; + case KMOD_RGUI: + SDL_snprintfcat(text, maxlen, "RGUI"); + break; + case KMOD_NUM: + SDL_snprintfcat(text, maxlen, "NUM"); + break; + case KMOD_CAPS: + SDL_snprintfcat(text, maxlen, "CAPS"); + break; + case KMOD_MODE: + SDL_snprintfcat(text, maxlen, "MODE"); + break; + case KMOD_SCROLL: + SDL_snprintfcat(text, maxlen, "SCROLL"); + break; + default: + SDL_snprintfcat(text, maxlen, "0x%8.8x", (unsigned int) flag); + break; + } +} + +static void SDLTest_PrintModState(char *text, size_t maxlen, SDL_Keymod keymod) +{ + const SDL_Keymod kmod_flags[] = { + KMOD_LSHIFT, + KMOD_RSHIFT, + KMOD_LCTRL, + KMOD_RCTRL, + KMOD_LALT, + KMOD_RALT, + KMOD_LGUI, + KMOD_RGUI, + KMOD_NUM, + KMOD_CAPS, + KMOD_MODE, + KMOD_SCROLL + }; + + int i; + int count = 0; + for (i = 0; i < SDL_arraysize(kmod_flags); ++i) { + const SDL_Keymod flag = kmod_flags[i]; + if ((keymod & flag) == flag) { + if (count > 0) { + SDL_snprintfcat(text, maxlen, " | "); + } + SDLTest_PrintModStateFlag(text, maxlen, flag); + ++count; + } + } +} + static void SDLTest_PrintButtonMask(char *text, size_t maxlen, Uint32 flags) { int i; @@ -851,6 +928,12 @@ static void SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format) case SDL_PIXELFORMAT_INDEX1MSB: SDL_snprintfcat(text, maxlen, "Index1MSB"); break; + case SDL_PIXELFORMAT_INDEX2LSB: + SDL_snprintfcat(text, maxlen, "Index2LSB"); + break; + case SDL_PIXELFORMAT_INDEX2MSB: + SDL_snprintfcat(text, maxlen, "Index2MSB"); + break; case SDL_PIXELFORMAT_INDEX4LSB: SDL_snprintfcat(text, maxlen, "Index4LSB"); break; @@ -991,7 +1074,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file) /* Load the icon surface */ icon = SDL_LoadBMP(file); - if (icon == NULL) { + if (!icon) { SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError()); return NULL; } @@ -1120,7 +1203,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state) SDL_DisplayMode mode; int bpp; Uint32 Rmask, Gmask, Bmask, Amask; -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS int adapterIndex = 0; int outputIndex = 0; #endif @@ -1183,7 +1266,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state) } } -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) /* Print the D3D9 adapter index */ adapterIndex = SDL_Direct3D9GetAdapterIndex(i); SDL_Log("D3D9 Adapter Index: %d", adapterIndex); @@ -1511,11 +1594,10 @@ static void SDLTest_PrintEvent(SDL_Event *event) SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " restored", event->window.windowID); break; case SDL_WINDOWEVENT_ENTER: - SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32 "", - event->window.windowID); + SDL_Log("SDL EVENT: Mouse entered window %" SDL_PRIu32, event->window.windowID); break; case SDL_WINDOWEVENT_LEAVE: - SDL_Log("SDL EVENT: Mouse left window %" SDL_PRIu32 "", 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 %" SDL_PRIu32 " gained keyboard focus", @@ -1538,7 +1620,7 @@ static void SDLTest_PrintEvent(SDL_Event *event) SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " ICC profile changed", event->window.windowID); break; case SDL_WINDOWEVENT_DISPLAY_CHANGED: - SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32 "", event->window.windowID, event->window.data1); + SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " display changed to %" SDL_PRIs32, event->window.windowID, event->window.data1); break; default: SDL_Log("SDL EVENT: Window %" SDL_PRIu32 " got unknown event 0x%4.4x", @@ -1547,19 +1629,23 @@ static void SDLTest_PrintEvent(SDL_Event *event) } break; case SDL_KEYDOWN: - 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 %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s", + case SDL_KEYUP: { + char modstr[64]; + if (event->key.keysym.mod) { + modstr[0] = '\0'; + SDLTest_PrintModState(modstr, sizeof (modstr), event->key.keysym.mod); + } else { + SDL_strlcpy(modstr, "NONE", sizeof (modstr)); + } + SDL_Log("SDL EVENT: Keyboard: key %s in window %" SDL_PRIu32 ": scancode 0x%08X = %s, keycode 0x%08" SDL_PRIX32 " = %s, mods = %s", + (event->type == SDL_KEYDOWN) ? "pressed" : "released", event->key.windowID, event->key.keysym.scancode, SDL_GetScancodeName(event->key.keysym.scancode), - event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym)); + event->key.keysym.sym, SDL_GetKeyName(event->key.keysym.sym), + modstr); break; + } case SDL_TEXTEDITING: SDL_Log("SDL EVENT: Keyboard: text editing \"%s\" in window %" SDL_PRIu32, event->edit.text, event->edit.windowID); @@ -1756,7 +1842,7 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer) SDL_Rect viewport; SDL_Surface *surface; - if (renderer == NULL) { + if (!renderer) { return; } @@ -1768,7 +1854,7 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer) 0x000000FF, 0x0000FF00, 0x00FF0000, #endif 0x00000000); - if (surface == NULL) { + if (!surface) { SDL_Log("Couldn't create surface: %s\n", SDL_GetError()); return; } @@ -1792,7 +1878,7 @@ static void FullscreenTo(int index, int windowId) Uint32 flags; struct SDL_Rect rect = { 0, 0, 0, 0 }; SDL_Window *window = SDL_GetWindowFromID(windowId); - if (window == NULL) { + if (!window) { return; } @@ -2394,6 +2480,19 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, in SDLTest_DrawString(renderer, 0, textY, text); textY += lineHeight; + /* Keyboard */ + + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDLTest_DrawString(renderer, 0, textY, "-- Keyboard --"); + textY += lineHeight; + + SDL_SetRenderDrawColor(renderer, 170, 170, 170, 255); + + (void)SDL_snprintf(text, sizeof(text), "SDL_GetModState: "); + SDLTest_PrintModState(text, sizeof(text), SDL_GetModState()); + SDLTest_DrawString(renderer, 0, textY, text); + textY += lineHeight; + if (usedHeight) { *usedHeight = textY; } diff --git a/vs/sdl2/src/test/SDL_test_compare.c b/vs/sdl2/src/test/SDL_test_compare.c index 9c4adf2192..ba532c7f34 100644 --- a/vs/sdl2/src/test/SDL_test_compare.c +++ b/vs/sdl2/src/test/SDL_test_compare.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,25 @@ /* Counter for _CompareSurface calls; used for filename creation when comparisons fail */ static int _CompareSurfaceCount = 0; +static Uint32 +GetPixel(Uint8 *p, size_t bytes_per_pixel) +{ + Uint32 ret = 0; + + SDL_assert(bytes_per_pixel <= sizeof(ret)); + + /* Fill the appropriate number of least-significant bytes of ret, + * leaving the most-significant bytes set to zero, so that ret can + * be decoded with SDL_GetRGBA afterwards. */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_memcpy(((Uint8 *) &ret) + (sizeof(ret) - bytes_per_pixel), p, bytes_per_pixel); +#else + SDL_memcpy(&ret, p, bytes_per_pixel); +#endif + + return ret; +} + /* Compare surfaces */ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, int allowable_error) { @@ -51,7 +70,7 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, char referenceFilename[FILENAME_SIZE]; /* Validate input surfaces */ - if (surface == NULL || referenceSurface == NULL) { + if (!surface || !referenceSurface) { return -1; } @@ -74,11 +93,14 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, /* Compare image - should be same format. */ for (j = 0; j < surface->h; j++) { for (i = 0; i < surface->w; i++) { + Uint32 pixel; p = (Uint8 *)surface->pixels + j * surface->pitch + i * bpp; p_reference = (Uint8 *)referenceSurface->pixels + j * referenceSurface->pitch + i * bpp_reference; - SDL_GetRGBA(*(Uint32 *)p, surface->format, &R, &G, &B, &A); - SDL_GetRGBA(*(Uint32 *)p_reference, referenceSurface->format, &Rd, &Gd, &Bd, &Ad); + pixel = GetPixel(p, bpp); + SDL_GetRGBA(pixel, surface->format, &R, &G, &B, &A); + pixel = GetPixel(p_reference, bpp_reference); + SDL_GetRGBA(pixel, referenceSurface->format, &Rd, &Gd, &Bd, &Ad); dist = 0; dist += (R - Rd) * (R - Rd); diff --git a/vs/sdl2/src/test/SDL_test_crc32.c b/vs/sdl2/src/test/SDL_test_crc32.c index 453124b07f..b13839b584 100644 --- a/vs/sdl2/src/test/SDL_test_crc32.c +++ b/vs/sdl2/src/test/SDL_test_crc32.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext) CrcUint32 c; /* Sanity check context pointer */ - if (crcContext == NULL) { + if (!crcContext) { return -1; } @@ -90,7 +90,7 @@ int SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { /* Sanity check pointers */ - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } @@ -108,7 +108,7 @@ int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { /* Sanity check pointers */ - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } @@ -128,12 +128,12 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C CrcUint8 *p; register CrcUint32 crc; - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } - if (inBuf == NULL) { + if (!inBuf) { return -1; } @@ -155,7 +155,7 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C int SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext) { - if (crcContext == NULL) { + if (!crcContext) { return -1; } diff --git a/vs/sdl2/src/test/SDL_test_font.c b/vs/sdl2/src/test/SDL_test_font.c index d3bdad6dd4..ffa3dde82c 100644 --- a/vs/sdl2/src/test/SDL_test_font.c +++ b/vs/sdl2/src/test/SDL_test_font.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -3166,14 +3166,14 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c) ci = c; /* Search for this renderer's cache */ - for (cache = SDLTest_CharTextureCacheList; cache != NULL; cache = cache->next) { + for (cache = SDLTest_CharTextureCacheList; cache; cache = cache->next) { if (cache->renderer == renderer) { break; } } /* Allocate a new cache for this renderer if needed */ - if (cache == NULL) { + if (!cache) { cache = (struct SDLTest_CharTextureCache *)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache)); cache->renderer = renderer; cache->next = SDLTest_CharTextureCacheList; @@ -3190,7 +3190,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c) character = SDL_CreateRGBSurface(SDL_SWSURFACE, charWidth, charHeight, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - if (character == NULL) { + if (!character) { return -1; } @@ -3358,7 +3358,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(int x, int y, int w, int h) { SDLTest_TextWindow *textwin = (SDLTest_TextWindow *)SDL_malloc(sizeof(*textwin)); - if (textwin == NULL) { + if (!textwin) { return NULL; } diff --git a/vs/sdl2/src/test/SDL_test_fuzzer.c b/vs/sdl2/src/test/SDL_test_fuzzer.c index b59cbb32dc..a04eee05ed 100644 --- a/vs/sdl2/src/test/SDL_test_fuzzer.c +++ b/vs/sdl2/src/test/SDL_test_fuzzer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -471,7 +471,9 @@ char *SDLTest_RandomAsciiStringWithMaximumLength(int maxLength) } size = (SDLTest_RandomUint32() % (maxLength + 1)); - + if (size == 0) { + size = 1; + } return SDLTest_RandomAsciiStringOfSize(size); } @@ -486,7 +488,7 @@ char *SDLTest_RandomAsciiStringOfSize(int size) } string = (char *)SDL_malloc((size + 1) * sizeof(char)); - if (string == NULL) { + if (!string) { return NULL; } diff --git a/vs/sdl2/src/test/SDL_test_harness.c b/vs/sdl2/src/test/SDL_test_harness.c index 6141513024..460e694f8c 100644 --- a/vs/sdl2/src/test/SDL_test_harness.c +++ b/vs/sdl2/src/test/SDL_test_harness.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ char *SDLTest_GenerateRunSeed(const int length) /* Allocate output buffer */ seed = (char *)SDL_malloc((length + 1) * sizeof(char)); - if (seed == NULL) { + if (!seed) { SDLTest_LogError("SDL_malloc for run seed output buffer failed."); SDL_Error(SDL_ENOMEM); return NULL; @@ -108,17 +108,17 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName size_t entireStringLength; char *buffer; - if (runSeed == NULL || runSeed[0] == '\0') { + if (!runSeed || runSeed[0] == '\0') { SDLTest_LogError("Invalid runSeed string."); return -1; } - if (suiteName == NULL || suiteName[0] == '\0') { + if (!suiteName || suiteName[0] == '\0') { SDLTest_LogError("Invalid suiteName string."); return -1; } - if (testName == NULL || testName[0] == '\0') { + if (!testName || testName[0] == '\0') { SDLTest_LogError("Invalid testName string."); return -1; } @@ -139,7 +139,7 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName iterationStringLength = SDL_strlen(iterationString); entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; buffer = (char *)SDL_malloc(entireStringLength); - if (buffer == NULL) { + if (!buffer) { SDLTest_LogError("Failed to allocate buffer for execKey generation."); SDL_Error(SDL_ENOMEM); return 0; @@ -171,7 +171,7 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, void(SDLCALL *callback)(v Uint32 timeoutInMilliseconds; SDL_TimerID timerID; - if (callback == NULL) { + if (!callback) { SDLTest_LogError("Timeout callback can't be NULL"); return -1; } @@ -229,7 +229,7 @@ static int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_ int testResult = 0; int fuzzerCount; - if (testSuite == NULL || testCase == NULL || testSuite->name == NULL || testCase->name == NULL) { + if (!testSuite || !testCase || !testSuite->name || !testCase->name) { SDLTest_LogError("Setup failure: testSuite or testCase references NULL"); return TEST_RESULT_SETUP_FAILURE; } @@ -402,9 +402,9 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user } /* Generate run see if we don't have one already */ - if (userRunSeed == NULL || userRunSeed[0] == '\0') { + if (!userRunSeed || userRunSeed[0] == '\0') { char *tmp = SDLTest_GenerateRunSeed(16); - if (tmp == NULL) { + if (!tmp) { SDLTest_LogError("Generating a random seed failed"); return 2; } @@ -445,20 +445,20 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Pre-allocate an array for tracking failed tests (potentially all test cases) */ failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *)); - if (failedTests == NULL) { + if (!failedTests) { SDLTest_LogError("Unable to allocate cache for failed tests"); SDL_Error(SDL_ENOMEM); return -1; } /* Initialize filtering */ - if (filter != NULL && filter[0] != '\0') { + if (filter && filter[0] != '\0') { /* Loop over all suites to check if we have a filter match */ suiteCounter = 0; while (testSuites[suiteCounter] && suiteFilter == 0) { testSuite = testSuites[suiteCounter]; suiteCounter++; - if (testSuite->name != NULL && SDL_strcasecmp(filter, testSuite->name) == 0) { + if (testSuite->name && SDL_strcasecmp(filter, testSuite->name) == 0) { /* Matched a suite name */ suiteFilter = 1; suiteFilterName = testSuite->name; @@ -471,7 +471,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user while (testSuite->testCases[testCounter] && testFilter == 0) { testCase = testSuite->testCases[testCounter]; testCounter++; - if (testCase->name != NULL && SDL_strcasecmp(filter, testCase->name) == 0) { + if (testCase->name && SDL_strcasecmp(filter, testCase->name) == 0) { /* Matched a test name */ suiteFilter = 1; suiteFilterName = testSuite->name; @@ -487,14 +487,14 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter); for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) { testSuite = testSuites[suiteCounter]; - if (testSuite->name != NULL) { + if (testSuite->name) { SDLTest_Log("Test suite: %s", testSuite->name); } /* Within each suite, loop over all test cases to check if we have a filter match */ for (testCounter = 0; testSuite->testCases[testCounter]; ++testCounter) { testCase = testSuite->testCases[testCounter]; - SDLTest_Log(" test: %s", testCase->name); + SDLTest_Log(" test: %s%s", testCase->name, testCase->enabled ? "" : " (disabled)"); } } SDLTest_Log("Exit code: 2"); @@ -511,7 +511,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter++; /* Filter suite if flag set and we have a name */ - if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL && + if (suiteFilter == 1 && suiteFilterName && testSuite->name && SDL_strcasecmp(suiteFilterName, testSuite->name) != 0) { /* Skip suite */ SDLTest_Log("===== Test Suite %i: '%s' skipped\n", @@ -540,7 +540,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user testCounter++; /* Filter tests if flag set and we have a name */ - if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL && + if (testFilter == 1 && testFilterName && testCase->name && SDL_strcasecmp(testFilterName, testCase->name) != 0) { /* Skip test */ SDLTest_Log("===== Test Case %i.%i: '%s' skipped\n", @@ -562,7 +562,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter, testCounter, currentTestName); - if (testCase->description != NULL && testCase->description[0] != '\0') { + if (testCase->description && testCase->description[0] != '\0') { SDLTest_Log("Test Description: '%s'", (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT); } diff --git a/vs/sdl2/src/test/SDL_test_imageBlit.c b/vs/sdl2/src/test/SDL_test_imageBlit.c index 0a086708c8..bf1cf2fce2 100644 --- a/vs/sdl2/src/test/SDL_test_imageBlit.c +++ b/vs/sdl2/src/test/SDL_test_imageBlit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -542,24 +542,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = { */ SDL_Surface *SDLTest_ImageBlit() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlit.pixel_data, SDLTest_imageBlit.width, SDLTest_imageBlit.height, SDLTest_imageBlit.bytes_per_pixel * 8, SDLTest_imageBlit.width * SDLTest_imageBlit.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -1027,24 +1016,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = { */ SDL_Surface *SDLTest_ImageBlitColor() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitColor.pixel_data, SDLTest_imageBlitColor.width, SDLTest_imageBlitColor.height, SDLTest_imageBlitColor.bytes_per_pixel * 8, SDLTest_imageBlitColor.width * SDLTest_imageBlitColor.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -1675,24 +1653,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = { */ SDL_Surface *SDLTest_ImageBlitAlpha() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitAlpha.pixel_data, SDLTest_imageBlitAlpha.width, SDLTest_imageBlitAlpha.height, SDLTest_imageBlitAlpha.bytes_per_pixel * 8, SDLTest_imageBlitAlpha.width * SDLTest_imageBlitAlpha.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } diff --git a/vs/sdl2/src/test/SDL_test_imageBlitBlend.c b/vs/sdl2/src/test/SDL_test_imageBlitBlend.c index b0e7e4ae09..520cfffdd0 100644 --- a/vs/sdl2/src/test/SDL_test_imageBlitBlend.c +++ b/vs/sdl2/src/test/SDL_test_imageBlitBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -582,24 +582,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = { */ SDL_Surface *SDLTest_ImageBlitBlendAdd() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitBlendAdd.pixel_data, SDLTest_imageBlitBlendAdd.width, SDLTest_imageBlitBlendAdd.height, SDLTest_imageBlitBlendAdd.bytes_per_pixel * 8, SDLTest_imageBlitBlendAdd.width * SDLTest_imageBlitBlendAdd.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -1184,24 +1173,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = { */ SDL_Surface *SDLTest_ImageBlitBlend() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitBlend.pixel_data, SDLTest_imageBlitBlend.width, SDLTest_imageBlitBlend.height, SDLTest_imageBlitBlend.bytes_per_pixel * 8, SDLTest_imageBlitBlend.width * SDLTest_imageBlitBlend.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -1616,24 +1594,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = { */ SDL_Surface *SDLTest_ImageBlitBlendMod() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitBlendMod.pixel_data, SDLTest_imageBlitBlendMod.width, SDLTest_imageBlitBlendMod.height, SDLTest_imageBlitBlendMod.bytes_per_pixel * 8, SDLTest_imageBlitBlendMod.width * SDLTest_imageBlitBlendMod.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -2431,24 +2398,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = { */ SDL_Surface *SDLTest_ImageBlitBlendNone() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitBlendNone.pixel_data, SDLTest_imageBlitBlendNone.width, SDLTest_imageBlitBlendNone.height, SDLTest_imageBlitBlendNone.bytes_per_pixel * 8, SDLTest_imageBlitBlendNone.width * SDLTest_imageBlitBlendNone.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } @@ -2978,24 +2934,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = { */ SDL_Surface *SDLTest_ImageBlitBlendAll() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageBlitBlendAll.pixel_data, SDLTest_imageBlitBlendAll.width, SDLTest_imageBlitBlendAll.height, SDLTest_imageBlitBlendAll.bytes_per_pixel * 8, SDLTest_imageBlitBlendAll.width * SDLTest_imageBlitBlendAll.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } diff --git a/vs/sdl2/src/test/SDL_test_imageFace.c b/vs/sdl2/src/test/SDL_test_imageFace.c index 0a95e7c872..255acaddee 100644 --- a/vs/sdl2/src/test/SDL_test_imageFace.c +++ b/vs/sdl2/src/test/SDL_test_imageFace.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -225,24 +225,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = { */ SDL_Surface *SDLTest_ImageFace() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imageFace.pixel_data, SDLTest_imageFace.width, SDLTest_imageFace.height, SDLTest_imageFace.bytes_per_pixel * 8, SDLTest_imageFace.width * SDLTest_imageFace.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGBA32); return surface; } diff --git a/vs/sdl2/src/test/SDL_test_imagePrimitives.c b/vs/sdl2/src/test/SDL_test_imagePrimitives.c index 416eb998bc..6ef05c5547 100644 --- a/vs/sdl2/src/test/SDL_test_imagePrimitives.c +++ b/vs/sdl2/src/test/SDL_test_imagePrimitives.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -506,24 +506,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = { */ SDL_Surface *SDLTest_ImagePrimitives() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imagePrimitives.pixel_data, SDLTest_imagePrimitives.width, SDLTest_imagePrimitives.height, SDLTest_imagePrimitives.bytes_per_pixel * 8, SDLTest_imagePrimitives.width * SDLTest_imagePrimitives.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } diff --git a/vs/sdl2/src/test/SDL_test_imagePrimitivesBlend.c b/vs/sdl2/src/test/SDL_test_imagePrimitivesBlend.c index fe65bdc540..8ee9f41775 100644 --- a/vs/sdl2/src/test/SDL_test_imagePrimitivesBlend.c +++ b/vs/sdl2/src/test/SDL_test_imagePrimitivesBlend.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -679,24 +679,13 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = { */ SDL_Surface *SDLTest_ImagePrimitivesBlend() { - SDL_Surface *surface = SDL_CreateRGBSurfaceFrom( + SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom( (void *)SDLTest_imagePrimitivesBlend.pixel_data, SDLTest_imagePrimitivesBlend.width, SDLTest_imagePrimitivesBlend.height, SDLTest_imagePrimitivesBlend.bytes_per_pixel * 8, SDLTest_imagePrimitivesBlend.width * SDLTest_imagePrimitivesBlend.bytes_per_pixel, -#if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - 0xff000000, /* Red bit mask. */ - 0x00ff0000, /* Green bit mask. */ - 0x0000ff00, /* Blue bit mask. */ - 0x000000ff /* Alpha bit mask. */ -#else - 0x000000ff, /* Red bit mask. */ - 0x0000ff00, /* Green bit mask. */ - 0x00ff0000, /* Blue bit mask. */ - 0xff000000 /* Alpha bit mask. */ -#endif - ); + SDL_PIXELFORMAT_RGB24); return surface; } diff --git a/vs/sdl2/src/test/SDL_test_log.c b/vs/sdl2/src/test/SDL_test_log.c index d69e3da2c2..714d307a7d 100644 --- a/vs/sdl2/src/test/SDL_test_log.c +++ b/vs/sdl2/src/test/SDL_test_log.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/test/SDL_test_md5.c b/vs/sdl2/src/test/SDL_test_md5.c index 8e8cd490c9..83f6f9ce90 100644 --- a/vs/sdl2/src/test/SDL_test_md5.c +++ b/vs/sdl2/src/test/SDL_test_md5.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ static unsigned char MD5PADDING[64] = { void SDLTest_Md5Init(SDLTest_Md5Context *mdContext) { - if (mdContext == NULL) { + if (!mdContext) { return; } @@ -141,10 +141,10 @@ void SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, int mdi; unsigned int i, ii; - if (mdContext == NULL) { + if (!mdContext) { return; } - if (inBuf == NULL || inLen < 1) { + if (!inBuf || inLen < 1) { return; } @@ -193,7 +193,7 @@ void SDLTest_Md5Final(SDLTest_Md5Context *mdContext) unsigned int i, ii; unsigned int padLen; - if (mdContext == NULL) { + if (!mdContext) { return; } diff --git a/vs/sdl2/src/test/SDL_test_memory.c b/vs/sdl2/src/test/SDL_test_memory.c index bb773a6bcb..ffd3eaac87 100644 --- a/vs/sdl2/src/test/SDL_test_memory.c +++ b/vs/sdl2/src/test/SDL_test_memory.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -84,7 +84,7 @@ static void SDL_TrackAllocation(void *mem, size_t size) return; } entry = (SDL_tracked_allocation *)SDL_malloc_orig(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { return; } entry->mem = mem; @@ -184,7 +184,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) static void SDLCALL SDLTest_TrackedFree(void *ptr) { - if (ptr == NULL) { + if (!ptr) { return; } diff --git a/vs/sdl2/src/test/SDL_test_random.c b/vs/sdl2/src/test/SDL_test_random.c index ab3fec54c2..0d7ef4ed3a 100644 --- a/vs/sdl2/src/test/SDL_test_random.c +++ b/vs/sdl2/src/test/SDL_test_random.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ void SDLTest_RandomInit(SDLTest_RandomContext *rndContext, unsigned int xi, unsigned int ci) { - if (rndContext == NULL) { + if (!rndContext) { return; } @@ -68,7 +68,7 @@ void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext) { int a, b; - if (rndContext == NULL) { + if (!rndContext) { return; } @@ -85,7 +85,7 @@ unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext) { unsigned int xh, xl; - if (rndContext == NULL) { + if (!rndContext) { return -1; } diff --git a/vs/sdl2/src/thread/SDL_systhread.h b/vs/sdl2/src/thread/SDL_systhread.h index bee2567633..b56eaf4da2 100644 --- a/vs/sdl2/src/thread/SDL_systhread.h +++ b/vs/sdl2/src/thread/SDL_systhread.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/SDL_thread.c b/vs/sdl2/src/thread/SDL_thread.c index aa8e2b188b..55c2902442 100644 --- a/vs/sdl2/src/thread/SDL_thread.c +++ b/vs/sdl2/src/thread/SDL_thread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "SDL_hints.h" #include "../SDL_error_c.h" -SDL_TLSID SDL_TLSCreate() +SDL_TLSID SDL_TLSCreate(void) { static SDL_atomic_t SDL_tls_id; return SDL_AtomicIncRef(&SDL_tls_id) + 1; @@ -39,7 +39,7 @@ void *SDL_TLSGet(SDL_TLSID id) SDL_TLSData *storage; storage = SDL_SYS_GetTLSData(); - if (storage == NULL || id == 0 || id > storage->limit) { + if (!storage || id == 0 || id > storage->limit) { return NULL; } return storage->array[id - 1].data; @@ -54,13 +54,13 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void * } storage = SDL_SYS_GetTLSData(); - if (storage == NULL || (id > storage->limit)) { + if (!storage || (id > storage->limit)) { unsigned int i, oldlimit, newlimit; oldlimit = storage ? storage->limit : 0; newlimit = (id + TLS_ALLOC_CHUNKSIZE); storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage) + (newlimit - 1) * sizeof(storage->array[0])); - if (storage == NULL) { + if (!storage) { return SDL_OutOfMemory(); } storage->limit = newlimit; @@ -78,7 +78,7 @@ int SDL_TLSSet(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void * return 0; } -void SDL_TLSCleanup() +void SDL_TLSCleanup(void) { SDL_TLSData *storage; @@ -119,15 +119,15 @@ SDL_TLSData *SDL_Generic_GetTLSData(void) SDL_TLSEntry *entry; SDL_TLSData *storage = NULL; -#if !SDL_THREADS_DISABLED - if (SDL_generic_TLS_mutex == NULL) { +#ifndef SDL_THREADS_DISABLED + if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_mutex *mutex = SDL_CreateMutex(); SDL_MemoryBarrierRelease(); SDL_generic_TLS_mutex = mutex; - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_AtomicUnlock(&tls_lock); return NULL; } @@ -144,7 +144,7 @@ SDL_TLSData *SDL_Generic_GetTLSData(void) break; } } -#if !SDL_THREADS_DISABLED +#ifndef SDL_THREADS_DISABLED SDL_UnlockMutex(SDL_generic_TLS_mutex); #endif @@ -161,10 +161,10 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) prev = NULL; for (entry = SDL_generic_TLS; entry; entry = entry->next) { if (entry->thread == thread) { - if (data != NULL) { + if (data) { entry->storage = data; } else { - if (prev != NULL) { + if (prev) { prev->next = entry->next; } else { SDL_generic_TLS = entry->next; @@ -175,7 +175,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } prev = entry; } - if (entry == NULL) { + if (!entry) { entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry)); if (entry) { entry->thread = thread; @@ -186,14 +186,14 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } SDL_UnlockMutex(SDL_generic_TLS_mutex); - if (entry == NULL) { + if (!entry) { return SDL_OutOfMemory(); } return 0; } /* Non-thread-safe global error variable */ -static SDL_error *SDL_GetStaticErrBuf() +static SDL_error *SDL_GetStaticErrBuf(void) { static SDL_error SDL_global_error; static char SDL_global_error_str[128]; @@ -202,7 +202,7 @@ static SDL_error *SDL_GetStaticErrBuf() return &SDL_global_error; } -#if !SDL_THREADS_DISABLED +#ifndef SDL_THREADS_DISABLED static void SDLCALL SDL_FreeErrBuf(void *data) { SDL_error *errbuf = (SDL_error *)data; @@ -217,7 +217,7 @@ static void SDLCALL SDL_FreeErrBuf(void *data) /* Routine to get the thread-specific error variable */ SDL_error *SDL_GetErrBuf(void) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return SDL_GetStaticErrBuf(); #else static SDL_SpinLock tls_lock; @@ -251,7 +251,7 @@ SDL_error *SDL_GetErrBuf(void) if (errbuf == ALLOCATION_IN_PROGRESS) { return SDL_GetStaticErrBuf(); } - if (errbuf == NULL) { + if (!errbuf) { /* Get the original memory functions for this allocation because the lifetime * of the error buffer may span calls to SDL_SetMemoryFunctions() by the app */ @@ -262,7 +262,7 @@ SDL_error *SDL_GetErrBuf(void) /* Mark that we're in the middle of allocating our buffer */ SDL_TLSSet(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL); errbuf = (SDL_error *)realloc_func(NULL, sizeof(*errbuf)); - if (errbuf == NULL) { + if (!errbuf) { SDL_TLSSet(tls_errbuf, NULL, NULL); return SDL_GetStaticErrBuf(); } @@ -330,7 +330,7 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), /* Allocate memory for the thread info structure */ thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread)); - if (thread == NULL) { + if (!thread) { SDL_OutOfMemory(); return NULL; } @@ -338,9 +338,9 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE); /* Set up the arguments for the thread */ - if (name != NULL) { + if (name) { thread->name = SDL_strdup(name); - if (thread->name == NULL) { + if (!thread->name) { SDL_OutOfMemory(); SDL_free(thread); return NULL; @@ -383,7 +383,7 @@ DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *), size_t stacksize = 0; /* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */ - if (stackhint != NULL) { + if (stackhint) { char *endp = NULL; const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10); if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */ @@ -452,7 +452,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) void SDL_DetachThread(SDL_Thread *thread) { - if (thread == NULL) { + if (!thread) { return; } diff --git a/vs/sdl2/src/thread/SDL_thread_c.h b/vs/sdl2/src/thread/SDL_thread_c.h index 278a680268..985a51996a 100644 --- a/vs/sdl2/src/thread/SDL_thread_c.h +++ b/vs/sdl2/src/thread/SDL_thread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,25 +26,25 @@ #include "SDL_thread.h" /* Need the definitions of SYS_ThreadHandle */ -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED #include "generic/SDL_systhread_c.h" -#elif SDL_THREAD_PTHREAD +#elif defined(SDL_THREAD_PTHREAD) #include "pthread/SDL_systhread_c.h" -#elif SDL_THREAD_WINDOWS +#elif defined(SDL_THREAD_WINDOWS) #include "windows/SDL_systhread_c.h" -#elif SDL_THREAD_PS2 +#elif defined(SDL_THREAD_PS2) #include "ps2/SDL_systhread_c.h" -#elif SDL_THREAD_PSP +#elif defined(SDL_THREAD_PSP) #include "psp/SDL_systhread_c.h" -#elif SDL_THREAD_VITA +#elif defined(SDL_THREAD_VITA) #include "vita/SDL_systhread_c.h" -#elif SDL_THREAD_N3DS +#elif defined(SDL_THREAD_N3DS) #include "n3ds/SDL_systhread_c.h" -#elif SDL_THREAD_STDCPP +#elif defined(SDL_THREAD_STDCPP) #include "stdcpp/SDL_systhread_c.h" -#elif SDL_THREAD_OS2 +#elif defined(SDL_THREAD_OS2) #include "os2/SDL_systhread_c.h" -#elif SDL_THREAD_NGAGE +#elif defined(SDL_THREAD_NGAGE) #include "ngage/SDL_systhread_c.h" #else #error Need thread implementation for this platform diff --git a/vs/sdl2/src/thread/generic/SDL_syscond.c b/vs/sdl2/src/thread/generic/SDL_syscond.c index a192929709..ebd0412310 100644 --- a/vs/sdl2/src/thread/generic/SDL_syscond.c +++ b/vs/sdl2/src/thread/generic/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +34,7 @@ * will be chosen at runtime), the function names need to be * suffixed */ -#if !SDL_THREAD_GENERIC_COND_SUFFIX +#ifndef SDL_THREAD_GENERIC_COND_SUFFIX #define SDL_CreateCond_generic SDL_CreateCond #define SDL_DestroyCond_generic SDL_DestroyCond #define SDL_CondSignal_generic SDL_CondSignal @@ -95,7 +95,7 @@ void SDL_DestroyCond_generic(SDL_cond *_cond) int SDL_CondSignal_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -119,7 +119,7 @@ int SDL_CondSignal_generic(SDL_cond *_cond) int SDL_CondBroadcast_generic(SDL_cond *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -175,7 +175,7 @@ int SDL_CondWaitTimeout_generic(SDL_cond *_cond, SDL_mutex *mutex, Uint32 ms) SDL_cond_generic *cond = (SDL_cond_generic *)_cond; int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/vs/sdl2/src/thread/generic/SDL_syscond_c.h b/vs/sdl2/src/thread/generic/SDL_syscond_c.h index 953f9bcfe0..64aaf4184f 100644 --- a/vs/sdl2/src/thread/generic/SDL_syscond_c.h +++ b/vs/sdl2/src/thread/generic/SDL_syscond_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #ifndef SDL_syscond_generic_h_ #define SDL_syscond_generic_h_ -#if SDL_THREAD_GENERIC_COND_SUFFIX +#ifdef SDL_THREAD_GENERIC_COND_SUFFIX SDL_cond *SDL_CreateCond_generic(void); void SDL_DestroyCond_generic(SDL_cond *cond); diff --git a/vs/sdl2/src/thread/generic/SDL_sysmutex.c b/vs/sdl2/src/thread/generic/SDL_sysmutex.c index daafbb607a..f9fc4e4a8e 100644 --- a/vs/sdl2/src/thread/generic/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/generic/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_mutex *SDL_CreateMutex(void) /* Allocate mutex memory */ mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); -#if !SDL_THREADS_DISABLED +#ifndef SDL_THREADS_DISABLED if (mutex) { /* Create the mutex semaphore, with initial value 1 */ mutex->sem = SDL_CreateSemaphore(1); @@ -72,7 +72,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) /* Lock the mutex */ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SDL_threadID this_thread; @@ -101,13 +101,13 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* try Lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else int retval = 0; SDL_threadID this_thread; - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -133,7 +133,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) /* Unlock the mutex */ int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else if (mutex == NULL) { diff --git a/vs/sdl2/src/thread/generic/SDL_sysmutex_c.h b/vs/sdl2/src/thread/generic/SDL_sysmutex_c.h index 0f15ae7bca..886ce23bf4 100644 --- a/vs/sdl2/src/thread/generic/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/generic/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/generic/SDL_syssem.c b/vs/sdl2/src/thread/generic/SDL_syssem.c index fc9794ed48..8b835b0748 100644 --- a/vs/sdl2/src/thread/generic/SDL_syssem.c +++ b/vs/sdl2/src/thread/generic/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_thread.h" #include "SDL_systhread_c.h" -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { @@ -78,7 +78,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -120,7 +120,7 @@ int SDL_SemTryWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -139,7 +139,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -184,7 +184,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/vs/sdl2/src/thread/generic/SDL_systhread.c b/vs/sdl2/src/thread/generic/SDL_systhread.c index 98c5d65cb5..b3a33f7be8 100644 --- a/vs/sdl2/src/thread/generic/SDL_systhread.c +++ b/vs/sdl2/src/thread/generic/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/generic/SDL_systhread_c.h b/vs/sdl2/src/thread/generic/SDL_systhread_c.h index 2283e61d3f..800b333a5d 100644 --- a/vs/sdl2/src/thread/generic/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/generic/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/generic/SDL_systls.c b/vs/sdl2/src/thread/generic/SDL_systls.c index 612ad378c9..1d100e0325 100644 --- a/vs/sdl2/src/thread/generic/SDL_systls.c +++ b/vs/sdl2/src/thread/generic/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/n3ds/SDL_syscond.c b/vs/sdl2/src/thread/n3ds/SDL_syscond.c index 05e0462af9..c5eae40b5d 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_syscond.c +++ b/vs/sdl2/src/thread/n3ds/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +54,7 @@ void SDL_DestroyCond(SDL_cond *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -65,7 +65,7 @@ int SDL_CondSignal(SDL_cond *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -98,10 +98,10 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) { Result res; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (mutex == NULL) { + if (!mutex) { return SDL_InvalidParamError("mutex"); } diff --git a/vs/sdl2/src/thread/n3ds/SDL_sysmutex.c b/vs/sdl2/src/thread/n3ds/SDL_sysmutex.c index 09e0e0ae3d..71056c23c3 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/n3ds/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* try Lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/vs/sdl2/src/thread/n3ds/SDL_sysmutex_c.h b/vs/sdl2/src/thread/n3ds/SDL_sysmutex_c.h index e72a60e66f..4a3e7e9f83 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/n3ds/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/n3ds/SDL_syssem.c b/vs/sdl2/src/thread/n3ds/SDL_syssem.c index e7615e4d95..45e53055ba 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_syssem.c +++ b/vs/sdl2/src/thread/n3ds/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +46,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) } sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -66,7 +66,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) int SDL_SemTryWait(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -81,7 +81,7 @@ int SDL_SemTryWait(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -122,7 +122,7 @@ int SDL_SemWait(SDL_sem *sem) Uint32 SDL_SemValue(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -131,7 +131,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } LightSemaphore_Release(&sem->semaphore, 1); diff --git a/vs/sdl2/src/thread/n3ds/SDL_systhread.c b/vs/sdl2/src/thread/n3ds/SDL_systhread.c index 4dfb8fc49e..c15c281be1 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_systhread.c +++ b/vs/sdl2/src/thread/n3ds/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +26,8 @@ #include "../SDL_systhread.h" -/* N3DS has very limited RAM (128MB), so we put a limit on thread stack size. */ -#define N3DS_THREAD_STACK_SIZE_MAX (16 * 1024) -#define N3DS_THREAD_STACK_SIZE_DEFAULT (4 * 1024) +/* N3DS has very limited RAM (128MB), so we set a low default thread stack size. */ +#define N3DS_THREAD_STACK_SIZE_DEFAULT (80 * 1024) #define N3DS_THREAD_PRIORITY_LOW 0x3F /**< Minimum priority */ #define N3DS_THREAD_PRIORITY_MEDIUM 0x2F /**< Slightly higher than main thread (0x30) */ @@ -49,18 +48,25 @@ static void ThreadEntry(void *arg) int SDL_SYS_CreateThread(SDL_Thread *thread) { - s32 priority; + s32 priority = 0x30; + int cpu = -1; size_t stack_size = GetStackSize(thread->stacksize); + svcGetThreadPriority(&priority, CUR_THREAD_HANDLE); + /* prefer putting audio thread on system core */ + if (thread->name && (SDL_strncmp(thread->name, "SDLAudioP", 9) == 0) && R_SUCCEEDED(APT_SetAppCpuTimeLimit(30))) { + cpu = 1; + } + thread->handle = threadCreate(ThreadEntry, thread, stack_size, priority, - -1, + cpu, false); - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Couldn't create thread"); } @@ -73,14 +79,6 @@ static size_t GetStackSize(size_t requested_size) return N3DS_THREAD_STACK_SIZE_DEFAULT; } - if (requested_size > N3DS_THREAD_STACK_SIZE_MAX) { - SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, - "Requested a thread size of %zu," - " falling back to the maximum supported of %zu\n", - requested_size, - N3DS_THREAD_STACK_SIZE_MAX); - requested_size = N3DS_THREAD_STACK_SIZE_MAX; - } return requested_size; } diff --git a/vs/sdl2/src/thread/n3ds/SDL_systhread_c.h b/vs/sdl2/src/thread/n3ds/SDL_systhread_c.h index f22f222f26..ee8bf94ed8 100644 --- a/vs/sdl2/src/thread/n3ds/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/n3ds/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/ngage/SDL_sysmutex.cpp b/vs/sdl2/src/thread/ngage/SDL_sysmutex.cpp index 72617045fe..4aa2625aa1 100644 --- a/vs/sdl2/src/thread/ngage/SDL_sysmutex.cpp +++ b/vs/sdl2/src/thread/ngage/SDL_sysmutex.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/ngage/SDL_syssem.cpp b/vs/sdl2/src/thread/ngage/SDL_syssem.cpp index 20133c6713..f8e1198cc7 100644 --- a/vs/sdl2/src/thread/ngage/SDL_syssem.cpp +++ b/vs/sdl2/src/thread/ngage/SDL_syssem.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { RSemaphore sema; sema.SetHandle(sem->handle); sema.Signal(sema.Count()); @@ -104,7 +104,7 @@ void SDL_DestroySemaphore(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -134,7 +134,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) int SDL_SemTryWait(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -151,7 +151,7 @@ int SDL_SemWait(SDL_sem *sem) Uint32 SDL_SemValue(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -160,7 +160,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) int SDL_SemPost(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } sem->count++; diff --git a/vs/sdl2/src/thread/ngage/SDL_systhread.cpp b/vs/sdl2/src/thread/ngage/SDL_systhread.cpp index fb2958da89..8eb50b23bf 100644 --- a/vs/sdl2/src/thread/ngage/SDL_systhread.cpp +++ b/vs/sdl2/src/thread/ngage/SDL_systhread.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_NGAGE +#ifdef SDL_THREAD_NGAGE /* N-Gage thread management routines for SDL */ diff --git a/vs/sdl2/src/thread/ngage/SDL_systhread_c.h b/vs/sdl2/src/thread/ngage/SDL_systhread_c.h index 8627eff42f..ed6ce36607 100644 --- a/vs/sdl2/src/thread/ngage/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/ngage/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/os2/SDL_sysmutex.c b/vs/sdl2/src/thread/os2/SDL_sysmutex.c index 4a7f6e86e8..e3a32e2614 100644 --- a/vs/sdl2/src/thread/os2/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/os2/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 /* An implementation of mutexes for OS/2 */ diff --git a/vs/sdl2/src/thread/os2/SDL_syssem.c b/vs/sdl2/src/thread/os2/SDL_syssem.c index 407867d670..44d6e91a51 100644 --- a/vs/sdl2/src/thread/os2/SDL_syssem.c +++ b/vs/sdl2/src/thread/os2/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 /* An implementation of semaphores for OS/2 */ @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ULONG ulRC; SDL_sem *pSDLSem = SDL_malloc(sizeof(SDL_sem)); - if (pSDLSem == NULL) { + if (!pSDLSem) { SDL_OutOfMemory(); return NULL; } @@ -85,7 +85,7 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) ULONG ulTimeout; ULONG cPost; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); if (timeout != SEM_INDEFINITE_WAIT) @@ -140,7 +140,7 @@ Uint32 SDL_SemValue(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -159,7 +159,7 @@ int SDL_SemPost(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); ulRC = DosRequestMutexSem(sem->hMtx, SEM_INDEFINITE_WAIT); diff --git a/vs/sdl2/src/thread/os2/SDL_systhread.c b/vs/sdl2/src/thread/os2/SDL_systhread.c index b2555892c1..f150de70e1 100644 --- a/vs/sdl2/src/thread/os2/SDL_systhread.c +++ b/vs/sdl2/src/thread/os2/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 /* Thread management routines for SDL */ @@ -45,7 +45,7 @@ static void RunThread(void *data) SDL_Thread *thread = (SDL_Thread *) data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc; - if (ppSDLTLSData != NULL) + if (ppSDLTLSData) *ppSDLTLSData = NULL; SDL_RunThread(thread); diff --git a/vs/sdl2/src/thread/os2/SDL_systhread_c.h b/vs/sdl2/src/thread/os2/SDL_systhread_c.h index 8627eff42f..ed6ce36607 100644 --- a/vs/sdl2/src/thread/os2/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/os2/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/os2/SDL_systls.c b/vs/sdl2/src/thread/os2/SDL_systls.c index 563ab74b80..5c380dd7f8 100644 --- a/vs/sdl2/src/thread/os2/SDL_systls.c +++ b/vs/sdl2/src/thread/os2/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 #include "../../core/os2/SDL_os2.h" @@ -41,7 +41,7 @@ void SDL_OS2TLSAlloc(void) { ULONG ulRC; - if (cTLSAlloc == 0 || ppSDLTLSData == NULL) { + if (cTLSAlloc == 0 || !ppSDLTLSData) { /* First call - allocate the thread local memory (1 DWORD) */ ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -59,7 +59,7 @@ void SDL_OS2TLSFree(void) if (cTLSAlloc != 0) cTLSAlloc--; - if (cTLSAlloc == 0 && ppSDLTLSData != NULL) { + if (cTLSAlloc == 0 && ppSDLTLSData) { /* Last call - free the thread local memory */ ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -72,7 +72,7 @@ void SDL_OS2TLSFree(void) SDL_TLSData *SDL_SYS_GetTLSData(void) { - return (ppSDLTLSData == NULL)? NULL : *ppSDLTLSData; + return (!ppSDLTLSData)? NULL : *ppSDLTLSData; } int SDL_SYS_SetTLSData(SDL_TLSData *data) diff --git a/vs/sdl2/src/thread/os2/SDL_systls_c.h b/vs/sdl2/src/thread/os2/SDL_systls_c.h index d792535380..bb39443794 100644 --- a/vs/sdl2/src/thread/os2/SDL_systls_c.h +++ b/vs/sdl2/src/thread/os2/SDL_systls_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_THREAD_OS2 +#ifdef SDL_THREAD_OS2 #include "../SDL_thread_c.h" diff --git a/vs/sdl2/src/thread/ps2/SDL_syssem.c b/vs/sdl2/src/thread/ps2/SDL_syssem.c index bba13a5e1e..c5f2cae114 100644 --- a/vs/sdl2/src/thread/ps2/SDL_syssem.c +++ b/vs/sdl2/src/thread/ps2/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +20,13 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_PS2 +#ifdef SDL_THREAD_PS2 /* Semaphore functions for the PS2. */ #include #include -#include +#include #include "SDL_error.h" #include "SDL_thread.h" @@ -38,11 +38,6 @@ struct SDL_semaphore s32 semid; }; -static void usercb(struct timer_alarm_t *alarm, void *arg) -{ - iReleaseWaitThread((int)arg); -} - /* Create a semaphore */ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { @@ -50,7 +45,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ee_sema_t sema; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sema.init_count = initial_value; sema.max_count = 255; @@ -72,7 +67,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { DeleteSema(sem->semid); sem->semid = 0; @@ -85,10 +80,10 @@ void SDL_DestroySemaphore(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int ret; - struct timer_alarm_t alarm; - InitializeTimerAlarm(&alarm); + u64 timeout_usec; + u64 *timeout_ptr; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -99,12 +94,14 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) return 0; } + timeout_ptr = NULL; + if (timeout != SDL_MUTEX_MAXWAIT) { - SetTimerAlarm(&alarm, MSec2TimerBusClock(timeout), &usercb, (void *)GetThreadId()); + timeout_usec = timeout * 1000; + timeout_ptr = &timeout_usec; } - ret = WaitSema(sem->semid); - StopTimerAlarm(&alarm); + ret = WaitSemaEx(sem->semid, 1, timeout_ptr); if (ret < 0) { return SDL_MUTEX_TIMEDOUT; @@ -127,7 +124,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { ee_sema_t info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -143,7 +140,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/vs/sdl2/src/thread/ps2/SDL_systhread.c b/vs/sdl2/src/thread/ps2/SDL_systhread.c index 3d2f68520c..15dcf0d96a 100644 --- a/vs/sdl2/src/thread/ps2/SDL_systhread.c +++ b/vs/sdl2/src/thread/ps2/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_PS2 +#ifdef SDL_THREAD_PS2 /* PS2 thread management routines for SDL */ diff --git a/vs/sdl2/src/thread/ps2/SDL_systhread_c.h b/vs/sdl2/src/thread/ps2/SDL_systhread_c.h index b975704539..afab3838f4 100644 --- a/vs/sdl2/src/thread/ps2/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/ps2/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/psp/SDL_sysmutex.c b/vs/sdl2/src/thread/psp/SDL_sysmutex.c index 3b3cf3786f..eafca9f362 100644 --- a/vs/sdl2/src/thread/psp/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/psp/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_PSP +#ifdef SDL_THREAD_PSP /* An implementation of mutexes using semaphores */ @@ -75,7 +75,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) /* Lock the mutex */ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; @@ -96,12 +96,12 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* Try to lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -125,7 +125,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) /* Unlock the mutex */ int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; diff --git a/vs/sdl2/src/thread/psp/SDL_sysmutex_c.h b/vs/sdl2/src/thread/psp/SDL_sysmutex_c.h index 0f15ae7bca..886ce23bf4 100644 --- a/vs/sdl2/src/thread/psp/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/psp/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/psp/SDL_syssem.c b/vs/sdl2/src/thread/psp/SDL_syssem.c index 131f6b73be..9b8e7d13b8 100644 --- a/vs/sdl2/src/thread/psp/SDL_syssem.c +++ b/vs/sdl2/src/thread/psp/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_PSP +#ifdef SDL_THREAD_PSP /* Semaphore functions for the PSP. */ @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -62,7 +62,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -81,7 +81,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -126,7 +126,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { SceKernelSemaInfo info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -142,7 +142,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/vs/sdl2/src/thread/psp/SDL_systhread.c b/vs/sdl2/src/thread/psp/SDL_systhread.c index f29efff35e..c137799ffa 100644 --- a/vs/sdl2/src/thread/psp/SDL_systhread.c +++ b/vs/sdl2/src/thread/psp/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_PSP +#ifdef SDL_THREAD_PSP /* PSP thread management routines for SDL */ diff --git a/vs/sdl2/src/thread/psp/SDL_systhread_c.h b/vs/sdl2/src/thread/psp/SDL_systhread_c.h index ef3fbccf59..ffa844924b 100644 --- a/vs/sdl2/src/thread/psp/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/psp/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/pthread/SDL_syscond.c b/vs/sdl2/src/thread/pthread/SDL_syscond.c index 5b8aeb4ad1..a1a2e63b90 100644 --- a/vs/sdl2/src/thread/pthread/SDL_syscond.c +++ b/vs/sdl2/src/thread/pthread/SDL_syscond.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 SDL_CondSignal(SDL_cond *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -80,7 +80,7 @@ int SDL_CondBroadcast(SDL_cond *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -99,7 +99,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) #endif struct timespec abstime; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -141,7 +141,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) */ int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { return SDL_SetError("pthread_cond_wait() failed"); diff --git a/vs/sdl2/src/thread/pthread/SDL_sysmutex.c b/vs/sdl2/src/thread/pthread/SDL_sysmutex.c index 9b24e1605c..c66b5cc9c5 100644 --- a/vs/sdl2/src/thread/pthread/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/pthread/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,15 +25,15 @@ #include "SDL_thread.h" -#if !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX && \ - !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP -#define FAKE_RECURSIVE_MUTEX 1 +#if !(defined(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX) || \ + defined(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP)) +#define FAKE_RECURSIVE_MUTEX #endif struct SDL_mutex { pthread_mutex_t id; -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX int recursive; pthread_t owner; #endif @@ -48,9 +48,9 @@ SDL_mutex *SDL_CreateMutex(void) mutex = (SDL_mutex *)SDL_calloc(1, sizeof(*mutex)); if (mutex) { pthread_mutexattr_init(&attr); -#if SDL_THREAD_PTHREAD_RECURSIVE_MUTEX +#ifdef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#elif SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP +#elif defined(SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP) pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #else /* No extra attributes necessary */ @@ -77,7 +77,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) /* Lock the mutex */ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX pthread_t this_thread; #endif @@ -85,7 +85,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn return 0; } -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX this_thread = pthread_self(); if (mutex->owner == this_thread) { ++mutex->recursive; @@ -113,16 +113,16 @@ int SDL_TryLockMutex(SDL_mutex *mutex) { int retval; int result; -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX pthread_t this_thread; #endif - if (mutex == NULL) { + if (!mutex) { return 0; } retval = 0; -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX this_thread = pthread_self(); if (mutex->owner == this_thread) { ++mutex->recursive; @@ -160,7 +160,7 @@ int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doe return 0; } -#if FAKE_RECURSIVE_MUTEX +#ifdef FAKE_RECURSIVE_MUTEX /* We can only unlock the mutex if we own it */ if (pthread_self() == mutex->owner) { if (mutex->recursive) { diff --git a/vs/sdl2/src/thread/pthread/SDL_sysmutex_c.h b/vs/sdl2/src/thread/pthread/SDL_sysmutex_c.h index 94667f310a..0435a38d4c 100644 --- a/vs/sdl2/src/thread/pthread/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/pthread/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/pthread/SDL_syssem.c b/vs/sdl2/src/thread/pthread/SDL_syssem.c index fee50bb865..6d0cdd5c2a 100644 --- a/vs/sdl2/src/thread/pthread/SDL_syssem.c +++ b/vs/sdl2/src/thread/pthread/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +45,7 @@ struct SDL_semaphore SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem)); - if (sem != NULL) { + if (sem) { if (sem_init(&sem->sem, 0, initial_value) < 0) { SDL_SetError("sem_init() failed"); SDL_free(sem); @@ -59,7 +59,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { sem_destroy(&sem->sem); SDL_free(sem); } @@ -69,7 +69,7 @@ int SDL_SemTryWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } retval = SDL_MUTEX_TIMEDOUT; @@ -83,7 +83,7 @@ int SDL_SemWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -109,7 +109,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 end; #endif - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -175,7 +175,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) { int ret = 0; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -191,7 +191,7 @@ int SDL_SemPost(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/vs/sdl2/src/thread/pthread/SDL_systhread.c b/vs/sdl2/src/thread/pthread/SDL_systhread.c index 5316807058..ccc09875fb 100644 --- a/vs/sdl2/src/thread/pthread/SDL_systhread.c +++ b/vs/sdl2/src/thread/pthread/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include -#if HAVE_PTHREAD_NP_H +#ifdef HAVE_PTHREAD_NP_H #include #endif @@ -127,10 +127,10 @@ void SDL_SYS_SetupThread(const char *name) sigset_t mask; #endif /* !__NACL__ */ - if (name != NULL) { + if (name) { #if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) SDL_assert(checked_setname); - if (ppthread_setname_np != NULL) { + if (ppthread_setname_np) { #if defined(__MACOSX__) || defined(__IPHONEOS__) ppthread_setname_np(name); #elif defined(__LINUX__) @@ -141,7 +141,7 @@ void SDL_SYS_SetupThread(const char *name) } #endif } -#elif HAVE_PTHREAD_SETNAME_NP +#elif defined(HAVE_PTHREAD_SETNAME_NP) #if defined(__NETBSD__) pthread_setname_np(pthread_self(), "%s", name); #else @@ -151,7 +151,7 @@ void SDL_SYS_SetupThread(const char *name) pthread_setname_np(pthread_self(), namebuf); } #endif -#elif HAVE_PTHREAD_SET_NAME_NP +#elif defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); #elif defined(__HAIKU__) /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ @@ -188,7 +188,7 @@ SDL_threadID SDL_ThreadID(void) int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { -#if __NACL__ || __RISCOS__ || __OS2__ +#if defined(__NACL__) || defined(__RISCOS__) || defined(__OS2__) /* FIXME: Setting thread priority does not seem to be supported in NACL */ return 0; #else @@ -246,7 +246,7 @@ int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) policy = pri_policy; } -#if __LINUX__ +#ifdef __LINUX__ { pid_t linuxTid = syscall(SYS_gettid); return SDL_LinuxSetThreadPriorityAndPolicy(linuxTid, priority, policy); diff --git a/vs/sdl2/src/thread/pthread/SDL_systhread_c.h b/vs/sdl2/src/thread/pthread/SDL_systhread_c.h index bb842ad379..04dbb22bc2 100644 --- a/vs/sdl2/src/thread/pthread/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/pthread/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/pthread/SDL_systls.c b/vs/sdl2/src/thread/pthread/SDL_systls.c index f0be2f840e..0618cb3c59 100644 --- a/vs/sdl2/src/thread/pthread/SDL_systls.c +++ b/vs/sdl2/src/thread/pthread/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/stdcpp/SDL_syscond.cpp b/vs/sdl2/src/thread/stdcpp/SDL_syscond.cpp index ebd03cf4f2..561d774ac6 100644 --- a/vs/sdl2/src/thread/stdcpp/SDL_syscond.cpp +++ b/vs/sdl2/src/thread/stdcpp/SDL_syscond.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +57,7 @@ SDL_CreateCond(void) extern "C" void SDL_DestroyCond(SDL_cond *cond) { - if (cond != NULL) { + if (cond) { delete cond; } } @@ -66,7 +66,7 @@ SDL_DestroyCond(SDL_cond *cond) extern "C" int SDL_CondSignal(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -78,7 +78,7 @@ SDL_CondSignal(SDL_cond *cond) extern "C" int SDL_CondBroadcast(SDL_cond *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/vs/sdl2/src/thread/stdcpp/SDL_sysmutex.cpp b/vs/sdl2/src/thread/stdcpp/SDL_sysmutex.cpp index e74627b1ae..bc04bed8d8 100644 --- a/vs/sdl2/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/vs/sdl2/src/thread/stdcpp/SDL_sysmutex.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +51,7 @@ SDL_CreateMutex(void) extern "C" void SDL_DestroyMutex(SDL_mutex *mutex) { - if (mutex != NULL) { + if (mutex) { delete mutex; } } @@ -77,7 +77,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) { int retval = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/vs/sdl2/src/thread/stdcpp/SDL_sysmutex_c.h b/vs/sdl2/src/thread/stdcpp/SDL_sysmutex_c.h index 9a117176f5..dd53ee8a92 100644 --- a/vs/sdl2/src/thread/stdcpp/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/stdcpp/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/stdcpp/SDL_systhread.cpp b/vs/sdl2/src/thread/stdcpp/SDL_systhread.cpp index 49b91d264e..3d93a014dd 100644 --- a/vs/sdl2/src/thread/stdcpp/SDL_systhread.cpp +++ b/vs/sdl2/src/thread/stdcpp/SDL_systhread.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/stdcpp/SDL_systhread_c.h b/vs/sdl2/src/thread/stdcpp/SDL_systhread_c.h index 14e0c74ed8..5cf9d11866 100644 --- a/vs/sdl2/src/thread/stdcpp/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/stdcpp/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/vita/SDL_sysmutex.c b/vs/sdl2/src/thread/vita/SDL_sysmutex.c index 232ae04795..b0301453a2 100644 --- a/vs/sdl2/src/thread/vita/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/vita/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_VITA +#ifdef SDL_THREAD_VITA #include "SDL_thread.h" #include "SDL_systhread_c.h" @@ -41,7 +41,7 @@ SDL_mutex *SDL_CreateMutex(void) /* Allocate mutex memory */ mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { res = sceKernelCreateLwMutex( &mutex->lock, @@ -62,7 +62,7 @@ SDL_mutex *SDL_CreateMutex(void) /* Free the mutex */ void SDL_DestroyMutex(SDL_mutex *mutex) { - if (mutex != NULL) { + if (mutex) { sceKernelDeleteLwMutex(&mutex->lock); SDL_free(mutex); } @@ -71,12 +71,12 @@ void SDL_DestroyMutex(SDL_mutex *mutex) /* Lock the mutex */ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -92,12 +92,12 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* Try to lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -121,7 +121,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) /* Unlock the mutex */ int SDL_UnlockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn't know about NULL mutexes */ { -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED return 0; #else SceInt32 res = 0; diff --git a/vs/sdl2/src/thread/vita/SDL_sysmutex_c.h b/vs/sdl2/src/thread/vita/SDL_sysmutex_c.h index aa0fe19e1c..46b7996b7c 100644 --- a/vs/sdl2/src/thread/vita/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/vita/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/vita/SDL_syssem.c b/vs/sdl2/src/thread/vita/SDL_syssem.c index 453afa9244..0149ec39db 100644 --- a/vs/sdl2/src/thread/vita/SDL_syssem.c +++ b/vs/sdl2/src/thread/vita/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_VITA +#ifdef SDL_THREAD_VITA /* Semaphore functions for the VITA. */ @@ -45,7 +45,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -63,7 +63,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -82,7 +82,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) Uint32 *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -128,7 +128,7 @@ Uint32 SDL_SemValue(SDL_sem *sem) SceKernelSemaInfo info; info.size = sizeof(info); - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -144,7 +144,7 @@ int SDL_SemPost(SDL_sem *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/vs/sdl2/src/thread/vita/SDL_systhread.c b/vs/sdl2/src/thread/vita/SDL_systhread.c index 31f7ab0a86..5e531b6b51 100644 --- a/vs/sdl2/src/thread/vita/SDL_systhread.c +++ b/vs/sdl2/src/thread/vita/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_VITA +#ifdef SDL_THREAD_VITA /* VITA thread management routines for SDL */ diff --git a/vs/sdl2/src/thread/vita/SDL_systhread_c.h b/vs/sdl2/src/thread/vita/SDL_systhread_c.h index 8b84e5fb5f..7419b1e0c8 100644 --- a/vs/sdl2/src/thread/vita/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/vita/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/windows/SDL_syscond_cv.c b/vs/sdl2/src/thread/windows/SDL_syscond_cv.c index 905d416b8d..b532231a59 100644 --- a/vs/sdl2/src/thread/windows/SDL_syscond_cv.c +++ b/vs/sdl2/src/thread/windows/SDL_syscond_cv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -61,7 +61,7 @@ typedef struct CONDITION_VARIABLE } CONDITION_VARIABLE, *PCONDITION_VARIABLE; #endif -#if __WINRT__ +#ifdef __WINRT__ #define pWakeConditionVariable WakeConditionVariable #define pWakeAllConditionVariable WakeAllConditionVariable #define pSleepConditionVariableSRW SleepConditionVariableSRW @@ -89,7 +89,7 @@ static SDL_cond *SDL_CreateCond_cv(void) /* Relies on CONDITION_VARIABLE_INIT == 0. */ cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond)); - if (cond == NULL) { + if (!cond) { SDL_OutOfMemory(); } @@ -98,7 +98,7 @@ static SDL_cond *SDL_CreateCond_cv(void) static void SDL_DestroyCond_cv(SDL_cond *cond) { - if (cond != NULL) { + if (cond) { /* There are no kernel allocated resources */ SDL_free(cond); } @@ -107,7 +107,7 @@ static void SDL_DestroyCond_cv(SDL_cond *cond) static int SDL_CondSignal_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -119,7 +119,7 @@ static int SDL_CondSignal_cv(SDL_cond *_cond) static int SDL_CondBroadcast_cv(SDL_cond *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -134,10 +134,10 @@ static int SDL_CondWaitTimeout_cv(SDL_cond *_cond, SDL_mutex *_mutex, Uint32 ms) DWORD timeout; int ret; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (_mutex == NULL) { + if (!_mutex) { return SDL_InvalidParamError("mutex"); } @@ -220,14 +220,14 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = { SDL_cond *SDL_CreateCond(void) { - if (SDL_cond_impl_active.Create == NULL) { + if (!SDL_cond_impl_active.Create) { /* 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 == NULL) { + if (!mutex) { return NULL; } SDL_DestroyMutex(mutex); @@ -235,7 +235,7 @@ SDL_cond *SDL_CreateCond(void) SDL_assert(SDL_mutex_impl_active.Type != SDL_MUTEX_INVALID); } -#if __WINRT__ +#ifdef __WINRT__ /* Link statically on this platform */ impl = &SDL_cond_impl_cv; #else diff --git a/vs/sdl2/src/thread/windows/SDL_sysmutex.c b/vs/sdl2/src/thread/windows/SDL_sysmutex.c index 6091819f85..71cdac94c0 100644 --- a/vs/sdl2/src/thread/windows/SDL_sysmutex.c +++ b/vs/sdl2/src/thread/windows/SDL_sysmutex.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_WINDOWS +#ifdef SDL_THREAD_WINDOWS /** * Mutex functions using the Win32 API @@ -42,7 +42,7 @@ SDL_mutex_impl_t SDL_mutex_impl_active = { 0 }; * Implementation based on Slim Reader/Writer (SRW) Locks for Win 7 and newer. */ -#if __WINRT__ +#ifdef __WINRT__ /* Functions are guaranteed to be available */ #define pReleaseSRWLockExclusive ReleaseSRWLockExclusive #define pAcquireSRWLockExclusive AcquireSRWLockExclusive @@ -62,7 +62,7 @@ static SDL_mutex *SDL_CreateMutex_srw(void) /* Relies on SRWLOCK_INIT == 0. */ mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex)); - if (mutex == NULL) { + if (!mutex) { SDL_OutOfMemory(); } @@ -153,10 +153,10 @@ static SDL_mutex *SDL_CreateMutex_cs(void) /* Allocate mutex memory */ mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { /* Initialize */ /* On SMP systems, a non-zero spin count generally helps performance */ -#if __WINRT__ +#ifdef __WINRT__ InitializeCriticalSectionEx(&mutex->cs, 2000, 0); #else InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000); @@ -221,12 +221,12 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = { SDL_mutex *SDL_CreateMutex(void) { - if (SDL_mutex_impl_active.Create == NULL) { + if (!SDL_mutex_impl_active.Create) { /* 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__ +#ifdef __WINRT__ /* Link statically on this platform */ impl = &SDL_mutex_impl_srw; #else @@ -260,7 +260,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) int SDL_LockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -269,7 +269,7 @@ int SDL_LockMutex(SDL_mutex *mutex) int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -278,7 +278,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) int SDL_UnlockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/vs/sdl2/src/thread/windows/SDL_sysmutex_c.h b/vs/sdl2/src/thread/windows/SDL_sysmutex_c.h index c5f28d07e2..6a0f45fa14 100644 --- a/vs/sdl2/src/thread/windows/SDL_sysmutex_c.h +++ b/vs/sdl2/src/thread/windows/SDL_sysmutex_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/windows/SDL_syssem.c b/vs/sdl2/src/thread/windows/SDL_syssem.c index 6853549b67..4c59fc1dc2 100644 --- a/vs/sdl2/src/thread/windows/SDL_syssem.c +++ b/vs/sdl2/src/thread/windows/SDL_syssem.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_WINDOWS +#ifdef SDL_THREAD_WINDOWS /** * Semaphore functions using the Win32 API @@ -68,14 +68,8 @@ static SDL_sem_impl_t SDL_sem_impl_active = { 0 }; /* 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__ +#ifdef __WINRT__ /* Functions are guaranteed to be available */ #define pWaitOnAddress WaitOnAddress #define pWakeByAddressSingle WakeByAddressSingle @@ -97,7 +91,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value) SDL_sem_atom *sem; sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { sem->count = initial_value; } else { SDL_OutOfMemory(); @@ -107,7 +101,7 @@ static SDL_sem *SDL_CreateSemaphore_atom(Uint32 initial_value) static void SDL_DestroySemaphore_atom(SDL_sem *sem) { - if (sem != NULL) { + if (sem) { SDL_free(sem); } } @@ -117,7 +111,7 @@ static int SDL_SemTryWait_atom(SDL_sem *_sem) SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -138,7 +132,7 @@ static int SDL_SemWait_atom(SDL_sem *_sem) SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -169,7 +163,7 @@ static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout) return SDL_SemWait_atom(_sem); } - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -211,7 +205,7 @@ static Uint32 SDL_SemValue_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -223,7 +217,7 @@ static int SDL_SemPost_atom(SDL_sem *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -261,9 +255,9 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value) /* Allocate sem memory */ sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* Create the semaphore, with max value 32K */ -#if __WINRT__ +#ifdef __WINRT__ sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); #else sem->id = CreateSemaphore(NULL, initial_value, 32 * 1024, NULL); @@ -284,7 +278,7 @@ static SDL_sem *SDL_CreateSemaphore_kern(Uint32 initial_value) static void SDL_DestroySemaphore_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem != NULL) { + if (sem) { if (sem->id) { CloseHandle(sem->id); sem->id = 0; @@ -299,7 +293,7 @@ static int SDL_SemWaitTimeout_kern(SDL_sem *_sem, Uint32 timeout) int retval; DWORD dwMilliseconds; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -337,7 +331,7 @@ static int SDL_SemWait_kern(SDL_sem *sem) static Uint32 SDL_SemValue_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -347,7 +341,7 @@ static Uint32 SDL_SemValue_kern(SDL_sem *_sem) static int SDL_SemPost_kern(SDL_sem *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } /* Increase the counter in the first place, because @@ -379,13 +373,13 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = { SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { - if (SDL_sem_impl_active.Create == NULL) { + if (!SDL_sem_impl_active.Create) { /* 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__ +#ifdef __WINRT__ /* Link statically on this platform */ impl = &SDL_sem_impl_atom; #else diff --git a/vs/sdl2/src/thread/windows/SDL_systhread.c b/vs/sdl2/src/thread/windows/SDL_systhread.c index b55eb13266..974759b7c0 100644 --- a/vs/sdl2/src/thread/windows/SDL_systhread.c +++ b/vs/sdl2/src/thread/windows/SDL_systhread.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_THREAD_WINDOWS +#ifdef SDL_THREAD_WINDOWS /* Win32 thread management routines for SDL */ @@ -49,7 +49,7 @@ static DWORD RunThread(void *data) SDL_Thread *thread = (SDL_Thread *)data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc; SDL_RunThread(thread); - if (pfnEndThread != NULL) { + if (pfnEndThread) { pfnEndThread(0); } return 0; @@ -98,7 +98,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) RunThreadViaCreateThread, thread, flags, &threadid); } - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Not enough resources to create thread"); } return 0; @@ -118,7 +118,7 @@ typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR); void SDL_SYS_SetupThread(const char *name) { - if (name != NULL) { + if (name) { #ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = NULL; @@ -130,7 +130,7 @@ void SDL_SYS_SetupThread(const char *name) } } - if (pSetThreadDescription != NULL) { + if (pSetThreadDescription) { WCHAR *strw = WIN_UTF8ToStringW(name); if (strw) { pSetThreadDescription(GetCurrentThread(), strw); diff --git a/vs/sdl2/src/thread/windows/SDL_systhread_c.h b/vs/sdl2/src/thread/windows/SDL_systhread_c.h index f69d2dec79..ae6978b1c5 100644 --- a/vs/sdl2/src/thread/windows/SDL_systhread_c.h +++ b/vs/sdl2/src/thread/windows/SDL_systhread_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/thread/windows/SDL_systls.c b/vs/sdl2/src/thread/windows/SDL_systls.c index b4be434fd9..9ae61b39ea 100644 --- a/vs/sdl2/src/thread/windows/SDL_systls.c +++ b/vs/sdl2/src/thread/windows/SDL_systls.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_THREAD_WINDOWS +#ifdef SDL_THREAD_WINDOWS #include "../../core/windows/SDL_windows.h" diff --git a/vs/sdl2/src/timer/SDL_timer.c b/vs/sdl2/src/timer/SDL_timer.c index 874f154626..8cba8087fc 100644 --- a/vs/sdl2/src/timer/SDL_timer.c +++ b/vs/sdl2/src/timer/SDL_timer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ /* #define DEBUG_TIMERS */ -#if !defined(__EMSCRIPTEN__) || !SDL_THREADS_DISABLED +#if !defined(__EMSCRIPTEN__) || !defined(SDL_THREADS_DISABLED) typedef struct _SDL_Timer { @@ -173,7 +173,7 @@ static int SDLCALL SDL_TimerThread(void *_data) current->scheduled = tick + interval; SDL_AddTimerInternal(data, current); } else { - if (freelist_head == NULL) { + if (!freelist_head) { freelist_head = current; } if (freelist_tail) { @@ -298,7 +298,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_RemoveTimer(timer->timerID); } else { timer = (SDL_Timer *)SDL_malloc(sizeof(*timer)); - if (timer == NULL) { + if (!timer) { SDL_OutOfMemory(); return 0; } @@ -311,7 +311,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_AtomicSet(&timer->canceled, 0); entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_free(timer); SDL_OutOfMemory(); return 0; @@ -424,7 +424,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_TimerMap *entry; entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return 0; } diff --git a/vs/sdl2/src/timer/SDL_timer_c.h b/vs/sdl2/src/timer/SDL_timer_c.h index c6de568437..f5c1e43ade 100644 --- a/vs/sdl2/src/timer/SDL_timer_c.h +++ b/vs/sdl2/src/timer/SDL_timer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/dummy/SDL_systimer.c b/vs/sdl2/src/timer/dummy/SDL_systimer.c index 8b3235792f..ecc31ad697 100644 --- a/vs/sdl2/src/timer/dummy/SDL_systimer.c +++ b/vs/sdl2/src/timer/dummy/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/haiku/SDL_systimer.c b/vs/sdl2/src/timer/haiku/SDL_systimer.c index 1c2970bb44..8b038b565f 100644 --- a/vs/sdl2/src/timer/haiku/SDL_systimer.c +++ b/vs/sdl2/src/timer/haiku/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/n3ds/SDL_systimer.c b/vs/sdl2/src/timer/n3ds/SDL_systimer.c index 2a9c38b8c5..047b004deb 100644 --- a/vs/sdl2/src/timer/n3ds/SDL_systimer.c +++ b/vs/sdl2/src/timer/n3ds/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/ngage/SDL_systimer.cpp b/vs/sdl2/src/timer/ngage/SDL_systimer.cpp index e2a45ce501..4ddf76f0aa 100644 --- a/vs/sdl2/src/timer/ngage/SDL_systimer.cpp +++ b/vs/sdl2/src/timer/ngage/SDL_systimer.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/os2/SDL_systimer.c b/vs/sdl2/src/timer/os2/SDL_systimer.c index 0828300abf..f558855bdc 100644 --- a/vs/sdl2/src/timer/os2/SDL_systimer.c +++ b/vs/sdl2/src/timer/os2/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_TIMER_OS2 +#ifdef SDL_TIMER_OS2 #include "SDL_timer.h" #include "../../core/os2/SDL_os2.h" diff --git a/vs/sdl2/src/timer/ps2/SDL_systimer.c b/vs/sdl2/src/timer/ps2/SDL_systimer.c index 910f7a675d..720f696d9b 100644 --- a/vs/sdl2/src/timer/ps2/SDL_systimer.c +++ b/vs/sdl2/src/timer/ps2/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/psp/SDL_systimer.c b/vs/sdl2/src/timer/psp/SDL_systimer.c index 5337c771f6..c69598e448 100644 --- a/vs/sdl2/src/timer/psp/SDL_systimer.c +++ b/vs/sdl2/src/timer/psp/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/unix/SDL_systimer.c b/vs/sdl2/src/timer/unix/SDL_systimer.c index 5fe367e13b..a697b7117a 100644 --- a/vs/sdl2/src/timer/unix/SDL_systimer.c +++ b/vs/sdl2/src/timer/unix/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +46,7 @@ Also added OS X Monotonic clock support Based on work in https://github.com/ThomasHabets/monotonic_clock */ -#if HAVE_NANOSLEEP || HAVE_CLOCK_GETTIME +#if defined(HAVE_NANOSLEEP) || defined(HAVE_CLOCK_GETTIME) #include #endif #ifdef __APPLE__ @@ -54,7 +54,7 @@ #endif /* Use CLOCK_MONOTONIC_RAW, if available, which is not subject to adjustment by NTP */ -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME #ifdef CLOCK_MONOTONIC_RAW #define SDL_MONOTONIC_CLOCK CLOCK_MONOTONIC_RAW #else @@ -63,7 +63,7 @@ #endif /* The first ticks value of the application */ -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME static struct timespec start_ts; #elif defined(__APPLE__) static uint64_t start_mach; @@ -81,7 +81,7 @@ void SDL_TicksInit(void) ticks_started = SDL_TRUE; /* Set first ticks value */ -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME if (clock_gettime(SDL_MONOTONIC_CLOCK, &start_ts) == 0) { has_monotonic_time = SDL_TRUE; } else @@ -108,7 +108,7 @@ Uint64 SDL_GetTicks64(void) } if (has_monotonic_time) { -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME struct timespec now; clock_gettime(SDL_MONOTONIC_CLOCK, &now); return (Uint64)(((Sint64)(now.tv_sec - start_ts.tv_sec) * 1000) + ((now.tv_nsec - start_ts.tv_nsec) / 1000000)); @@ -134,7 +134,7 @@ Uint64 SDL_GetPerformanceCounter(void) } if (has_monotonic_time) { -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME struct timespec now; clock_gettime(SDL_MONOTONIC_CLOCK, &now); @@ -165,7 +165,7 @@ Uint64 SDL_GetPerformanceFrequency(void) } if (has_monotonic_time) { -#if HAVE_CLOCK_GETTIME +#ifdef HAVE_CLOCK_GETTIME return 1000000000; #elif defined(__APPLE__) Uint64 freq = mach_base_info.denom; @@ -182,7 +182,7 @@ void SDL_Delay(Uint32 ms) { int was_error; -#if HAVE_NANOSLEEP +#ifdef HAVE_NANOSLEEP struct timespec elapsed, tv; #else struct timeval tv; @@ -198,7 +198,7 @@ void SDL_Delay(Uint32 ms) #endif /* Set the timeout interval */ -#if HAVE_NANOSLEEP +#ifdef HAVE_NANOSLEEP elapsed.tv_sec = ms / 1000; elapsed.tv_nsec = (ms % 1000) * 1000000; #else @@ -207,7 +207,7 @@ void SDL_Delay(Uint32 ms) do { errno = 0; -#if HAVE_NANOSLEEP +#ifdef HAVE_NANOSLEEP tv.tv_sec = elapsed.tv_sec; tv.tv_nsec = elapsed.tv_nsec; was_error = nanosleep(&tv, &elapsed); diff --git a/vs/sdl2/src/timer/vita/SDL_systimer.c b/vs/sdl2/src/timer/vita/SDL_systimer.c index f954bb7475..d5ccabcab9 100644 --- a/vs/sdl2/src/timer/vita/SDL_systimer.c +++ b/vs/sdl2/src/timer/vita/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/timer/windows/SDL_systimer.c b/vs/sdl2/src/timer/windows/SDL_systimer.c index e51c891d75..e7c2c78fe8 100644 --- a/vs/sdl2/src/timer/windows/SDL_systimer.c +++ b/vs/sdl2/src/timer/windows/SDL_systimer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_RLEaccel.c b/vs/sdl2/src/video/SDL_RLEaccel.c index 9f861ebac8..a007984fc6 100644 --- a/vs/sdl2/src/video/SDL_RLEaccel.c +++ b/vs/sdl2/src/video/SDL_RLEaccel.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -1024,7 +1024,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) SDL_PixelFormat *, SDL_PixelFormat *); dest = surface->map->dst; - if (dest == NULL) { + if (!dest) { return -1; } df = dest->format; @@ -1081,7 +1081,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) maxsize += sizeof(RLEDestFormat); rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } { @@ -1227,7 +1227,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) /* reallocate the buffer to release unused memory */ { Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1300,7 +1300,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) } rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } @@ -1395,7 +1395,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) { /* If SDL_realloc returns NULL, the original block is left intact */ Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1492,7 +1492,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { return SDL_FALSE; } surface->flags |= SDL_SIMD_ALIGNED; @@ -1558,7 +1558,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) /* re-create the original surface */ surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; return; diff --git a/vs/sdl2/src/video/SDL_RLEaccel_c.h b/vs/sdl2/src/video/SDL_RLEaccel_c.h index eaaeed2fa8..5968081099 100644 --- a/vs/sdl2/src/video/SDL_RLEaccel_c.h +++ b/vs/sdl2/src/video/SDL_RLEaccel_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit.c b/vs/sdl2/src/video/SDL_blit.c index 88b7f7330a..19d47a17f8 100644 --- a/vs/sdl2/src/video/SDL_blit.c +++ b/vs/sdl2/src/video/SDL_blit.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +116,7 @@ static SDL_bool SDL_UseAltivecPrefetch() } } #else -static SDL_bool SDL_UseAltivecPrefetch() +static SDL_bool SDL_UseAltivecPrefetch(void) { /* Just guess G4 */ return SDL_TRUE; @@ -251,7 +251,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) } #endif #if SDL_HAVE_BLIT_AUTO - if (blit == NULL) { + if (!blit) { Uint32 src_format = surface->format->format; Uint32 dst_format = dst->format->format; @@ -262,7 +262,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) #endif #ifndef TEST_SLOW_BLIT - if (blit == NULL) + if (!blit) #endif { Uint32 src_format = surface->format->format; @@ -278,7 +278,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) map->data = blit; /* Make sure we have a blit function */ - if (blit == NULL) { + if (!blit) { SDL_InvalidateMap(map); return SDL_SetError("Blit combination not supported"); } diff --git a/vs/sdl2/src/video/SDL_blit.h b/vs/sdl2/src/video/SDL_blit.h index fb4bb67309..731ea63753 100644 --- a/vs/sdl2/src/video/SDL_blit.h +++ b/vs/sdl2/src/video/SDL_blit.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit_0.c b/vs/sdl2/src/video/SDL_blit_0.c index 8be309140b..e7750ddb3d 100644 --- a/vs/sdl2/src/video/SDL_blit_0.c +++ b/vs/sdl2/src/video/SDL_blit_0.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,8 +27,11 @@ /* Functions to blit from bitmaps to other surfaces */ -static void BlitBto1(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int c; int width, height; Uint8 *src, *map, *dst; @@ -42,22 +45,28 @@ static void BlitBto1(SDL_BlitInfo *info) dst = info->dst; dstskip = info->dst_skip; map = info->table; - srcskip += width - (width + 7) / 8; + + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; if (map) { - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { *dst = map[bit]; } dst++; - byte >>= 1; + byte >>= srcbpp; } src += srcskip; dst += dstskip; @@ -66,34 +75,34 @@ static void BlitBto1(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { *dst = map[bit]; } dst++; - byte <<= 1; + byte <<= srcbpp; } src += srcskip; dst += dstskip; } } } else { - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { *dst = bit; } dst++; - byte >>= 1; + byte >>= srcbpp; } src += srcskip; dst += dstskip; @@ -102,15 +111,15 @@ static void BlitBto1(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { *dst = bit; } dst++; - byte <<= 1; + byte <<= srcbpp; } src += srcskip; dst += dstskip; @@ -119,8 +128,11 @@ static void BlitBto1(SDL_BlitInfo *info) } } -static void BlitBto2(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int c; int width, height; Uint8 *src; @@ -135,20 +147,26 @@ static void BlitBto2(SDL_BlitInfo *info) dst = (Uint16 *)info->dst; dstskip = info->dst_skip / 2; map = (Uint16 *)info->table; - srcskip += width - (width + 7) / 8; - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { *dst = map[bit]; } - byte >>= 1; + byte >>= srcbpp; dst++; } src += srcskip; @@ -158,14 +176,14 @@ static void BlitBto2(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { *dst = map[bit]; } - byte <<= 1; + byte <<= srcbpp; dst++; } src += srcskip; @@ -174,8 +192,11 @@ static void BlitBto2(SDL_BlitInfo *info) } } -static void BlitBto3(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int c, o; int width, height; Uint8 *src, *map, *dst; @@ -189,23 +210,29 @@ static void BlitBto3(SDL_BlitInfo *info) dst = info->dst; dstskip = info->dst_skip; map = info->table; - srcskip += width - (width + 7) / 8; - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { o = bit * 4; dst[0] = map[o++]; dst[1] = map[o++]; dst[2] = map[o++]; } - byte >>= 1; + byte >>= srcbpp; dst += 3; } src += srcskip; @@ -215,17 +242,17 @@ static void BlitBto3(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { o = bit * 4; dst[0] = map[o++]; dst[1] = map[o++]; dst[2] = map[o++]; } - byte <<= 1; + byte <<= srcbpp; dst += 3; } src += srcskip; @@ -234,8 +261,11 @@ static void BlitBto3(SDL_BlitInfo *info) } } -static void BlitBto4(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width, height; Uint8 *src; Uint32 *map, *dst; @@ -250,20 +280,26 @@ static void BlitBto4(SDL_BlitInfo *info) dst = (Uint32 *)info->dst; dstskip = info->dst_skip / 4; map = (Uint32 *)info->table; - srcskip += width - (width + 7) / 8; - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { *dst = map[bit]; } - byte >>= 1; + byte >>= srcbpp; dst++; } src += srcskip; @@ -273,14 +309,14 @@ static void BlitBto4(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { *dst = map[bit]; } - byte <<= 1; + byte <<= srcbpp; dst++; } src += srcskip; @@ -289,8 +325,11 @@ static void BlitBto4(SDL_BlitInfo *info) } } -static void BlitBto1Key(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -302,22 +341,27 @@ static void BlitBto1Key(SDL_BlitInfo *info) int c; /* Set up some basic variables */ - srcskip += width - (width + 7) / 8; + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; if (palmap) { - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { *dst = palmap[bit]; } dst++; - byte >>= 1; + byte >>= srcbpp; } src += srcskip; dst += dstskip; @@ -326,34 +370,34 @@ static void BlitBto1Key(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { *dst = palmap[bit]; } dst++; - byte <<= 1; + byte <<= srcbpp; } src += srcskip; dst += dstskip; } } } else { - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { *dst = bit; } dst++; - byte >>= 1; + byte >>= srcbpp; } src += srcskip; dst += dstskip; @@ -362,15 +406,15 @@ static void BlitBto1Key(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { *dst = bit; } dst++; - byte <<= 1; + byte <<= srcbpp; } src += srcskip; dst += dstskip; @@ -379,8 +423,11 @@ static void BlitBto1Key(SDL_BlitInfo *info) } } -static void BlitBto2Key(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -392,21 +439,26 @@ static void BlitBto2Key(SDL_BlitInfo *info) int c; /* Set up some basic variables */ - srcskip += width - (width + 7) / 8; + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; dstskip /= 2; - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { *dstp = ((Uint16 *)palmap)[bit]; } - byte >>= 1; + byte >>= srcbpp; dstp++; } src += srcskip; @@ -416,14 +468,14 @@ static void BlitBto2Key(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { *dstp = ((Uint16 *)palmap)[bit]; } - byte <<= 1; + byte <<= srcbpp; dstp++; } src += srcskip; @@ -432,8 +484,11 @@ static void BlitBto2Key(SDL_BlitInfo *info) } } -static void BlitBto3Key(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -445,20 +500,25 @@ static void BlitBto3Key(SDL_BlitInfo *info) int c; /* Set up some basic variables */ - srcskip += width - (width + 7) / 8; - - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { SDL_memcpy(dst, &palmap[bit * 4], 3); } - byte >>= 1; + byte >>= srcbpp; dst += 3; } src += srcskip; @@ -468,14 +528,14 @@ static void BlitBto3Key(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { SDL_memcpy(dst, &palmap[bit * 4], 3); } - byte <<= 1; + byte <<= srcbpp; dst += 3; } src += srcskip; @@ -484,8 +544,11 @@ static void BlitBto3Key(SDL_BlitInfo *info) } } -static void BlitBto4Key(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -497,21 +560,26 @@ static void BlitBto4Key(SDL_BlitInfo *info) int c; /* Set up some basic variables */ - srcskip += width - (width + 7) / 8; + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; dstskip /= 4; - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { *dstp = ((Uint32 *)palmap)[bit]; } - byte >>= 1; + byte >>= srcbpp; dstp++; } src += srcskip; @@ -521,14 +589,14 @@ static void BlitBto4Key(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { *dstp = ((Uint32 *)palmap)[bit]; } - byte <<= 1; + byte <<= srcbpp; dstp++; } src += srcskip; @@ -537,8 +605,11 @@ static void BlitBto4Key(SDL_BlitInfo *info) } } -static void BlitBtoNAlpha(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBtoNAlpha(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -556,16 +627,21 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info) /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; - srcskip += width - (width + 7) / 8; - - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (1) { sR = srcpal[bit].r; sG = srcpal[bit].g; @@ -574,7 +650,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info) ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } - byte >>= 1; + byte >>= srcbpp; dst += dstbpp; } src += srcskip; @@ -584,10 +660,10 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (1) { sR = srcpal[bit].r; sG = srcpal[bit].g; @@ -596,7 +672,7 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info) ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } - byte <<= 1; + byte <<= srcbpp; dst += dstbpp; } src += srcskip; @@ -605,8 +681,11 @@ static void BlitBtoNAlpha(SDL_BlitInfo *info) } } -static void BlitBtoNAlphaKey(SDL_BlitInfo *info) +SDL_FORCE_INLINE void BlitBtoNAlphaKey(SDL_BlitInfo *info, const Uint32 srcbpp) { + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + int width = info->dst_w; int height = info->dst_h; Uint8 *src = info->src; @@ -626,16 +705,21 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info) /* Set up some basic variables */ dstbpp = dstfmt->BytesPerPixel; - srcskip += width - (width + 7) / 8; - - if (info->src_fmt->format == SDL_PIXELFORMAT_INDEX1LSB) { + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x01); + bit = (byte & mask); if (bit != ckey) { sR = srcpal[bit].r; sG = srcpal[bit].g; @@ -644,7 +728,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info) ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } - byte >>= 1; + byte >>= srcbpp; dst += dstbpp; } src += srcskip; @@ -654,10 +738,10 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info) while (height--) { Uint8 byte = 0, bit; for (c = 0; c < width; ++c) { - if (!(c & 7)) { + if (!(c & align)) { byte = *src++; } - bit = (byte & 0x80) >> 7; + bit = (byte >> (8 - srcbpp)) & mask; if (bit != ckey) { sR = srcpal[bit].r; sG = srcpal[bit].g; @@ -666,7 +750,7 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info) ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); } - byte <<= 1; + byte <<= srcbpp; dst += dstbpp; } src += srcskip; @@ -675,121 +759,226 @@ static void BlitBtoNAlphaKey(SDL_BlitInfo *info) } } -static const SDL_BlitFunc bitmap_blit[] = { - (SDL_BlitFunc)NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4 + + +static void Blit1bto1(SDL_BlitInfo *info) { + BlitBto1(info, 1); +} + +static void Blit1bto2(SDL_BlitInfo *info) { + BlitBto2(info, 1); +} + +static void Blit1bto3(SDL_BlitInfo *info) { + BlitBto3(info, 1); +} + +static void Blit1bto4(SDL_BlitInfo *info) { + BlitBto4(info, 1); +} + +static const SDL_BlitFunc bitmap_blit_1b[] = { + (SDL_BlitFunc)NULL, Blit1bto1, Blit1bto2, Blit1bto3, Blit1bto4 }; -static const SDL_BlitFunc colorkey_blit[] = { - (SDL_BlitFunc)NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key +static void Blit1bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 1); +} + +static void Blit1bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 1); +} + +static void Blit1bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 1); +} + +static void Blit1bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 1); +} + +static const SDL_BlitFunc colorkey_blit_1b[] = { + (SDL_BlitFunc)NULL, Blit1bto1Key, Blit1bto2Key, Blit1bto3Key, Blit1bto4Key }; -static void Blit4bto4(SDL_BlitInfo *info) +static void Blit1btoNAlpha(SDL_BlitInfo *info) { - int width = info->dst_w; - int height = info->dst_h; - Uint8 *src = info->src; - Uint32 *dst = (Uint32 *)info->dst; - int srcskip = info->src_skip; - int dstskip = info->dst_skip; - Uint32 *map = (Uint32 *)info->table; - int c; + BlitBtoNAlpha(info, 1); +} - /* Set up some basic variables */ - srcskip += width - (width + 1) / 2; +static void Blit1btoNAlphaKey(SDL_BlitInfo *info) +{ + BlitBtoNAlphaKey(info, 1); +} - while (height--) { - Uint8 byte = 0, bit; - for (c = 0; c < width; ++c) { - if (!(c & 0x1)) { - byte = *src++; - } - bit = (byte & 0xF0) >> 4; - if (1) { - *dst = map[bit]; - } - byte <<= 4; - dst++; - } - src += srcskip; - dst = (Uint32 *)((Uint8 *)dst + dstskip); - } + + +static void Blit2bto1(SDL_BlitInfo *info) { + BlitBto1(info, 2); } -static void Blit4bto4Key(SDL_BlitInfo *info) +static void Blit2bto2(SDL_BlitInfo *info) { + BlitBto2(info, 2); +} + +static void Blit2bto3(SDL_BlitInfo *info) { + BlitBto3(info, 2); +} + +static void Blit2bto4(SDL_BlitInfo *info) { + BlitBto4(info, 2); +} + +static const SDL_BlitFunc bitmap_blit_2b[] = { + (SDL_BlitFunc)NULL, Blit2bto1, Blit2bto2, Blit2bto3, Blit2bto4 +}; + +static void Blit2bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 2); +} + +static void Blit2bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 2); +} + +static void Blit2bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 2); +} + +static void Blit2bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 2); +} + +static const SDL_BlitFunc colorkey_blit_2b[] = { + (SDL_BlitFunc)NULL, Blit2bto1Key, Blit2bto2Key, Blit2bto3Key, Blit2bto4Key +}; + +static void Blit2btoNAlpha(SDL_BlitInfo *info) { - int width = info->dst_w; - int height = info->dst_h; - Uint8 *src = info->src; - Uint32 *dst = (Uint32 *)info->dst; - int srcskip = info->src_skip; - int dstskip = info->dst_skip; - Uint32 ckey = info->colorkey; - Uint32 *map = (Uint32 *)info->table; - int c; + BlitBtoNAlpha(info, 2); +} - /* Set up some basic variables */ - srcskip += width - (width + 1) / 2; +static void Blit2btoNAlphaKey(SDL_BlitInfo *info) +{ + BlitBtoNAlphaKey(info, 2); +} - while (height--) { - Uint8 byte = 0, bit; - for (c = 0; c < width; ++c) { - if (!(c & 0x1)) { - byte = *src++; - } - bit = (byte & 0xF0) >> 4; - if (bit != ckey) { - *dst = map[bit]; - } - byte <<= 4; - dst++; - } - src += srcskip; - dst = (Uint32 *)((Uint8 *)dst + dstskip); - } + + +static void Blit4bto1(SDL_BlitInfo *info) { + BlitBto1(info, 4); +} + +static void Blit4bto2(SDL_BlitInfo *info) { + BlitBto2(info, 4); +} + +static void Blit4bto3(SDL_BlitInfo *info) { + BlitBto3(info, 4); +} + +static void Blit4bto4(SDL_BlitInfo *info) { + BlitBto4(info, 4); +} + +static const SDL_BlitFunc bitmap_blit_4b[] = { + (SDL_BlitFunc)NULL, Blit4bto1, Blit4bto2, Blit4bto3, Blit4bto4 +}; + +static void Blit4bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 4); +} + +static void Blit4bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 4); +} + +static void Blit4bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 4); +} + +static void Blit4bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 4); } +static const SDL_BlitFunc colorkey_blit_4b[] = { + (SDL_BlitFunc)NULL, Blit4bto1Key, Blit4bto2Key, Blit4bto3Key, Blit4bto4Key +}; + +static void Blit4btoNAlpha(SDL_BlitInfo *info) +{ + BlitBtoNAlpha(info, 4); +} + +static void Blit4btoNAlphaKey(SDL_BlitInfo *info) +{ + BlitBtoNAlphaKey(info, 4); +} + + + SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface) { int which; - /* 4bits to 32bits */ - if (surface->format->BitsPerPixel == 4) { - if (surface->map->dst->format->BytesPerPixel == 4) { - switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { - case 0: - return Blit4bto4; + if (surface->map->dst->format->BitsPerPixel < 8) { + which = 0; + } else { + which = surface->map->dst->format->BytesPerPixel; + } + + if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX1) { + switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + return bitmap_blit_1b[which]; - case SDL_COPY_COLORKEY: - return Blit4bto4Key; - } + case SDL_COPY_COLORKEY: + return colorkey_blit_1b[which]; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit1btoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit1btoNAlphaKey : (SDL_BlitFunc)NULL; } - /* We don't fully support 4-bit packed pixel modes */ return NULL; } - if (surface->format->BitsPerPixel != 1) { - /* We don't support sub 8-bit packed pixel modes */ - return (SDL_BlitFunc) NULL; - } - if (surface->map->dst->format->BitsPerPixel < 8) { - which = 0; - } else { - which = surface->map->dst->format->BytesPerPixel; + if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX2) { + switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + return bitmap_blit_2b[which]; + + case SDL_COPY_COLORKEY: + return colorkey_blit_2b[which]; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit2btoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit2btoNAlphaKey : (SDL_BlitFunc)NULL; + } + return NULL; } - switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { - case 0: - return bitmap_blit[which]; - case SDL_COPY_COLORKEY: - return colorkey_blit[which]; + if (SDL_PIXELTYPE(surface->format->format) == SDL_PIXELTYPE_INDEX4) { + switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + return bitmap_blit_4b[which]; - case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: - return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc) NULL; + case SDL_COPY_COLORKEY: + return colorkey_blit_4b[which]; - case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: - return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc) NULL; + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit4btoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit4btoNAlphaKey : (SDL_BlitFunc)NULL; + } + return NULL; } - return (SDL_BlitFunc) NULL; + + return NULL; } #endif /* SDL_HAVE_BLIT_0 */ diff --git a/vs/sdl2/src/video/SDL_blit_1.c b/vs/sdl2/src/video/SDL_blit_1.c index a616067e3f..93fdb3ec1b 100644 --- a/vs/sdl2/src/video/SDL_blit_1.c +++ b/vs/sdl2/src/video/SDL_blit_1.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit_A.c b/vs/sdl2/src/video/SDL_blit_A.c index 316f3f369f..2cf00e0a2c 100644 --- a/vs/sdl2/src/video/SDL_blit_A.c +++ b/vs/sdl2/src/video/SDL_blit_A.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -412,7 +412,7 @@ static void BlitRGBtoRGBPixelAlphaMMX(SDL_BlitInfo *info) #endif /* __MMX__ */ -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS void BlitARGBto565PixelAlphaARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); static void BlitARGBto565PixelAlphaARMSIMD(SDL_BlitInfo *info) @@ -442,7 +442,7 @@ static void BlitRGBtoRGBPixelAlphaARMSIMD(SDL_BlitInfo *info) } #endif -#if SDL_ARM_NEON_BLITTERS +#ifdef SDL_ARM_NEON_BLITTERS void BlitARGBto565PixelAlphaARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); static void BlitARGBto565PixelAlphaARMNEON(SDL_BlitInfo *info) @@ -1427,7 +1427,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-pixel alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1PixelAlpha; } else { /* RGB332 has no palette ! */ @@ -1435,14 +1435,14 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) } case 2: -#if SDL_ARM_NEON_BLITTERS || SDL_ARM_SIMD_BLITTERS +#if defined(SDL_ARM_NEON_BLITTERS) || defined(SDL_ARM_SIMD_BLITTERS) if (sf->BytesPerPixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && df->Gmask == 0x7e0 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { -#if SDL_ARM_NEON_BLITTERS +#ifdef SDL_ARM_NEON_BLITTERS if (SDL_HasNEON()) { return BlitARGBto565PixelAlphaARMNEON; } #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS if (SDL_HasARMSIMD()) { return BlitARGBto565PixelAlphaARMSIMD; } @@ -1475,12 +1475,12 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) } #endif /* __MMX__ || __3dNOW__ */ if (sf->Amask == 0xff000000) { -#if SDL_ARM_NEON_BLITTERS +#ifdef SDL_ARM_NEON_BLITTERS if (SDL_HasNEON()) { return BlitRGBtoRGBPixelAlphaARMNEON; } #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS if (SDL_HasARMSIMD()) { return BlitRGBtoRGBPixelAlphaARMSIMD; } @@ -1505,7 +1505,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-surface alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlpha; } else { /* RGB332 has no palette ! */ @@ -1560,7 +1560,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) if (sf->Amask == 0) { if (df->BytesPerPixel == 1) { - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlphaKey; } else { /* RGB332 has no palette ! */ diff --git a/vs/sdl2/src/video/SDL_blit_N.c b/vs/sdl2/src/video/SDL_blit_N.c index 7c0b0106d4..123d0aad03 100644 --- a/vs/sdl2/src/video/SDL_blit_N.c +++ b/vs/sdl2/src/video/SDL_blit_N.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ enum blit_features BLIT_FEATURE_HAS_ARM_SIMD = 8 }; -#if SDL_ALTIVEC_BLITTERS +#ifdef SDL_ALTIVEC_BLITTERS #ifdef HAVE_ALTIVEC_H #include #endif @@ -903,7 +903,7 @@ static enum blit_features GetBlitFeatures(void) return features; } -#if __MWERKS__ +#ifdef __MWERKS__ #pragma altivec_model off #endif #else @@ -911,7 +911,7 @@ static enum blit_features GetBlitFeatures(void) #define GetBlitFeatures() ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0) | (SDL_HasARMSIMD() ? BLIT_FEATURE_HAS_ARM_SIMD : 0)) #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS void Blit_BGR888_RGB888ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t *src, int32_t src_stride); static void Blit_BGR888_RGB888ARMSIMD(SDL_BlitInfo *info) @@ -977,7 +977,7 @@ static void Blit_RGB888_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -1091,7 +1091,7 @@ static void Blit_RGB101010_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2115,7 +2115,7 @@ static void BlitNto1(SDL_BlitInfo *info) srcfmt = info->src_fmt; srcbpp = srcfmt->BytesPerPixel; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2513,7 +2513,7 @@ static void BlitNto1Key(SDL_BlitInfo *info) srcbpp = srcfmt->BytesPerPixel; ckey &= rgbmask; - if (palmap == NULL) { + if (!palmap) { while (height--) { /* *INDENT-OFF* */ /* clang-format off */ DUFFS_LOOP( @@ -3221,14 +3221,14 @@ static const struct blit_table normal_blit_1[] = { }; static const struct blit_table normal_blit_2[] = { -#if SDL_ALTIVEC_BLITTERS +#ifdef SDL_ALTIVEC_BLITTERS /* has-altivec */ { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, { 0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS { 0x00000F00, 0x000000F0, 0x0000000F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, BLIT_FEATURE_HAS_ARM_SIMD, Blit_RGB444_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, #endif @@ -3288,7 +3288,7 @@ static const struct blit_table normal_blit_3[] = { }; static const struct blit_table normal_blit_4[] = { -#if SDL_ALTIVEC_BLITTERS +#ifdef SDL_ALTIVEC_BLITTERS /* has-altivec | dont-use-prefetch */ { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, BLIT_FEATURE_HAS_ALTIVEC | BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, @@ -3299,7 +3299,7 @@ static const struct blit_table normal_blit_4[] = { { 0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB888_RGB565Altivec, NO_ALPHA }, #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, BLIT_FEATURE_HAS_ARM_SIMD, Blit_BGR888_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, #endif @@ -3437,7 +3437,7 @@ SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) } else if (dstfmt->BytesPerPixel == 1) { return BlitNto1Key; } else { -#if SDL_ALTIVEC_BLITTERS +#ifdef SDL_ALTIVEC_BLITTERS if ((srcfmt->BytesPerPixel == 4) && (dstfmt->BytesPerPixel == 4) && SDL_HasAltiVec()) { return Blit32to32KeyAltivec; } else diff --git a/vs/sdl2/src/video/SDL_blit_auto.c b/vs/sdl2/src/video/SDL_blit_auto.c index 1561d10690..b05dc4a02e 100644 --- a/vs/sdl2/src/video/SDL_blit_auto.c +++ b/vs/sdl2/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-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,12 @@ static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) { - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -114,12 +114,12 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -207,12 +207,12 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -321,12 +321,12 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -392,12 +392,12 @@ static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -478,12 +478,12 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -571,12 +571,12 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -685,12 +685,12 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -756,12 +756,12 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info) { Uint32 pixel; const Uint32 A = 0xFF; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -842,12 +842,12 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -940,12 +940,12 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1055,12 +1055,12 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1127,12 +1127,12 @@ static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1213,12 +1213,12 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1306,12 +1306,12 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1420,12 +1420,12 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1489,12 +1489,12 @@ 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; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1572,12 +1572,12 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1665,12 +1665,12 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1779,12 +1779,12 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1851,12 +1851,12 @@ static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info) Uint32 pixel; const Uint32 A = 0xFF; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -1938,12 +1938,12 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2036,12 +2036,12 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) Uint32 pixel; const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2151,12 +2151,12 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2222,12 +2222,12 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) { Uint32 pixel; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2315,12 +2315,12 @@ static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2416,12 +2416,12 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2531,12 +2531,12 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2605,12 +2605,12 @@ static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2699,12 +2699,12 @@ static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2800,12 +2800,12 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2915,12 +2915,12 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -2987,12 +2987,12 @@ 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; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3079,12 +3079,12 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3186,12 +3186,12 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateA = info->a; Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3305,12 +3305,12 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3379,12 +3379,12 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) { Uint32 pixel; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3472,12 +3472,12 @@ static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3573,12 +3573,12 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3688,12 +3688,12 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3762,12 +3762,12 @@ static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3856,12 +3856,12 @@ static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -3957,12 +3957,12 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4072,12 +4072,12 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4145,12 +4145,12 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) { Uint32 pixel; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4239,12 +4239,12 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4346,12 +4346,12 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateA = info->a; Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4465,12 +4465,12 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4540,12 +4540,12 @@ static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4634,12 +4634,12 @@ static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4735,12 +4735,12 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4850,12 +4850,12 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -4923,12 +4923,12 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) { Uint32 pixel; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5016,12 +5016,12 @@ static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5117,12 +5117,12 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5232,12 +5232,12 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5306,12 +5306,12 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5401,12 +5401,12 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5508,12 +5508,12 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateA = info->a; Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5627,12 +5627,12 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5702,12 +5702,12 @@ static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5796,12 +5796,12 @@ static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -5897,12 +5897,12 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6012,12 +6012,12 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6085,12 +6085,12 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) { Uint32 pixel; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6178,12 +6178,12 @@ static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6279,12 +6279,12 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateB = info->b; Uint32 pixel; Uint32 R, G, B; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6394,12 +6394,12 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6468,12 +6468,12 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) { Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6563,12 +6563,12 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6670,12 +6670,12 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) const Uint32 modulateA = info->a; Uint32 pixel; Uint32 R, G, B, A; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { @@ -6789,12 +6789,12 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { diff --git a/vs/sdl2/src/video/SDL_blit_auto.h b/vs/sdl2/src/video/SDL_blit_auto.h index f7f89c7c09..1b7f227d74 100644 --- a/vs/sdl2/src/video/SDL_blit_auto.h +++ b/vs/sdl2/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-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit_copy.c b/vs/sdl2/src/video/SDL_blit_copy.c index b772a55409..47dafb59e2 100644 --- a/vs/sdl2/src/video/SDL_blit_copy.c +++ b/vs/sdl2/src/video/SDL_blit_copy.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit_copy.h b/vs/sdl2/src/video/SDL_blit_copy.h index a245db8e81..0979a87da4 100644 --- a/vs/sdl2/src/video/SDL_blit_copy.h +++ b/vs/sdl2/src/video/SDL_blit_copy.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_blit_slow.c b/vs/sdl2/src/video/SDL_blit_slow.c index 9ea5c384d1..7696dcf925 100644 --- a/vs/sdl2/src/video/SDL_blit_slow.c +++ b/vs/sdl2/src/video/SDL_blit_slow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) Uint32 srcR, srcG, srcB, srcA; Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; SDL_PixelFormat *src_fmt = info->src_fmt; SDL_PixelFormat *dst_fmt = info->dst_fmt; int srcbpp = src_fmt->BytesPerPixel; @@ -69,8 +69,8 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) srcfmt_val = detect_format(src_fmt); dstfmt_val = detect_format(dst_fmt); - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; /* start at the middle of pixel */ while (info->dst_h--) { @@ -106,15 +106,20 @@ void SDL_Blit_Slow(SDL_BlitInfo *info) continue; } } - if (FORMAT_HAS_ALPHA(dstfmt_val)) { - DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); - } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { - DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); - dstA = 0xFF; + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + if (FORMAT_HAS_ALPHA(dstfmt_val)) { + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + } else if (FORMAT_HAS_NO_ALPHA(dstfmt_val)) { + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + } else { + /* SDL_PIXELFORMAT_ARGB2101010 */ + dstpixel = *((Uint32 *) (dst)); + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + } } else { - /* SDL_PIXELFORMAT_ARGB2101010 */ - dstpixel = *((Uint32 *)(dst)); - RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + /* don't care */ + dstR = dstG = dstB = dstA = 0; } if (flags & SDL_COPY_MODULATE_COLOR) { diff --git a/vs/sdl2/src/video/SDL_blit_slow.h b/vs/sdl2/src/video/SDL_blit_slow.h index 37bc7ca649..05b1dca227 100644 --- a/vs/sdl2/src/video/SDL_blit_slow.h +++ b/vs/sdl2/src/video/SDL_blit_slow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_bmp.c b/vs/sdl2/src/video/SDL_bmp.c index 82147a5833..10e99fb041 100644 --- a/vs/sdl2/src/video/SDL_bmp.c +++ b/vs/sdl2/src/video/SDL_bmp.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -238,7 +238,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) /* Make sure we are passed a valid data source */ surface = NULL; was_error = SDL_FALSE; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); was_error = SDL_TRUE; goto done; @@ -424,7 +424,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) surface = SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { was_error = SDL_TRUE; goto done; } @@ -667,7 +667,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) } #endif /* SAVE_32BIT_BMP */ - if (surface->format->palette != NULL && !save32bit) { + if (surface->format->palette && !save32bit) { if (surface->format->BitsPerPixel == 8) { intermediate_surface = surface; } else { @@ -697,7 +697,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24); } intermediate_surface = SDL_ConvertSurface(surface, &format, 0); - if (intermediate_surface == NULL) { + if (!intermediate_surface) { SDL_SetError("Couldn't convert image to %d bpp", format.BitsPerPixel); } diff --git a/vs/sdl2/src/video/SDL_clipboard.c b/vs/sdl2/src/video/SDL_clipboard.c index e18668ceac..3111a63b65 100644 --- a/vs/sdl2/src/video/SDL_clipboard.c +++ b/vs/sdl2/src/video/SDL_clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +27,11 @@ int SDL_SetClipboardText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetClipboardText) { @@ -47,11 +47,11 @@ int SDL_SetPrimarySelectionText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set primary selection text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetPrimarySelectionText) { @@ -67,7 +67,7 @@ char *SDL_GetClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get clipboard text"); return SDL_strdup(""); } @@ -76,7 +76,7 @@ char *SDL_GetClipboardText(void) return _this->GetClipboardText(_this); } else { const char *text = _this->clipboard_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -87,7 +87,7 @@ char *SDL_GetPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get primary selection text"); return SDL_strdup(""); } @@ -96,7 +96,7 @@ char *SDL_GetPrimarySelectionText(void) return _this->GetPrimarySelectionText(_this); } else { const char *text = _this->primary_selection_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -107,7 +107,7 @@ SDL_bool SDL_HasClipboardText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard text"); return SDL_FALSE; } @@ -127,7 +127,7 @@ SDL_bool SDL_HasPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check primary selection text"); return SDL_FALSE; } diff --git a/vs/sdl2/src/video/SDL_egl.c b/vs/sdl2/src/video/SDL_egl.c index 8e5f165b56..a89c0e812c 100644 --- a/vs/sdl2/src/video/SDL_egl.c +++ b/vs/sdl2/src/video/SDL_egl.c @@ -1,6 +1,6 @@ /* * Simple DirectMedia Layer - * Copyright (C) 1997-2023 Sam Lantinga + * Copyright (C) 1997-2024 Sam Lantinga * * 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,16 +20,16 @@ */ #include "../SDL_internal.h" -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT +#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) #include "../core/windows/SDL_windows.h" #endif -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include #include "../video/android/SDL_androidvideo.h" #endif -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI #include #endif @@ -57,7 +57,7 @@ #define EGL_PRESENT_OPAQUE_EXT 0x31DF #endif /* EGL_EXT_present_opaque */ -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI /* Raspbian places the OpenGL ES/EGL binaries in a non standard path */ #define DEFAULT_EGL (vc4 ? "libEGL.so.1" : "libbrcmEGL.so") #define DEFAULT_OGL_ES2 (vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so") @@ -66,21 +66,21 @@ #define DEFAULT_OGL_ES_PVR (vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so") #define DEFAULT_OGL_ES (vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so") -#elif SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_VIVANTE +#elif defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_VIVANTE) /* Android */ #define DEFAULT_EGL "libEGL.so" #define DEFAULT_OGL_ES2 "libGLESv2.so" #define DEFAULT_OGL_ES_PVR "libGLES_CM.so" #define DEFAULT_OGL_ES "libGLESv1_CM.so" -#elif SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT +#elif defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) /* EGL AND OpenGL ES support via ANGLE */ #define DEFAULT_EGL "libEGL.dll" #define DEFAULT_OGL_ES2 "libGLESv2.dll" #define DEFAULT_OGL_ES_PVR "libGLES_CM.dll" #define DEFAULT_OGL_ES "libGLESv1_CM.dll" -#elif SDL_VIDEO_DRIVER_COCOA +#elif defined(SDL_VIDEO_DRIVER_COCOA) /* EGL AND OpenGL ES support via ANGLE */ #define DEFAULT_EGL "libEGL.dylib" #define DEFAULT_OGL_ES2 "libGLESv2.dylib" @@ -105,7 +105,7 @@ #define DEFAULT_OGL_ES "libGLESv1_CM.so.1" #endif /* SDL_VIDEO_DRIVER_RPI */ -#if SDL_VIDEO_OPENGL && !SDL_VIDEO_VITA_PVR_OGL +#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_VITA_PVR_OGL) #include "SDL_opengl.h" #endif @@ -178,7 +178,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext const char *ext_start; /* Invalid extensions can be rejected early */ - if (ext == NULL || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { + if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */ return SDL_FALSE; } @@ -191,7 +191,7 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext * 1 If set, the client extension is masked and not present to SDL. */ ext_override = SDL_getenv(ext); - if (ext_override != NULL) { + if (ext_override) { int disable_ext = SDL_atoi(ext_override); if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) { return SDL_FALSE; @@ -217,12 +217,12 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext return SDL_FALSE; } - if (egl_extstr != NULL) { + if (egl_extstr) { ext_start = egl_extstr; while (*ext_start) { ext_start = SDL_strstr(ext_start, ext); - if (ext_start == NULL) { + if (!ext_start) { return SDL_FALSE; } /* Check if the match is not just a substring of one of the extensions */ @@ -245,24 +245,24 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext void *SDL_EGL_GetProcAddress(_THIS, const char *proc) { void *retval = NULL; - if (_this->egl_data != NULL) { + if (_this->egl_data) { const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); /* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */ - if (retval == NULL && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } #if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ /* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */ - if (retval == NULL) { + if (!retval) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); } #endif /* Try eglGetProcAddress if we're on <= 1.4 and still searching... */ - if (retval == NULL && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } } @@ -295,14 +295,14 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) { void *egl_dll_handle = NULL, *opengl_dll_handle = NULL; const char *path = NULL; -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT +#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) const char *d3dcompiler; #endif -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI SDL_bool vc4 = (0 == access("/sys/module/vc4/", F_OK)); #endif -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_WINRT +#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_WINRT) d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER); if (d3dcompiler) { if (SDL_strcasecmp(d3dcompiler, "none") != 0) { @@ -336,17 +336,17 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) #if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA) /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); - if (path != NULL) { + if (path) { opengl_dll_handle = SDL_LoadObject(path); } - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { if (_this->gl_config.major_version > 1) { path = DEFAULT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -355,12 +355,12 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) } else { path = DEFAULT_OGL_ES; opengl_dll_handle = SDL_LoadObject(path); - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = DEFAULT_OGL_ES_PVR; opengl_dll_handle = SDL_LoadObject(path); } #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -372,7 +372,7 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) path = DEFAULT_OGL; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = ALT_OGL; opengl_dll_handle = SDL_LoadObject(path); } @@ -382,34 +382,34 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) } _this->egl_data->opengl_dll_handle = opengl_dll_handle; - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { return SDL_SetError("Could not initialize OpenGL / GLES library"); } /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ - if (egl_path != NULL) { + if (egl_path) { egl_dll_handle = SDL_LoadObject(egl_path); } /* Try loading a EGL symbol, if it does not work try the default library paths */ - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } path = SDL_getenv("SDL_VIDEO_EGL_DRIVER"); - if (path == NULL) { + if (!path) { path = DEFAULT_EGL; } egl_dll_handle = SDL_LoadObject(path); #ifdef ALT_EGL - if (egl_dll_handle == NULL && !vc4) { + if (!egl_dll_handle && !vc4) { path = ALT_EGL; egl_dll_handle = SDL_LoadObject(path); } #endif - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } return SDL_SetError("Could not load EGL library"); @@ -419,7 +419,7 @@ static int SDL_EGL_LoadLibraryInternal(_THIS, const char *egl_path) #endif _this->egl_data->egl_dll_handle = egl_dll_handle; -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA _this->egl_data->opengl_dll_handle = opengl_dll_handle; #endif @@ -535,7 +535,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di } #endif /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */ - if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) { + if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay)) { _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); } if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { @@ -578,11 +578,11 @@ int SDL_EGL_InitializeOffscreen(_THIS, int device) } /* Check for all extensions that are optional until used and fail if any is missing */ - if (_this->egl_data->eglQueryDevicesEXT == NULL) { + if (!_this->egl_data->eglQueryDevicesEXT) { return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)"); } - if (_this->egl_data->eglGetPlatformDisplayEXT == NULL) { + if (!_this->egl_data->eglGetPlatformDisplayEXT) { return SDL_SetError("eglGetPlatformDisplayEXT is missing (EXT_platform_base not supported by the drivers?)"); } @@ -954,7 +954,7 @@ SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) share_context = (EGLContext)SDL_GL_GetCurrentContext(); } -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID if (_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) { /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset. * This is required because some Android devices like to complain about it @@ -1065,7 +1065,7 @@ SDL_GLContext SDL_EGL_CreateContext(_THIS, EGLSurface egl_surface) if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) { _this->gl_allow_no_surface = SDL_TRUE; } -#if SDL_VIDEO_OPENGL && !defined(SDL_VIDEO_DRIVER_VITA) +#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_DRIVER_VITA) } else { /* Desktop OpenGL supports it by default from version 3.0 on. */ void(APIENTRY * glGetIntegervFunc)(GLenum pname, GLint * params); @@ -1179,7 +1179,7 @@ void SDL_EGL_DeleteContext(_THIS, SDL_GLContext context) EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) { -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID EGLint format_wanted; EGLint format_got; #endif @@ -1193,7 +1193,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) return EGL_NO_SURFACE; } -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID /* 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, @@ -1235,7 +1235,7 @@ EGLSurface *SDL_EGL_CreateSurface(_THIS, NativeWindowType nw) SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface"); } -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID format_got = ANativeWindow_getFormat(nw); Android_SetFormat(format_wanted, format_got); #endif diff --git a/vs/sdl2/src/video/SDL_egl_c.h b/vs/sdl2/src/video/SDL_egl_c.h index feb889a1cd..3fc2977662 100644 --- a/vs/sdl2/src/video/SDL_egl_c.h +++ b/vs/sdl2/src/video/SDL_egl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_egl_h_ #define SDL_egl_h_ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "SDL_egl.h" @@ -42,7 +42,7 @@ typedef struct SDL_EGL_VideoData EGLint egl_required_visual_id; SDL_bool is_offscreen; /* whether EGL display was offscreen */ EGLenum apitype; /* EGL_OPENGL_ES_API, EGL_OPENGL_API, etc */ - + EGLDisplay(EGLAPIENTRY *eglGetDisplay) (NativeDisplayType display); EGLDisplay(EGLAPIENTRY *eglGetPlatformDisplay) (EGLenum platform, void *native_display, @@ -53,21 +53,21 @@ typedef struct SDL_EGL_VideoData EGLBoolean(EGLAPIENTRY *eglInitialize) (EGLDisplay dpy, EGLint * major, EGLint * minor); EGLBoolean(EGLAPIENTRY *eglTerminate) (EGLDisplay dpy); - + void *(EGLAPIENTRY *eglGetProcAddress) (const char * procName); - + EGLBoolean(EGLAPIENTRY *eglChooseConfig) (EGLDisplay dpy, const EGLint * attrib_list, EGLConfig * configs, EGLint config_size, EGLint * num_config); - + EGLContext(EGLAPIENTRY *eglCreateContext) (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint * attrib_list); - + EGLBoolean(EGLAPIENTRY *eglDestroyContext) (EGLDisplay dpy, EGLContext ctx); - + EGLSurface(EGLAPIENTRY *eglCreatePbufferSurface)(EGLDisplay dpy, EGLConfig config, EGLint const* attrib_list); @@ -76,25 +76,25 @@ typedef struct SDL_EGL_VideoData NativeWindowType window, const EGLint * attrib_list); EGLBoolean(EGLAPIENTRY *eglDestroySurface) (EGLDisplay dpy, EGLSurface surface); - + EGLBoolean(EGLAPIENTRY *eglMakeCurrent) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); - + EGLBoolean(EGLAPIENTRY *eglSwapBuffers) (EGLDisplay dpy, EGLSurface draw); - + EGLBoolean(EGLAPIENTRY *eglSwapInterval) (EGLDisplay dpy, EGLint interval); - + const char *(EGLAPIENTRY *eglQueryString) (EGLDisplay dpy, EGLint name); EGLenum(EGLAPIENTRY *eglQueryAPI)(void); - + EGLBoolean(EGLAPIENTRY *eglGetConfigAttrib) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value); - + EGLBoolean(EGLAPIENTRY *eglWaitNative) (EGLint engine); EGLBoolean(EGLAPIENTRY *eglWaitGL)(void); - + EGLBoolean(EGLAPIENTRY *eglBindAPI)(EGLenum); EGLint(EGLAPIENTRY *eglGetError)(void); @@ -109,7 +109,7 @@ typedef struct SDL_EGL_VideoData EGLBoolean(EGLAPIENTRY *eglDestroySyncKHR)(EGLDisplay dpy, EGLSyncKHR sync); - EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync); + EGLint(EGLAPIENTRY *eglDupNativeFenceFDANDROID)(EGLDisplay dpy, EGLSyncKHR sync); EGLint(EGLAPIENTRY *eglWaitSyncKHR)(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); diff --git a/vs/sdl2/src/video/SDL_fillrect.c b/vs/sdl2/src/video/SDL_fillrect.c index 5687fb9510..d7d112fd14 100644 --- a/vs/sdl2/src/video/SDL_fillrect.c +++ b/vs/sdl2/src/video/SDL_fillrect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -233,12 +233,12 @@ static void SDL_FillRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h) */ int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillRect(): dst"); } /* If 'rect' == NULL, then fill the whole surface */ - if (rect == NULL) { + if (!rect) { rect = &dst->clip_rect; /* Don't attempt to fill if the surface's clip_rect is empty */ if (SDL_RectEmpty(rect)) { @@ -249,7 +249,7 @@ int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) return SDL_FillRects(dst, rect, 1, color); } -#if SDL_ARM_NEON_BLITTERS +#ifdef SDL_ARM_NEON_BLITTERS void FillRect8ARMNEONAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, uint8_t src); void FillRect16ARMNEONAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src); void FillRect32ARMNEONAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src); @@ -273,7 +273,7 @@ static void fill_32_neon(Uint8 *pixels, int pitch, Uint32 color, int w, int h) } #endif -#if SDL_ARM_SIMD_BLITTERS +#ifdef SDL_ARM_SIMD_BLITTERS void FillRect8ARMSIMDAsm(int32_t w, int32_t h, uint8_t *dst, int32_t dst_stride, uint8_t src); void FillRect16ARMSIMDAsm(int32_t w, int32_t h, uint16_t *dst, int32_t dst_stride, uint16_t src); void FillRect32ARMSIMDAsm(int32_t w, int32_t h, uint32_t *dst, int32_t dst_stride, uint32_t src); @@ -306,7 +306,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL; int i; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillRects(): dst"); } @@ -320,7 +320,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_SetError("SDL_FillRects(): You must lock the surface"); } - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_FillRects(): rects"); } @@ -341,8 +341,8 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_SetError("SDL_FillRects(): Unsupported surface format"); } -#if SDL_ARM_NEON_BLITTERS - if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { +#ifdef SDL_ARM_NEON_BLITTERS + if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_neon; @@ -356,8 +356,8 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } } #endif -#if SDL_ARM_SIMD_BLITTERS - if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { +#ifdef SDL_ARM_SIMD_BLITTERS + if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_simd; @@ -372,7 +372,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif - if (fill_function == NULL) { + if (!fill_function) { switch (dst->format->BytesPerPixel) { case 1: { diff --git a/vs/sdl2/src/video/SDL_pixels.c b/vs/sdl2/src/video/SDL_pixels.c index 65e33ab861..a6821784de 100644 --- a/vs/sdl2/src/video/SDL_pixels.c +++ b/vs/sdl2/src/video/SDL_pixels.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +91,8 @@ const char *SDL_GetPixelFormatName(Uint32 format) CASE(SDL_PIXELFORMAT_INDEX1LSB) CASE(SDL_PIXELFORMAT_INDEX1MSB) + CASE(SDL_PIXELFORMAT_INDEX2LSB) + CASE(SDL_PIXELFORMAT_INDEX2MSB) CASE(SDL_PIXELFORMAT_INDEX4LSB) CASE(SDL_PIXELFORMAT_INDEX4MSB) CASE(SDL_PIXELFORMAT_INDEX8) @@ -299,6 +301,9 @@ Uint32 SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bm case 1: /* SDL defaults to MSB ordering */ return SDL_PIXELFORMAT_INDEX1MSB; + case 2: + /* SDL defaults to MSB ordering */ + return SDL_PIXELFORMAT_INDEX2MSB; case 4: /* SDL defaults to MSB ordering */ return SDL_PIXELFORMAT_INDEX4MSB; @@ -518,7 +523,7 @@ SDL_PixelFormat *SDL_AllocFormat(Uint32 pixel_format) /* Allocate an empty pixel format structure, and initialize it */ format = SDL_malloc(sizeof(*format)); - if (format == NULL) { + if (!format) { SDL_AtomicUnlock(&formats_lock); SDL_OutOfMemory(); return NULL; @@ -616,7 +621,7 @@ void SDL_FreeFormat(SDL_PixelFormat *format) { SDL_PixelFormat *prev; - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return; } @@ -659,7 +664,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors) } palette = (SDL_Palette *)SDL_malloc(sizeof(*palette)); - if (palette == NULL) { + if (!palette) { SDL_OutOfMemory(); return NULL; } @@ -681,7 +686,7 @@ SDL_Palette *SDL_AllocPalette(int ncolors) int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette) { - if (format == NULL) { + if (!format) { return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format"); } @@ -712,7 +717,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int status = 0; /* Verify the parameters */ - if (palette == NULL) { + if (!palette) { return -1; } if (ncolors > (palette->ncolors - firstcolor)) { @@ -734,7 +739,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, void SDL_FreePalette(SDL_Palette *palette) { - if (palette == NULL) { + if (!palette) { SDL_InvalidParamError("palette"); return; } @@ -856,7 +861,7 @@ Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask; } else { return SDL_FindColor(format->palette, r, g, b, SDL_ALPHA_OPAQUE); @@ -870,7 +875,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask); } else { return SDL_FindColor(format->palette, r, g, b, a); @@ -880,7 +885,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uin void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -902,7 +907,7 @@ void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -943,7 +948,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) *identical = 0; } map = (Uint8 *)SDL_calloc(256, sizeof(Uint8)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -966,7 +971,7 @@ static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); map = (Uint8 *)SDL_calloc(256, bpp); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1002,7 +1007,7 @@ SDL_BlitMap *SDL_AllocBlitMap(void) /* Allocate the empty map */ map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1031,7 +1036,7 @@ void SDL_InvalidateAllBlitMap(SDL_Surface *surface) void SDL_InvalidateMap(SDL_BlitMap *map) { - if (map == NULL) { + if (!map) { return; } if (map->dst) { @@ -1070,7 +1075,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1to1(srcfmt->palette, dstfmt->palette, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1082,7 +1087,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1toN(srcfmt, src->map->info.r, src->map->info.g, src->map->info.b, src->map->info.a, dstfmt); - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1091,7 +1096,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) /* BitField --> Palette */ map->info.table = MapNto1(srcfmt, dstfmt, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1144,7 +1149,7 @@ void SDL_CalculateGammaRamp(float gamma, Uint16 * ramp) SDL_InvalidParamError("gamma"); return; } - if (ramp == NULL) { + if (!ramp) { SDL_InvalidParamError("ramp"); return; } diff --git a/vs/sdl2/src/video/SDL_pixels_c.h b/vs/sdl2/src/video/SDL_pixels_c.h index 1a6f6243aa..7b5eff3aac 100644 --- a/vs/sdl2/src/video/SDL_pixels_c.h +++ b/vs/sdl2/src/video/SDL_pixels_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_rect.c b/vs/sdl2/src/video/SDL_rect.c index 1b461d230f..7af1125d38 100644 --- a/vs/sdl2/src/video/SDL_rect.c +++ b/vs/sdl2/src/video/SDL_rect.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +38,10 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, } else if (height < 1) { SDL_InvalidParamError("height"); return SDL_FALSE; - } else if (rects == NULL) { + } else if (!rects) { SDL_InvalidParamError("rects"); return SDL_FALSE; - } else if (span == NULL) { + } else if (!span) { SDL_InvalidParamError("span"); return SDL_FALSE; } else if (numrects < 1) { @@ -89,6 +89,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, #define RECTTYPE SDL_Rect #define POINTTYPE SDL_Point #define SCALARTYPE int +#define BIGSCALARTYPE Sint64 #define COMPUTEOUTCODE ComputeOutCode #define SDL_HASINTERSECTION SDL_HasIntersection #define SDL_INTERSECTRECT SDL_IntersectRect @@ -101,6 +102,7 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, #define RECTTYPE SDL_FRect #define POINTTYPE SDL_FPoint #define SCALARTYPE float +#define BIGSCALARTYPE double #define COMPUTEOUTCODE ComputeOutCodeF #define SDL_HASINTERSECTION SDL_HasIntersectionF #define SDL_INTERSECTRECT SDL_IntersectFRect diff --git a/vs/sdl2/src/video/SDL_rect_c.h b/vs/sdl2/src/video/SDL_rect_c.h index 639bef8440..b7d6e7ffee 100644 --- a/vs/sdl2/src/video/SDL_rect_c.h +++ b/vs/sdl2/src/video/SDL_rect_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_rect_impl.h b/vs/sdl2/src/video/SDL_rect_impl.h index b0e3901b12..288a727760 100644 --- a/vs/sdl2/src/video/SDL_rect_impl.h +++ b/vs/sdl2/src/video/SDL_rect_impl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +25,10 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { @@ -70,13 +70,13 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */ @@ -120,13 +120,13 @@ void SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return; } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ @@ -180,7 +180,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c SCALARTYPE x, y; int i; - if (points == NULL) { + if (!points) { SDL_InvalidParamError("points"); return SDL_FALSE; } else if (count < 1) { @@ -210,7 +210,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } if (!added) { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -236,7 +236,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } } else { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -299,19 +299,19 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY SCALARTYPE recty2; int outcode1, outcode2; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return SDL_FALSE; - } else if (X1 == NULL) { + } else if (!X1) { SDL_InvalidParamError("X1"); return SDL_FALSE; - } else if (Y1 == NULL) { + } else if (!Y1) { SDL_InvalidParamError("Y1"); return SDL_FALSE; - } else if (X2 == NULL) { + } else if (!X2) { SDL_InvalidParamError("X2"); return SDL_FALSE; - } else if (Y2 == NULL) { + } else if (!Y2) { SDL_InvalidParamError("Y2"); return SDL_FALSE; } else if (SDL_RECTEMPTY(rect)) { @@ -378,16 +378,16 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY if (outcode1) { if (outcode1 & CODE_TOP) { y = recty1; - x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); } else if (outcode1 & CODE_BOTTOM) { y = recty2; - x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); } else if (outcode1 & CODE_LEFT) { x = rectx1; - y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); } else if (outcode1 & CODE_RIGHT) { x = rectx2; - y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); } x1 = x; y1 = y; @@ -396,23 +396,23 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY if (outcode2 & CODE_TOP) { SDL_assert(y2 != y1); /* if equal: division by zero. */ y = recty1; - x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); } else if (outcode2 & CODE_BOTTOM) { SDL_assert(y2 != y1); /* if equal: division by zero. */ y = recty2; - x = x1 + ((x2 - x1) * (y - y1)) / (y2 - y1); + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); } else if (outcode2 & CODE_LEFT) { /* If this assertion ever fires, here's the static analysis that warned about it: http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */ SDL_assert(x2 != x1); /* if equal: division by zero. */ x = rectx1; - y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); } else if (outcode2 & CODE_RIGHT) { /* If this assertion ever fires, here's the static analysis that warned about it: http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */ SDL_assert(x2 != x1); /* if equal: division by zero. */ x = rectx2; - y = y1 + ((y2 - y1) * (x - x1)) / (x2 - x1); + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); } x2 = x; y2 = y; @@ -429,6 +429,7 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY #undef RECTTYPE #undef POINTTYPE #undef SCALARTYPE +#undef BIGSCALARTYPE #undef COMPUTEOUTCODE #undef SDL_HASINTERSECTION #undef SDL_INTERSECTRECT diff --git a/vs/sdl2/src/video/SDL_shape.c b/vs/sdl2/src/video/SDL_shape.c index a0b977b6e7..77cc8dcad9 100644 --- a/vs/sdl2/src/video/SDL_shape.c +++ b/vs/sdl2/src/video/SDL_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 @@ SDL_Window *SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned i { SDL_Window *result = NULL; result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); - if (result != NULL) { + if (result) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); return NULL; } result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); - if (result->shaper != NULL) { + if (result->shaper) { result->shaper->userx = x; result->shaper->usery = y; result->shaper->mode.mode = ShapeModeDefault; @@ -136,7 +136,7 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree)); SDL_Rect next = { 0, 0, 0, 0 }; - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -265,16 +265,16 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo SDL_VideoDevice *_this = SDL_GetVideoDevice(); int result; - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { /* The window given was not a shapeable window. */ return SDL_NONSHAPEABLE_WINDOW; } - if (shape == NULL) { + if (!shape) { /* Invalid shape argument. */ return SDL_INVALID_SHAPE_ARGUMENT; } - if (shape_mode != NULL) { + if (shape_mode) { window->shaper->mode = *shape_mode; } result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); @@ -317,7 +317,7 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { return SDL_FALSE; } return window->shaper->hasshape; @@ -325,8 +325,8 @@ static SDL_bool SDL_WindowHasAShape(SDL_Window *window) int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode) { - if (window != NULL && SDL_IsShapedWindow(window)) { - if (shape_mode == NULL) { + if (window && SDL_IsShapedWindow(window)) { + if (!shape_mode) { if (SDL_WindowHasAShape(window)) { return 0; /* The window given has a shape. */ } else { diff --git a/vs/sdl2/src/video/SDL_shape_internals.h b/vs/sdl2/src/video/SDL_shape_internals.h index 7681a045ab..ed0b0d0ed8 100644 --- a/vs/sdl2/src/video/SDL_shape_internals.h +++ b/vs/sdl2/src/video/SDL_shape_internals.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/SDL_stretch.c b/vs/sdl2/src/video/SDL_stretch.c index ec2bed5cc5..a2bae05782 100644 --- a/vs/sdl2/src/video/SDL_stretch.c +++ b/vs/sdl2/src/video/SDL_stretch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -149,9 +149,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, #define BILINEAR___START \ int i; \ - int fp_sum_h, fp_step_h, left_pad_h, right_pad_h; \ - int fp_sum_w, fp_step_w, left_pad_w, right_pad_w; \ - int fp_sum_w_init, left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \ + Sint64 fp_sum_h; \ + int fp_step_h, left_pad_h, right_pad_h; \ + Sint64 fp_sum_w; \ + int fp_step_w, left_pad_w, right_pad_w; \ + Sint64 fp_sum_w_init; \ + int left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \ get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \ get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \ fp_sum_w_init = fp_sum_w + left_pad_w * fp_step_w; \ @@ -163,7 +166,8 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, #define BILINEAR___HEIGHT \ int index_h, frac_h0, frac_h1, middle; \ const Uint32 *src_h0, *src_h1; \ - int no_padding, incr_h0, incr_h1; \ + int no_padding; \ + Uint64 incr_h0, incr_h1; \ \ no_padding = !(i < left_pad_h || i > dst_h - 1 - right_pad_h); \ index_h = SRC_INDEX(fp_sum_h); \ @@ -172,7 +176,7 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, 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; \ + incr_h0 = (Uint64)index_h * src_pitch; \ \ src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \ src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \ @@ -193,12 +197,12 @@ static int SDL_UpperSoftStretch(SDL_Surface *src, const SDL_Rect *srcrect, // 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) +static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *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; + Sint64 fp_sum; int i; #if 0 /* scale to source coordinates */ @@ -334,7 +338,7 @@ static int scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, } #if defined(__SSE2__) -#define HAVE_SSE2_INTRINSICS 1 +#define HAVE_SSE2_INTRINSICS #endif #if defined(__ARM_NEON) @@ -532,7 +536,7 @@ static int scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, #if defined(HAVE_NEON_INTRINSICS) -static SDL_INLINE int hasNEON() +static SDL_INLINE int hasNEON(void) { static int val = -1; if (val != -1) { @@ -824,16 +828,16 @@ int SDL_LowerSoftStretchLinear(SDL_Surface *s, const SDL_Rect *srcrect, 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; \ +#define SDL_SCALE_NEAREST__START \ + int i; \ + Uint64 posy, incy; \ + Uint64 posx, incx; \ + Uint64 srcy, srcx; \ + int dst_gap, n; \ + const Uint32 *src_h0; \ + incy = ((Uint64)src_h << 16) / dst_h; \ + incx = ((Uint64)src_w << 16) / dst_w; \ + dst_gap = dst_pitch - bpp * dst_w; \ posy = incy / 2; #define SDL_SCALE_NEAREST__HEIGHT \ @@ -852,7 +856,7 @@ static int scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int SDL_SCALE_NEAREST__HEIGHT while (n--) { const Uint8 *src; - int srcx = bpp * (posx >> 16); + srcx = bpp * (posx >> 16); posx += incx; src = (const Uint8 *)src_h0 + srcx; *(Uint8 *)dst = *src; @@ -872,7 +876,7 @@ static int scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int SDL_SCALE_NEAREST__HEIGHT while (n--) { const Uint16 *src; - int srcx = bpp * (posx >> 16); + srcx = bpp * (posx >> 16); posx += incx; src = (const Uint16 *)((const Uint8 *)src_h0 + srcx); *(Uint16 *)dst = *src; @@ -892,7 +896,7 @@ static int scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int SDL_SCALE_NEAREST__HEIGHT while (n--) { const Uint8 *src; - int srcx = bpp * (posx >> 16); + srcx = bpp * (posx >> 16); posx += incx; src = (const Uint8 *)src_h0 + srcx; ((Uint8 *)dst)[0] = src[0]; @@ -914,7 +918,7 @@ static int scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int SDL_SCALE_NEAREST__HEIGHT while (n--) { const Uint32 *src; - int srcx = bpp * (posx >> 16); + srcx = bpp * (posx >> 16); posx += incx; src = (const Uint32 *)((const Uint8 *)src_h0 + srcx); *dst = *src; diff --git a/vs/sdl2/src/video/SDL_surface.c b/vs/sdl2/src/video/SDL_surface.c index a81ff7bd5a..9db0c5039c 100644 --- a/vs/sdl2/src/video/SDL_surface.c +++ b/vs/sdl2/src/video/SDL_surface.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +107,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, /* Allocate the surface */ surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface)); - if (surface == NULL) { + if (!surface) { SDL_OutOfMemory(); return NULL; } @@ -125,7 +125,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); - if (palette == NULL) { + if (!palette) { SDL_FreeSurface(surface); return NULL; } @@ -238,7 +238,7 @@ SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -284,7 +284,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -297,7 +297,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface"); } if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) { @@ -312,8 +312,8 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) { int flags; - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } flags = surface->map->info.flags; @@ -330,7 +330,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) SDL_bool SDL_HasSurfaceRLE(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -345,7 +345,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -373,7 +373,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) SDL_bool SDL_HasColorKey(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -386,7 +386,7 @@ SDL_bool SDL_HasColorKey(SDL_Surface *surface) int SDL_GetColorKey(SDL_Surface *surface, Uint32 *key) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -406,7 +406,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp { int x, y, bpp; - if (surface == NULL) { + if (!surface) { return; } @@ -495,8 +495,8 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) { int flags; - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } surface->map->info.r = r; @@ -517,8 +517,8 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) { - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } if (r) { @@ -537,8 +537,8 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) { int flags; - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } surface->map->info.a = alpha; @@ -557,8 +557,8 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha) { - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } if (alpha) { @@ -571,8 +571,8 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) { int flags, status; - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } status = 0; @@ -608,11 +608,11 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) { - if (surface == NULL) { - return -1; + if (!surface) { + return SDL_InvalidParamError("surface"); } - if (blendMode == NULL) { + if (!blendMode) { return 0; } @@ -641,7 +641,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) SDL_Rect full_rect; /* Don't do anything if there's no surface to act on */ - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -652,7 +652,7 @@ SDL_bool SDL_SetClipRect(SDL_Surface *surface, const SDL_Rect *rect) full_rect.h = surface->h; /* Set the clipping rectangle */ - if (rect == NULL) { + if (!rect) { surface->clip_rect = full_rect; return SDL_TRUE; } @@ -701,85 +701,65 @@ int SDL_LowerBlit(SDL_Surface *src, SDL_Rect *srcrect, int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { - SDL_Rect fulldst; - int srcx, srcy, w, h; + SDL_Rect r_src, r_dst; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { - return SDL_InvalidParamError("SDL_UpperBlit(): src/dst"); - } - if (src->locked || dst->locked) { + if (!src) { + return SDL_InvalidParamError("src"); + } else if (!dst) { + return SDL_InvalidParamError("dst"); + } else if (src->locked || dst->locked) { return SDL_SetError("Surfaces must not be locked during blit"); } - /* If the destination rectangle is NULL, use the entire dest surface */ - if (dstrect == NULL) { - fulldst.x = fulldst.y = 0; - fulldst.w = dst->w; - fulldst.h = dst->h; - dstrect = &fulldst; + /* Full src surface */ + r_src.x = 0; + r_src.y = 0; + r_src.w = src->w; + r_src.h = src->h; + + if (dstrect) { + r_dst.x = dstrect->x; + r_dst.y = dstrect->y; + } else { + r_dst.x = 0; + r_dst.y = 0; } /* clip the source rectangle to the source surface */ if (srcrect) { - int maxw, maxh; - - srcx = srcrect->x; - w = srcrect->w; - if (srcx < 0) { - w += srcx; - dstrect->x -= srcx; - srcx = 0; - } - maxw = src->w - srcx; - if (maxw < w) { - w = maxw; + SDL_Rect tmp; + if (SDL_IntersectRect(srcrect, &r_src, &tmp) == SDL_FALSE) { + goto end; } - srcy = srcrect->y; - h = srcrect->h; - if (srcy < 0) { - h += srcy; - dstrect->y -= srcy; - srcy = 0; - } - maxh = src->h - srcy; - if (maxh < h) { - h = maxh; - } + /* Shift dstrect, if srcrect origin has changed */ + r_dst.x += tmp.x - srcrect->x; + r_dst.y += tmp.y - srcrect->y; - } else { - srcx = srcy = 0; - w = src->w; - h = src->h; + /* Update srcrect */ + r_src = tmp; } + /* There're no dstrect.w/h parameters. It's the same as srcrect */ + r_dst.w = r_src.w; + r_dst.h = r_src.h; + /* clip the destination rectangle against the clip rectangle */ { - SDL_Rect *clip = &dst->clip_rect; - int dx, dy; - - dx = clip->x - dstrect->x; - if (dx > 0) { - w -= dx; - dstrect->x += dx; - srcx += dx; - } - dx = dstrect->x + w - clip->x - clip->w; - if (dx > 0) { - w -= dx; + SDL_Rect tmp; + if (SDL_IntersectRect(&r_dst, &dst->clip_rect, &tmp) == SDL_FALSE) { + goto end; } - dy = clip->y - dstrect->y; - if (dy > 0) { - h -= dy; - dstrect->y += dy; - srcy += dy; - } - dy = dstrect->y + h - clip->y - clip->h; - if (dy > 0) { - h -= dy; - } + /* Shift srcrect, if dstrect has changed */ + r_src.x += tmp.x - r_dst.x; + r_src.y += tmp.y - r_dst.y; + r_src.w = tmp.w; + r_src.h = tmp.h; + + /* Update dstrect */ + r_dst = tmp; } /* Switch back to a fast blit if we were previously stretching */ @@ -788,15 +768,17 @@ int SDL_UpperBlit(SDL_Surface *src, const SDL_Rect *srcrect, SDL_InvalidateMap(src->map); } - if (w > 0 && h > 0) { - SDL_Rect sr; - sr.x = srcx; - sr.y = srcy; - sr.w = dstrect->w = w; - sr.h = dstrect->h = h; - return SDL_LowerBlit(src, &sr, dst, dstrect); + if (r_dst.w > 0 && r_dst.h > 0) { + if (dstrect) { /* update output parameter */ + *dstrect = r_dst; + } + return SDL_LowerBlit(src, &r_src, dst, &r_dst); + } + +end: + if (dstrect) { /* update output parameter */ + dstrect->w = dstrect->h = 0; } - dstrect->w = dstrect->h = 0; return 0; } @@ -817,14 +799,14 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, int dst_w, dst_h; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { + if (!src || !dst) { return SDL_InvalidParamError("SDL_UpperBlitScaled(): src/dst"); } if (src->locked || dst->locked) { return SDL_SetError("Surfaces must not be locked during blit"); } - if (srcrect == NULL) { + if (!srcrect) { src_w = src->w; src_h = src->h; } else { @@ -832,7 +814,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, src_h = srcrect->h; } - if (dstrect == NULL) { + if (!dstrect) { dst_w = dst->w; dst_h = dst->h; } else { @@ -848,7 +830,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, scaling_w = (double)dst_w / src_w; scaling_h = (double)dst_h / src_h; - if (dstrect == NULL) { + if (!dstrect) { dst_x0 = 0; dst_y0 = 0; dst_x1 = dst_w; @@ -860,7 +842,7 @@ int SDL_PrivateUpperBlitScaled(SDL_Surface *src, const SDL_Rect *srcrect, dst_y1 = dst_y0 + dst_h; } - if (srcrect == NULL) { + if (!srcrect) { src_x0 = 0; src_y0 = 0; src_x1 = src_w; @@ -1146,17 +1128,17 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f Uint8 *palette_saved_alpha = NULL; int palette_saved_alpha_ncolors = 0; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return NULL; } /* Check for empty destination palette! (results in empty image) */ - if (format->palette != NULL) { + if (format->palette) { int i; for (i = 0; i < format->palette->ncolors; ++i) { if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) { @@ -1174,7 +1156,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask); - if (convert == NULL) { + if (!convert) { return NULL; } @@ -1429,13 +1411,13 @@ int SDL_ConvertPixels(int width, int height, void *nonconst_src = (void *)src; int ret; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1511,13 +1493,13 @@ int SDL_PremultiplyAlpha(int width, int height, Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1559,7 +1541,7 @@ int SDL_PremultiplyAlpha(int width, int height, */ void SDL_FreeSurface(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return; } if (surface->flags & SDL_DONTFREE) { diff --git a/vs/sdl2/src/video/SDL_sysvideo.h b/vs/sdl2/src/video/SDL_sysvideo.h index d7a42cc64d..344efec489 100644 --- a/vs/sdl2/src/video/SDL_sysvideo.h +++ b/vs/sdl2/src/video/SDL_sysvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +24,7 @@ #define SDL_sysvideo_h_ #include "SDL_messagebox.h" +#include "SDL_mouse.h" #include "SDL_shape.h" #include "SDL_thread.h" #include "SDL_metal.h" @@ -433,11 +434,11 @@ struct SDL_VideoDevice void *driverdata; struct SDL_GLDriverData *gl_data; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL struct SDL_EGL_VideoData *egl_data; #endif -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) struct SDL_PrivateGLESData *gles_data; #endif @@ -451,6 +452,7 @@ typedef struct VideoBootStrap const char *name; const char *desc; SDL_VideoDevice *(*create)(void); + int (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonid); /* can be done without initializing backend! */ } VideoBootStrap; /* Not all of these are available in a given build. Use #ifdefs, etc. */ @@ -528,6 +530,10 @@ extern int SDL_GetPointDisplayIndex(const SDL_Point *point); extern int SDL_GL_SwapWindowWithResult(SDL_Window *window); +#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) +const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name); +#endif + #endif /* SDL_sysvideo_h_ */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/video/SDL_video.c b/vs/sdl2/src/video/SDL_video.c index 8065a0b8cf..ee723a57b1 100644 --- a/vs/sdl2/src/video/SDL_video.c +++ b/vs/sdl2/src/video/SDL_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,20 +34,20 @@ #include "SDL_syswm.h" -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL #include "SDL_opengl.h" #endif /* SDL_VIDEO_OPENGL */ -#if SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL +#if defined(SDL_VIDEO_OPENGL_ES) && !defined(SDL_VIDEO_OPENGL) #include "SDL_opengles.h" #endif /* SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL */ /* GL and GLES2 headers conflict on Linux 32 bits */ -#if SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL +#if defined(SDL_VIDEO_OPENGL_ES2) && !defined(SDL_VIDEO_OPENGL) #include "SDL_opengles2.h" #endif /* SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL */ -#if !SDL_VIDEO_OPENGL +#ifndef SDL_VIDEO_OPENGL #ifndef GL_CONTEXT_RELEASE_BEHAVIOR_KHR #define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB #endif @@ -61,86 +61,87 @@ #include #include #include +#include #endif /* Available video drivers */ static VideoBootStrap *bootstrap[] = { -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA &COCOA_bootstrap, #endif -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 &X11_bootstrap, #endif -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND &Wayland_bootstrap, #endif -#if SDL_VIDEO_DRIVER_VIVANTE +#ifdef SDL_VIDEO_DRIVER_VIVANTE &VIVANTE_bootstrap, #endif -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB &DirectFB_bootstrap, #endif -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS &WINDOWS_bootstrap, #endif -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT &WINRT_bootstrap, #endif -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU &HAIKU_bootstrap, #endif -#if SDL_VIDEO_DRIVER_PANDORA +#ifdef SDL_VIDEO_DRIVER_PANDORA &PND_bootstrap, #endif -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT &UIKIT_bootstrap, #endif -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID &Android_bootstrap, #endif -#if SDL_VIDEO_DRIVER_PS2 +#ifdef SDL_VIDEO_DRIVER_PS2 &PS2_bootstrap, #endif -#if SDL_VIDEO_DRIVER_PSP +#ifdef SDL_VIDEO_DRIVER_PSP &PSP_bootstrap, #endif -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA &VITA_bootstrap, #endif -#if SDL_VIDEO_DRIVER_N3DS +#ifdef SDL_VIDEO_DRIVER_N3DS &N3DS_bootstrap, #endif -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM &KMSDRM_bootstrap, #endif -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS &RISCOS_bootstrap, #endif -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI &RPI_bootstrap, #endif -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL &NACL_bootstrap, #endif -#if SDL_VIDEO_DRIVER_EMSCRIPTEN +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN &Emscripten_bootstrap, #endif -#if SDL_VIDEO_DRIVER_QNX +#ifdef SDL_VIDEO_DRIVER_QNX &QNX_bootstrap, #endif -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 &OS2DIVE_bootstrap, &OS2VMAN_bootstrap, #endif -#if SDL_VIDEO_DRIVER_NGAGE +#ifdef SDL_VIDEO_DRIVER_NGAGE &NGAGE_bootstrap, #endif -#if SDL_VIDEO_DRIVER_OFFSCREEN +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN &OFFSCREEN_bootstrap, #endif -#if SDL_VIDEO_DRIVER_DUMMY +#ifdef SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV &DUMMY_evdev_bootstrap, #endif #endif @@ -202,13 +203,13 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { -#if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ - if (_this->GL_CreateContext != NULL) { +#if (defined(SDL_VIDEO_OPENGL) && defined(__MACOSX__)) || (defined(__IPHONEOS__) && !TARGET_OS_MACCATALYST) || defined(__ANDROID__) || defined(__NACL__) + if (_this->GL_CreateContext) { return SDL_WINDOW_OPENGL; } #endif -#if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) - if (_this->Metal_CreateView != NULL) { +#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(__MACOSX__) || defined(__IPHONEOS__)) + if (_this->Metal_CreateView) { return SDL_WINDOW_METAL; } #endif @@ -224,7 +225,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U SDL_GetWindowSizeInPixels(window, &w, &h); - if (data == NULL) { + if (!data) { SDL_Renderer *renderer = NULL; const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && @@ -241,7 +242,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U break; } } - if (renderer == NULL || (SDL_GetRendererInfo(renderer, &info) == -1)) { + if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) { if (renderer) { SDL_DestroyRenderer(renderer); } @@ -262,7 +263,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U } } } - if (renderer == NULL) { + if (!renderer) { return SDL_SetError("No hardware accelerated renderers available"); } } @@ -271,7 +272,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U /* Create the data after we successfully create the renderer (bug #1116) */ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_DestroyRenderer(renderer); return SDL_OutOfMemory(); } @@ -346,7 +347,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, SDL_GetWindowSizeInPixels(window, &w, &h); data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); - if (data == NULL || !data->texture) { + if (!data || !data->texture) { return SDL_SetError("No window texture data"); } @@ -373,7 +374,7 @@ static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window SDL_WindowTextureData *data; data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL); - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -406,7 +407,7 @@ static int SDLCALL cmpmodes(const void *A, const void *B) return 0; } -static int SDL_UninitializedVideo() +static int SDL_UninitializedVideo(void) { return SDL_SetError("Video subsystem has not been initialized"); } @@ -437,11 +438,11 @@ int SDL_VideoInit(const char *driver_name) int i = 0; /* Check to make sure we don't overwrite '_this' */ - if (_this != NULL) { + if (_this) { SDL_VideoQuit(); } -#if !SDL_TIMERS_DISABLED +#ifndef SDL_TIMERS_DISABLED SDL_TicksInit(); #endif @@ -454,7 +455,7 @@ int SDL_VideoInit(const char *driver_name) goto pre_driver_error; } init_keyboard = SDL_TRUE; - if (SDL_MouseInit() < 0) { + if (SDL_MousePreInit() < 0) { goto pre_driver_error; } init_mouse = SDL_TRUE; @@ -465,14 +466,36 @@ int SDL_VideoInit(const char *driver_name) /* Select the proper video driver */ video = NULL; - if (driver_name == NULL) { + if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER); } - if (driver_name != NULL && *driver_name != 0) { +#if defined(__LINUX__) && defined(SDL_VIDEO_DRIVER_X11) + if (!driver_name) { + /* See if it looks like we need X11 */ + SDL_bool force_x11 = SDL_FALSE; + void *global_symbols = dlopen(NULL, RTLD_LOCAL|RTLD_NOW); + + /* Use linked libraries to detect what quirks we are likely to need */ + if (global_symbols != NULL) { + if (dlsym(global_symbols, "glxewInit") != NULL) { /* GLEW (e.g. Frogatto, SLUDGE) */ + force_x11 = SDL_TRUE; + } else if (dlsym(global_symbols, "cgGLEnableProgramProfiles") != NULL) { /* NVIDIA Cg (e.g. Awesomenauts, Braid) */ + force_x11 = SDL_TRUE; + } else if (dlsym(global_symbols, "_Z7ssgInitv") != NULL) { /* ::ssgInit(void) in plib (e.g. crrcsim) */ + force_x11 = SDL_TRUE; + } + dlclose(global_symbols); + } + if (force_x11) { + driver_name = "x11"; + } + } +#endif + if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; - while (driver_attempt != NULL && *driver_attempt != 0 && video == NULL) { + while (driver_attempt && *driver_attempt != 0 && !video) { const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); - size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt) + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) : SDL_strlen(driver_attempt); for (i = 0; bootstrap[i]; ++i) { @@ -483,17 +506,17 @@ int SDL_VideoInit(const char *driver_name) } } - driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL; + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; } } else { for (i = 0; bootstrap[i]; ++i) { video = bootstrap[i]->create(); - if (video != NULL) { + if (video) { break; } } } - if (video == NULL) { + if (!video) { if (driver_name) { SDL_SetError("%s not available", driver_name); goto pre_driver_error; @@ -539,16 +562,23 @@ int SDL_VideoInit(const char *driver_name) SDL_DisableScreenSaver(); } - /* If we don't use a screen keyboard, turn on text input by default, - otherwise programs that expect to get text events without enabling - UNICODE input won't get any events. - - Actually, come to think of it, you needed to call SDL_EnableUNICODE(1) - in SDL 1.2 before you got text input events. Hmm... +#if !defined(SDL_VIDEO_DRIVER_N3DS) + /* In the initial state we don't want to pop up an on-screen keyboard, + * but we do want to allow text input from other mechanisms. */ - if (!SDL_HasScreenKeyboardSupport()) { + { + const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD); + if (!hint) { + SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, "0"); + } SDL_StartTextInput(); + if (!hint) { + SDL_SetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD, NULL); + } } +#endif /* !SDL_VIDEO_DRIVER_N3DS */ + + SDL_MousePostInit(); /* We're ready to go! */ return 0; @@ -570,9 +600,9 @@ int SDL_VideoInit(const char *driver_name) return -1; } -const char *SDL_GetCurrentVideoDriver() +const char *SDL_GetCurrentVideoDriver(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -584,7 +614,7 @@ SDL_VideoDevice *SDL_GetVideoDevice(void) return _this; } -SDL_bool SDL_OnVideoThread() +SDL_bool SDL_OnVideoThread(void) { return (_this && SDL_ThreadID() == _this->thread) ? SDL_TRUE : SDL_FALSE; } @@ -644,6 +674,7 @@ void SDL_DelVideoDisplay(int index) if (index < (_this->num_displays - 1)) { SDL_free(_this->displays[index].driverdata); + SDL_free(_this->displays[index].name); SDL_memmove(&_this->displays[index], &_this->displays[index + 1], (_this->num_displays - index - 1) * sizeof(_this->displays[index])); } --_this->num_displays; @@ -651,7 +682,7 @@ void SDL_DelVideoDisplay(int index) int SDL_GetNumVideoDisplays(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return 0; } @@ -697,7 +728,7 @@ int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect) CHECK_DISPLAY_INDEX(displayIndex, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -734,7 +765,7 @@ int SDL_GetDisplayUsableBounds(int displayIndex, SDL_Rect *rect) CHECK_DISPLAY_INDEX(displayIndex, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -802,7 +833,7 @@ SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mo modes = SDL_realloc(modes, (display->max_display_modes + 32) * sizeof(*modes)); - if (modes == NULL) { + if (!modes) { return SDL_FALSE; } display->display_modes = modes; @@ -825,6 +856,9 @@ void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) { + if (display->desktop_mode.driverdata) { + SDL_free(display->desktop_mode.driverdata); + } SDL_memcpy(&display->desktop_mode, mode, sizeof(*mode)); } @@ -914,7 +948,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di int i; SDL_DisplayMode *current, *match; - if (mode == NULL || closest == NULL) { + if (!mode || !closest) { SDL_InvalidParamError("mode/closest"); return NULL; } @@ -951,7 +985,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di modes may still follow. */ continue; } - if (match == NULL || current->w < match->w || current->h < match->h) { + if (!match || current->w < match->w || current->h < match->h) { match = current; continue; } @@ -1208,7 +1242,7 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window) SDL_VideoDisplay *new_display = &_this->displays[displayIndex]; /* The window was moved to a different display */ - if (new_display->fullscreen_window != NULL) { + if (new_display->fullscreen_window) { /* Uh oh, there's already a fullscreen window here */ } else { new_display->fullscreen_window = window; @@ -1268,7 +1302,7 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode) CHECK_WINDOW_MAGIC(window, -1); - if (mode == NULL) { + if (!mode) { return SDL_InvalidParamError("mode"); } @@ -1326,7 +1360,7 @@ static void SDL_RestoreMousePosition(SDL_Window *window) } } -#if __WINRT__ +#ifdef __WINRT__ extern Uint32 WINRT_DetectWindowFlags(SDL_Window *window); #endif @@ -1334,6 +1368,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) { SDL_VideoDisplay *display; SDL_Window *other; + SDL_bool resized = SDL_FALSE; CHECK_WINDOW_MAGIC(window, -1); @@ -1372,7 +1407,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) return 0; } } -#elif __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10) +#elif defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10) /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen or not. The user can choose this, via OS-provided UI, but this can't be set programmatically. @@ -1399,7 +1434,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) #endif display = SDL_GetDisplayForWindow(window); - if (display == NULL) { /* No display connected, nothing to do. */ + if (!display) { /* No display connected, nothing to do. */ return 0; } @@ -1442,7 +1477,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) SDL_zero(fullscreen_mode); if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) { - SDL_bool resized = SDL_TRUE; + resized = SDL_TRUE; if (other->w == fullscreen_mode.w && other->h == fullscreen_mode.h) { resized = SDL_FALSE; @@ -1466,20 +1501,21 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) /* Generate a mode change event here */ if (resized) { -#if !defined(__ANDROID__) && !defined(__WIN32__) - /* Android may not resize the window to exactly what our fullscreen mode is, especially on - * windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't - * use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such, - * Android's SetWindowFullscreen will generate the window event for us with the proper final size. - */ - - /* This is also unnecessary on Win32 (WIN_SetWindowFullscreen calls SetWindowPos, - * WM_WINDOWPOSCHANGED will send SDL_WINDOWEVENT_RESIZED). Also, on Windows with DPI scaling enabled, - * we're keeping modes in pixels, but window sizes in dpi-scaled points, so this would be a unit mismatch. - */ - SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED, - fullscreen_mode.w, fullscreen_mode.h); -#endif + if (SDL_strcmp(_this->name, "Android") != 0 && SDL_strcmp(_this->name, "windows") != 0) { + /* Android may not resize the window to exactly what our fullscreen mode is, especially on + * windowed Android environments like the Chromebook or Samsung DeX. Given this, we shouldn't + * use fullscreen_mode.w and fullscreen_mode.h, but rather get our current native size. As such, + * Android's SetWindowFullscreen will generate the window event for us with the proper final size. + */ + + /* This is also unnecessary on Win32 (WIN_SetWindowFullscreen calls SetWindowPos, + * WM_WINDOWPOSCHANGED will send SDL_WINDOWEVENT_RESIZED). Also, on Windows with DPI scaling enabled, + * we're keeping modes in pixels, but window sizes in dpi-scaled points, so this would be a unit mismatch. + */ + SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED, + fullscreen_mode.w, fullscreen_mode.h); + } + } else { SDL_OnWindowResized(other); } @@ -1497,11 +1533,18 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) if (_this->SetWindowFullscreen) { _this->SetWindowFullscreen(_this, window, display, SDL_FALSE); + } else { + resized = SDL_TRUE; } display->fullscreen_window = NULL; - /* Generate a mode change event here */ - SDL_OnWindowResized(window); + if (!resized) { + /* Generate a mode change event here */ + SDL_OnWindowResized(window); + } else { + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESIZED, + window->windowed.w, window->windowed.h); + } /* Restore the cursor position */ SDL_RestoreMousePosition(window); @@ -1590,14 +1633,14 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint SDL_Window *window; Uint32 type_flags, graphics_flags; - if (_this == NULL) { + if (!_this) { /* Initialize the video system if needed */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { return NULL; } /* Make clang-tidy happy */ - if (_this == NULL) { + if (!_this) { return NULL; } } @@ -1623,9 +1666,11 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint } /* Some platforms blow up if the windows are too large. Raise it later? */ - if ((w > 16384) || (h > 16384)) { - SDL_SetError("Window is too large."); - return NULL; + if (w > 16384) { + w = 16384; + } + if (h > 16384) { + h = 16384; } /* ensure no more than one of these flags is set */ @@ -1677,7 +1722,7 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -1763,7 +1808,7 @@ SDL_Window *SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint } #endif -#if __WINRT__ && (NTDDI_VERSION < NTDDI_WIN10) +#if defined(__WINRT__) && (NTDDI_VERSION < NTDDI_WIN10) /* HACK: WinRT 8.x apps can't choose whether or not they are fullscreen or not. The user can choose this, via OS-provided UI, but this can't be set programmatically. @@ -1791,7 +1836,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) SDL_Window *window; Uint32 flags = SDL_WINDOW_FOREIGN; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -1827,7 +1872,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -1980,6 +2025,14 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) _this->SetWindowIcon(_this, window, window->icon); } + if (_this->SetWindowMinimumSize && (window->min_w || window->min_h)) { + _this->SetWindowMinimumSize(_this, window); + } + + if (_this->SetWindowMaximumSize && (window->max_w || window->max_h)) { + _this->SetWindowMaximumSize(_this, window); + } + if (window->hit_test) { _this->SetWindowHitTest(window, SDL_TRUE); } @@ -1991,7 +2044,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) SDL_bool SDL_HasWindows(void) { - return _this && _this->windows != NULL; + return _this && _this->windows; } Uint32 SDL_GetWindowID(SDL_Window *window) @@ -2005,7 +2058,7 @@ SDL_Window *SDL_GetWindowFromID(Uint32 id) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -2050,7 +2103,7 @@ void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) { CHECK_WINDOW_MAGIC(window, ); - if (icon == NULL) { + if (!icon) { return; } @@ -2333,16 +2386,16 @@ int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *botto { int dummy = 0; - if (top == NULL) { + if (!top) { top = &dummy; } - if (left == NULL) { + if (!left) { left = &dummy; } - if (right == NULL) { + if (!right) { right = &dummy; } - if (bottom == NULL) { + if (!bottom) { bottom = &dummy; } @@ -2364,11 +2417,11 @@ void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) CHECK_WINDOW_MAGIC(window, ); - if (w == NULL) { + if (!w) { w = &filter; } - if (h == NULL) { + if (!h) { h = &filter; } @@ -2470,6 +2523,9 @@ void SDL_ShowWindow(SDL_Window *window) if (_this->ShowWindow) { _this->ShowWindow(_this, window); + } else { + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); } SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SHOWN, 0, 0); } @@ -2487,6 +2543,9 @@ void SDL_HideWindow(SDL_Window *window) if (_this->HideWindow) { _this->HideWindow(_this, window); + } else { + SDL_SetMouseFocus(NULL); + SDL_SetKeyboardFocus(NULL); } window->is_hiding = SDL_FALSE; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIDDEN, 0, 0); @@ -2618,7 +2677,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) #if defined(__LINUX__) /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "x11") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ attempt_texture_framebuffer = SDL_FALSE; @@ -2626,7 +2685,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } #endif #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } #endif @@ -3161,7 +3220,7 @@ static SDL_bool ShouldMinimizeOnFocusLoss(SDL_Window *window) /* Real fullscreen windows should minimize on focus loss so the desktop video mode is restored */ hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); - if (hint == NULL || !*hint || SDL_strcasecmp(hint, "auto") == 0) { + if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { if ((window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP || DisableDisplayModeSwitching(_this) == SDL_TRUE) { return SDL_FALSE; @@ -3191,7 +3250,7 @@ SDL_Window *SDL_GetFocusWindow(void) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -3291,17 +3350,17 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_free(window); } -SDL_bool SDL_IsScreenSaverEnabled() +SDL_bool SDL_IsScreenSaverEnabled(void) { - if (_this == NULL) { + if (!_this) { return SDL_TRUE; } return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE; } -void SDL_EnableScreenSaver() +void SDL_EnableScreenSaver(void) { - if (_this == NULL) { + if (!_this) { return; } if (!_this->suspend_screensaver) { @@ -3313,9 +3372,9 @@ void SDL_EnableScreenSaver() } } -void SDL_DisableScreenSaver() +void SDL_DisableScreenSaver(void) { - if (_this == NULL) { + if (!_this) { return; } if (_this->suspend_screensaver) { @@ -3331,7 +3390,7 @@ void SDL_VideoQuit(void) { int i; - if (_this == NULL) { + if (!_this) { return; } @@ -3353,18 +3412,14 @@ void SDL_VideoQuit(void) SDL_VideoDisplay *display = &_this->displays[i]; SDL_ResetDisplayModes(i); SDL_free(display->desktop_mode.driverdata); - display->desktop_mode.driverdata = NULL; SDL_free(display->driverdata); - display->driverdata = NULL; - } - if (_this->displays) { - for (i = 0; i < _this->num_displays; ++i) { - SDL_free(_this->displays[i].name); - } - SDL_free(_this->displays); - _this->displays = NULL; - _this->num_displays = 0; + SDL_free(display->name); } + + SDL_free(_this->displays); + _this->displays = NULL; + _this->num_displays = 0; + SDL_free(_this->clipboard_text); _this->clipboard_text = NULL; _this->free(_this); @@ -3375,7 +3430,7 @@ int SDL_GL_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } if (_this->gl_config.driver_loaded) { @@ -3403,7 +3458,7 @@ void *SDL_GL_GetProcAddress(const char *proc) { void *func; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -3422,7 +3477,7 @@ void *SDL_GL_GetProcAddress(const char *proc) void SDL_GL_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -3436,7 +3491,7 @@ void SDL_GL_UnloadLibrary(void) } } -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) { return verstr && (SDL_atoi(verstr) >= 3); @@ -3445,7 +3500,7 @@ static SDL_INLINE SDL_bool isAtLeastGL3(const char *verstr) SDL_bool SDL_GL_ExtensionSupported(const char *extension) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); const char *extensions; const char *start; @@ -3465,7 +3520,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Lookup the available extensions */ glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return SDL_FALSE; } @@ -3477,7 +3532,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi"); glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); - if ((glGetStringiFunc == NULL) || (glGetIntegervFunc == NULL)) { + if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { return SDL_FALSE; } @@ -3498,7 +3553,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Try the old way with glGetString(GL_EXTENSIONS) ... */ extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } /* @@ -3510,7 +3565,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -3539,7 +3594,7 @@ void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) { /* THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. */ /* Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. */ -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) /* XXX This is fragile; it will break in the event of release of * new versions of OpenGL ES. */ @@ -3559,9 +3614,9 @@ void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) #endif } -void SDL_GL_ResetAttributes() +void SDL_GL_ResetAttributes(void) { - if (_this == NULL) { + if (!_this) { return; } @@ -3584,15 +3639,15 @@ void SDL_GL_ResetAttributes() _this->gl_config.retained_backing = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; _this->gl_config.minor_version = 1; _this->gl_config.profile_mask = 0; -#elif SDL_VIDEO_OPENGL_ES2 +#elif defined(SDL_VIDEO_OPENGL_ES2) _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; -#elif SDL_VIDEO_OPENGL_ES +#elif defined(SDL_VIDEO_OPENGL_ES) _this->gl_config.major_version = 1; _this->gl_config.minor_version = 1; _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; @@ -3615,10 +3670,10 @@ void SDL_GL_ResetAttributes() int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } retval = 0; @@ -3738,7 +3793,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) GLenum(APIENTRY * glGetErrorFunc)(void); GLenum attrib = 0; GLenum error = 0; @@ -3749,51 +3804,51 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) * the enums we use for the former function don't exist in OpenGL ES 2, and * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2. */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL const GLubyte *(APIENTRY * glGetStringFunc)(GLenum name); void(APIENTRY * glGetFramebufferAttachmentParameterivFunc)(GLenum target, GLenum attachment, GLenum pname, GLint * params); GLenum attachment = GL_BACK_LEFT; GLenum attachmentattrib = 0; #endif - if (value == NULL) { + if (!value) { return SDL_InvalidParamError("value"); } /* Clear value in any case */ *value = 0; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } switch (attr) { case SDL_GL_RED_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; #endif attrib = GL_RED_BITS; break; case SDL_GL_BLUE_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE; #endif attrib = GL_BLUE_BITS; break; case SDL_GL_GREEN_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; #endif attrib = GL_GREEN_BITS; break; case SDL_GL_ALPHA_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE; #endif attrib = GL_ALPHA_BITS; break; case SDL_GL_DOUBLEBUFFER: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attrib = GL_DOUBLEBUFFER; break; #else @@ -3804,20 +3859,20 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; #endif case SDL_GL_DEPTH_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachment = GL_DEPTH; attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE; #endif attrib = GL_DEPTH_BITS; break; case SDL_GL_STENCIL_SIZE: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attachment = GL_STENCIL; attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE; #endif attrib = GL_STENCIL_BITS; break; -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL case SDL_GL_ACCUM_RED_SIZE: attrib = GL_ACCUM_RED_BITS; break; @@ -3850,7 +3905,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) attrib = GL_SAMPLES; break; case SDL_GL_CONTEXT_RELEASE_BEHAVIOR: -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL attrib = GL_CONTEXT_RELEASE_BEHAVIOR; #else attrib = GL_CONTEXT_RELEASE_BEHAVIOR_KHR; @@ -3937,9 +3992,9 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return SDL_SetError("Unknown OpenGL attribute"); } -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return -1; } @@ -3977,7 +4032,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } glGetErrorFunc = SDL_GL_GetProcAddress("glGetError"); - if (glGetErrorFunc == NULL) { + if (!glGetErrorFunc) { return -1; } @@ -4024,7 +4079,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -4058,7 +4113,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) SDL_Window *SDL_GL_GetCurrentWindow(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4067,7 +4122,7 @@ SDL_Window *SDL_GL_GetCurrentWindow(void) SDL_GLContext SDL_GL_GetCurrentContext(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4087,7 +4142,7 @@ void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) int SDL_GL_SetSwapInterval(int interval) { - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } else if (SDL_GL_GetCurrentContext() == NULL) { return SDL_SetError("No OpenGL context has been made current"); @@ -4100,7 +4155,7 @@ int SDL_GL_SetSwapInterval(int interval) int SDL_GL_GetSwapInterval(void) { - if (_this == NULL) { + if (!_this) { return 0; } else if (SDL_GL_GetCurrentContext() == NULL) { return 0; @@ -4133,7 +4188,7 @@ void SDL_GL_SwapWindow(SDL_Window *window) void SDL_GL_DeleteContext(SDL_GLContext context) { - if (_this == NULL || !context) { + if (!_this || !context) { return; } @@ -4351,59 +4406,6 @@ int SDL_GetMessageBoxCount(void) return SDL_AtomicGet(&SDL_messagebox_count); } -#if SDL_VIDEO_DRIVER_ANDROID -#include "android/SDL_androidmessagebox.h" -#endif -#if SDL_VIDEO_DRIVER_WINDOWS -#include "windows/SDL_windowsmessagebox.h" -#endif -#if SDL_VIDEO_DRIVER_WINRT -#include "winrt/SDL_winrtmessagebox.h" -#endif -#if SDL_VIDEO_DRIVER_COCOA -#include "cocoa/SDL_cocoamessagebox.h" -#endif -#if SDL_VIDEO_DRIVER_UIKIT -#include "uikit/SDL_uikitmessagebox.h" -#endif -#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_RISCOS -#include "riscos/SDL_riscosmessagebox.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_WAYLAND || SDL_VIDEO_DRIVER_HAIKU || SDL_VIDEO_DRIVER_OS2 || SDL_VIDEO_DRIVER_RISCOS -static SDL_bool SDL_MessageboxValidForDriver(const SDL_MessageBoxData *messageboxdata, SDL_SYSWM_TYPE drivertype) -{ - SDL_SysWMinfo info; - SDL_Window *window = messageboxdata->window; - - if (!window) { - return SDL_TRUE; - } - - SDL_VERSION(&info.version); - if (!SDL_GetWindowWMInfo(window, &info)) { - return SDL_TRUE; - } else { - return (info.subsystem == drivertype); - } -} -#endif - int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { int dummybutton; @@ -4413,7 +4415,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_Window *current_window; SDL_MessageBoxData mbdata; - if (messageboxdata == NULL) { + if (!messageboxdata) { return SDL_InvalidParamError("messageboxdata"); } else if (messageboxdata->numbuttons < 0) { return SDL_SetError("Invalid number of buttons"); @@ -4428,7 +4430,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) show_cursor_prev = SDL_ShowCursor(1); SDL_ResetKeyboard(); - if (buttonid == NULL) { + if (!buttonid) { buttonid = &dummybutton; } @@ -4445,84 +4447,38 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) if (_this && _this->ShowMessageBox) { retval = _this->ShowMessageBox(_this, messageboxdata, buttonid); - } + } else { + /* It's completely fine to call this function before video is initialized */ + const char *driver_name = SDL_GetHint(SDL_HINT_VIDEODRIVER); + int i; + if (driver_name && *driver_name != 0) { + const char *driver_attempt = driver_name; + while (driver_attempt && (*driver_attempt != 0) && (retval == -1)) { + const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) + : SDL_strlen(driver_attempt); + for (i = 0; bootstrap[i]; ++i) { + if (bootstrap[i]->ShowMessageBox && (driver_attempt_len == SDL_strlen(bootstrap[i]->name)) && + (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) { + if (bootstrap[i]->ShowMessageBox(messageboxdata, buttonid) == 0) { + retval = 0; + } + break; + } + } - /* It's completely fine to call this function before video is initialized */ -#if SDL_VIDEO_DRIVER_ANDROID - if (retval == -1 && - Android_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINDOWS) && - WIN_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_WINRT - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_WINRT) && - WINRT_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_COCOA - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_COCOA) && - Cocoa_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_UIKIT - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_UIKIT) && - UIKit_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_X11 - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_X11) && - X11_ShowMessageBox(messageboxdata, buttonid) == 0) { - 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) && - HAIKU_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_OS2 - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_OS2) && - OS2_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_RISCOS - if (retval == -1 && - SDL_MessageboxValidForDriver(messageboxdata, SDL_SYSWM_RISCOS) && - RISCOS_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; - } -#endif -#if SDL_VIDEO_DRIVER_VITA - if (retval == -1 && - VITA_ShowMessageBox(messageboxdata, buttonid) == 0) { - retval = 0; + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; + } + } else { + for (i = 0; bootstrap[i]; ++i) { + if (bootstrap[i]->ShowMessageBox && bootstrap[i]->ShowMessageBox(messageboxdata, buttonid) == 0) { + retval = 0; + break; + } + } + } } -#endif + if (retval == -1) { const char *error = SDL_GetError(); @@ -4551,10 +4507,10 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag /* Web browsers don't (currently) have an API for a custom message box that can block, but for the most common case (SDL_ShowSimpleMessageBox), we can use the standard Javascript alert() function. */ - if (title == NULL) { + if (!title) { title = ""; } - if (message == NULL) { + if (!message) { message = ""; } EM_ASM({ @@ -4631,7 +4587,7 @@ void SDL_OnApplicationWillResignActive(void) { if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } @@ -4655,7 +4611,7 @@ void SDL_OnApplicationDidBecomeActive(void) if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } @@ -4667,7 +4623,7 @@ void SDL_OnApplicationDidBecomeActive(void) int SDL_Vulkan_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return -1; } @@ -4690,7 +4646,7 @@ int SDL_Vulkan_LoadLibrary(const char *path) void *SDL_Vulkan_GetVkGetInstanceProcAddr(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4703,7 +4659,7 @@ void *SDL_Vulkan_GetVkGetInstanceProcAddr(void) void SDL_Vulkan_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -4728,7 +4684,7 @@ SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, c } } - if (count == NULL) { + if (!count) { SDL_InvalidParamError("count"); return SDL_FALSE; } @@ -4752,7 +4708,7 @@ SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window, return SDL_FALSE; } - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return SDL_FALSE; } @@ -4824,4 +4780,93 @@ void SDL_Metal_GetDrawableSize(SDL_Window *window, int *w, int *h) } } +#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) +const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name) +{ + /* Reference: https://www.w3.org/TR/css-ui-4/#cursor */ + /* Also in: https://www.freedesktop.org/wiki/Specifications/cursor-spec/ */ + switch (id) { + case SDL_SYSTEM_CURSOR_ARROW: + return "default"; + + case SDL_SYSTEM_CURSOR_IBEAM: + return "text"; + + case SDL_SYSTEM_CURSOR_WAIT: + return "wait"; + + case SDL_SYSTEM_CURSOR_CROSSHAIR: + return "crosshair"; + + case SDL_SYSTEM_CURSOR_WAITARROW: + return "progress"; + + case SDL_SYSTEM_CURSOR_SIZENWSE: + if (fallback_name) { + /* only a single arrow */ + *fallback_name = "nw-resize"; + } + return "nwse-resize"; + + case SDL_SYSTEM_CURSOR_SIZENESW: + if (fallback_name) { + /* only a single arrow */ + *fallback_name = "ne-resize"; + } + return "nesw-resize"; + + case SDL_SYSTEM_CURSOR_SIZEWE: + if (fallback_name) { + *fallback_name = "col-resize"; + } + return "ew-resize"; + + case SDL_SYSTEM_CURSOR_SIZENS: + if (fallback_name) { + *fallback_name = "row-resize"; + } + return "ns-resize"; + + case SDL_SYSTEM_CURSOR_SIZEALL: + return "all-scroll"; + + case SDL_SYSTEM_CURSOR_NO: + return "not-allowed"; + + case SDL_SYSTEM_CURSOR_HAND: + return "pointer"; + +#if 0 + case SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT: + return "nw-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_TOP: + return "n-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT: + return "ne-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_RIGHT: + return "e-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT: + return "se-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_BOTTOM: + return "s-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT: + return "sw-resize"; + + case SDL_SYSTEM_CURSOR_WINDOW_LEFT: + return "w-resize"; +#endif + + default: + SDL_assert(0); + return "default"; + } +} +#endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/video/SDL_vulkan_internal.h b/vs/sdl2/src/video/SDL_vulkan_internal.h index ff731c3448..28728fadc5 100644 --- a/vs/sdl2/src/video/SDL_vulkan_internal.h +++ b/vs/sdl2/src/video/SDL_vulkan_internal.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,34 +25,34 @@ #include "SDL_stdinc.h" -#if SDL_VIDEO_VULKAN -#if SDL_LOADSO_DISABLED || SDL_LOADSO_DUMMY +#ifdef SDL_VIDEO_VULKAN +#if defined(SDL_LOADSO_DISABLED) || defined(SDL_LOADSO_DUMMY) #error You should not be here. #endif -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #define VK_USE_PLATFORM_ANDROID_KHR #endif -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #define VK_USE_PLATFORM_METAL_EXT #define VK_USE_PLATFORM_MACOS_MVK #endif -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #define VK_USE_PLATFORM_DIRECTFB_EXT #endif -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define VK_USE_PLATFORM_METAL_EXT #define VK_USE_PLATFORM_IOS_MVK #endif -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #define VK_USE_PLATFORM_WAYLAND_KHR #include "wayland/SDL_waylanddyn.h" #endif -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS #define VK_USE_PLATFORM_WIN32_KHR #include "../core/windows/SDL_windows.h" #endif -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #define VK_USE_PLATFORM_XLIB_KHR #define VK_USE_PLATFORM_XCB_KHR #endif diff --git a/vs/sdl2/src/video/SDL_vulkan_utils.c b/vs/sdl2/src/video/SDL_vulkan_utils.c index 3d5827f699..7a1579d75a 100644 --- a/vs/sdl2/src/video/SDL_vulkan_utils.c +++ b/vs/sdl2/src/video/SDL_vulkan_utils.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_vulkan_internal.h" #include "SDL_error.h" -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN const char *SDL_Vulkan_GetResultString(VkResult result) { @@ -149,7 +149,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( retval = SDL_calloc(count, sizeof(VkExtensionProperties)); } - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -232,7 +232,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, goto error; } chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY"); - if (chosenDisplayId != NULL) { + if (chosenDisplayId) { displayId = SDL_atoi(chosenDisplayId); } @@ -249,7 +249,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if (physicalDevices == NULL) { + if (!physicalDevices) { SDL_OutOfMemory(); goto error; } @@ -292,7 +292,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount); - if (displayProperties == NULL) { + if (!displayProperties) { SDL_OutOfMemory(); goto error; } @@ -321,7 +321,7 @@ 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 == NULL) { + if (!displayModeProperties) { SDL_OutOfMemory(); goto error; } @@ -368,7 +368,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount); displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount); - if (displayPlaneProperties == NULL) { + if (!displayPlaneProperties) { SDL_OutOfMemory(); goto error; } @@ -399,7 +399,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, 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 == NULL) { + if (!planeSupportedDisplays) { SDL_free(displayPlaneProperties); SDL_OutOfMemory(); goto error; diff --git a/vs/sdl2/src/video/SDL_yuv.c b/vs/sdl2/src/video/SDL_yuv.c index dd79d79cff..14f57468d3 100644 --- a/vs/sdl2/src/video/SDL_yuv.c +++ b/vs/sdl2/src/video/SDL_yuv.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ void SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode) SDL_YUV_ConversionMode = mode; } -SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode() +SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode(void) { return SDL_YUV_ConversionMode; } @@ -597,7 +597,7 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -978,7 +978,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -1067,7 +1067,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src /* Allocate a temporary row for the swap */ tmp = (Uint8 *)SDL_malloc(UVwidth); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } for (y = 0; y < UVheight; ++y) { @@ -1127,7 +1127,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const voi if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch); @@ -1200,7 +1200,7 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const vo if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch); diff --git a/vs/sdl2/src/video/SDL_yuv_c.h b/vs/sdl2/src/video/SDL_yuv_c.h index 59ee9b6be2..3fda84b7fd 100644 --- a/vs/sdl2/src/video/SDL_yuv_c.h +++ b/vs/sdl2/src/video/SDL_yuv_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidclipboard.c b/vs/sdl2/src/video/android/SDL_androidclipboard.c index bd80a01008..afd729eca8 100644 --- a/vs/sdl2/src/video/android/SDL_androidclipboard.c +++ b/vs/sdl2/src/video/android/SDL_androidclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include "SDL_androidvideo.h" #include "SDL_androidclipboard.h" diff --git a/vs/sdl2/src/video/android/SDL_androidclipboard.h b/vs/sdl2/src/video/android/SDL_androidclipboard.h index 627492ada2..8097d71993 100644 --- a/vs/sdl2/src/video/android/SDL_androidclipboard.h +++ b/vs/sdl2/src/video/android/SDL_androidclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidevents.c b/vs/sdl2/src/video/android/SDL_androidevents.c index ad669f892d..d125c92bd1 100644 --- a/vs/sdl2/src/video/android/SDL_androidevents.c +++ b/vs/sdl2/src/video/android/SDL_androidevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +20,11 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include "SDL_androidevents.h" #include "SDL_events.h" +#include "SDL_hints.h" #include "SDL_androidkeyboard.h" #include "SDL_androidwindow.h" #include "../SDL_sysvideo.h" @@ -32,7 +33,7 @@ /* Can't include sysaudio "../../audio/android/SDL_androidaudio.h" * because of THIS redefinition */ -#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_ANDROID +#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_ANDROID) extern void ANDROIDAUDIO_ResumeDevices(void); extern void ANDROIDAUDIO_PauseDevices(void); #else @@ -40,7 +41,7 @@ static void ANDROIDAUDIO_ResumeDevices(void) {} static void ANDROIDAUDIO_PauseDevices(void) {} #endif -#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_OPENSLES +#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_OPENSLES) extern void openslES_ResumeDevices(void); extern void openslES_PauseDevices(void); #else @@ -50,7 +51,7 @@ static void openslES_ResumeDevices(void) static void openslES_PauseDevices(void) {} #endif -#if !SDL_AUDIO_DISABLED && SDL_AUDIO_DRIVER_AAUDIO +#if !defined(SDL_AUDIO_DISABLED) && defined(SDL_AUDIO_DRIVER_AAUDIO) extern void aaudio_ResumeDevices(void); extern void aaudio_PauseDevices(void); SDL_bool aaudio_DetectBrokenPlayState(void); @@ -68,12 +69,13 @@ static int SDL_NumberOfEvents(Uint32 type) return SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type); } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL static void android_egl_context_restore(SDL_Window *window) { if (window) { SDL_Event event; SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_GL_MakeCurrent(window, NULL); if (SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context) < 0) { /* The context is no longer valid, create a new one */ data->egl_context = (EGLContext)SDL_GL_CreateContext(window); @@ -112,7 +114,7 @@ void Android_PumpEvents_Blocking(_THIS) if (videodata->isPaused) { SDL_bool isContextExternal = SDL_IsVideoContextExternal(); -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Make sure this is the last thing we do before pausing */ if (!isContextExternal) { SDL_LockMutex(Android_ActivityMutex); @@ -139,7 +141,7 @@ void Android_PumpEvents_Blocking(_THIS) aaudio_ResumeDevices(); /* Restore the GL Context from here, as this operation is thread dependent */ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_restore(Android_Window); @@ -148,9 +150,7 @@ void Android_PumpEvents_Blocking(_THIS) #endif /* Make sure SW Keyboard is restored when an app becomes foreground */ - if (SDL_IsTextInputActive()) { - Android_StartTextInput(_this); /* Only showTextInput */ - } + Android_RestoreScreenKeyboardOnResume(_this, Android_Window); } } else { if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) { @@ -190,7 +190,7 @@ void Android_PumpEvents_NonBlocking(_THIS) SDL_bool isContextExternal = SDL_IsVideoContextExternal(); if (backup_context) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (!isContextExternal) { SDL_LockMutex(Android_ActivityMutex); android_egl_context_backup(Android_Window); @@ -222,7 +222,7 @@ void Android_PumpEvents_NonBlocking(_THIS) aaudio_ResumeDevices(); } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Restore the GL Context from here, as this operation is thread dependent */ if (!isContextExternal && !SDL_HasEvent(SDL_QUIT)) { SDL_LockMutex(Android_ActivityMutex); @@ -232,9 +232,7 @@ void Android_PumpEvents_NonBlocking(_THIS) #endif /* Make sure SW Keyboard is restored when an app becomes foreground */ - if (SDL_IsTextInputActive()) { - Android_StartTextInput(_this); /* Only showTextInput */ - } + Android_RestoreScreenKeyboardOnResume(_this, Android_Window); } } else { if (videodata->isPausing || SDL_SemTryWait(Android_PauseSem) == 0) { diff --git a/vs/sdl2/src/video/android/SDL_androidevents.h b/vs/sdl2/src/video/android/SDL_androidevents.h index 103d166c97..921daa6cf9 100644 --- a/vs/sdl2/src/video/android/SDL_androidevents.h +++ b/vs/sdl2/src/video/android/SDL_androidevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidgl.c b/vs/sdl2/src/video/android/SDL_androidgl.c index e54dbbed16..5e5ef603ea 100644 --- a/vs/sdl2/src/video/android/SDL_androidgl.c +++ b/vs/sdl2/src/video/android/SDL_androidgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_ANDROID) && defined(SDL_VIDEO_OPENGL_EGL) /* Android SDL video driver implementation */ diff --git a/vs/sdl2/src/video/android/SDL_androidgl.h b/vs/sdl2/src/video/android/SDL_androidgl.h index 34bd229841..4fb505c1f7 100644 --- a/vs/sdl2/src/video/android/SDL_androidgl.h +++ b/vs/sdl2/src/video/android/SDL_androidgl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidkeyboard.c b/vs/sdl2/src/video/android/SDL_androidkeyboard.c index ba652019aa..b55de02977 100644 --- a/vs/sdl2/src/video/android/SDL_androidkeyboard.c +++ b/vs/sdl2/src/video/android/SDL_androidkeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include @@ -313,6 +313,8 @@ static SDL_Scancode Android_Keycodes[] = { SDL_SCANCODE_PASTE, /* AKEYCODE_PASTE */ }; +static SDL_bool SDL_screen_keyboard_shown; + static SDL_Scancode TranslateKeycode(int keycode) { SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; @@ -341,27 +343,36 @@ SDL_bool Android_HasScreenKeyboardSupport(_THIS) return SDL_TRUE; } -SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window) +void Android_ShowScreenKeyboard(_THIS, SDL_Window *window) { - return Android_JNI_IsScreenKeyboardShown(); + SDL_VideoData *videodata = _this->driverdata; + Android_JNI_ShowScreenKeyboard(&videodata->textRect); + SDL_screen_keyboard_shown = SDL_TRUE; } -void Android_StartTextInput(_THIS) +void Android_HideScreenKeyboard(_THIS, SDL_Window *window) { - SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; - Android_JNI_ShowTextInput(&videodata->textRect); + Android_JNI_HideScreenKeyboard(); + SDL_screen_keyboard_shown = SDL_FALSE; +} + +void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window) +{ + if (SDL_screen_keyboard_shown) { + Android_ShowScreenKeyboard(_this, window); + } } -void Android_StopTextInput(_THIS) +SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window) { - Android_JNI_HideTextInput(); + return Android_JNI_IsScreenKeyboardShown(); } void Android_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/vs/sdl2/src/video/android/SDL_androidkeyboard.h b/vs/sdl2/src/video/android/SDL_androidkeyboard.h index 81b593fb10..4081ac674f 100644 --- a/vs/sdl2/src/video/android/SDL_androidkeyboard.h +++ b/vs/sdl2/src/video/android/SDL_androidkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +26,10 @@ extern int Android_OnKeyDown(int keycode); extern int Android_OnKeyUp(int keycode); extern SDL_bool Android_HasScreenKeyboardSupport(_THIS); +extern void Android_ShowScreenKeyboard(_THIS, SDL_Window *window); +extern void Android_HideScreenKeyboard(_THIS, SDL_Window *window); +extern void Android_RestoreScreenKeyboardOnResume(_THIS, SDL_Window *window); extern SDL_bool Android_IsScreenKeyboardShown(_THIS, SDL_Window *window); - -extern void Android_StartTextInput(_THIS); -extern void Android_StopTextInput(_THIS); extern void Android_SetTextInputRect(_THIS, const SDL_Rect *rect); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/src/video/android/SDL_androidmessagebox.c b/vs/sdl2/src/video/android/SDL_androidmessagebox.c index 81f6f38a62..cb2ad28079 100644 --- a/vs/sdl2/src/video/android/SDL_androidmessagebox.c +++ b/vs/sdl2/src/video/android/SDL_androidmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include "SDL_messagebox.h" #include "SDL_androidmessagebox.h" diff --git a/vs/sdl2/src/video/android/SDL_androidmessagebox.h b/vs/sdl2/src/video/android/SDL_androidmessagebox.h index 9dabc9e4d3..7c93c0eff6 100644 --- a/vs/sdl2/src/video/android/SDL_androidmessagebox.h +++ b/vs/sdl2/src/video/android/SDL_androidmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID extern int Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/android/SDL_androidmouse.c b/vs/sdl2/src/video/android/SDL_androidmouse.c index 7d9ab0928a..29ee05e356 100644 --- a/vs/sdl2/src/video/android/SDL_androidmouse.c +++ b/vs/sdl2/src/video/android/SDL_androidmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include "SDL_androidmouse.h" @@ -89,7 +89,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y); @@ -118,7 +118,7 @@ static void Android_FreeCursor(SDL_Cursor *cursor) static SDL_Cursor *Android_CreateEmptyCursor() { - if (empty_cursor == NULL) { + if (!empty_cursor) { SDL_Surface *empty_surface = SDL_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888); if (empty_surface) { SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch); @@ -139,7 +139,7 @@ static void Android_DestroyEmptyCursor() static int Android_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = Android_CreateEmptyCursor(); } if (cursor) { @@ -216,7 +216,7 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y int changes; Uint8 button; - if (window == NULL) { + if (!window) { return; } diff --git a/vs/sdl2/src/video/android/SDL_androidmouse.h b/vs/sdl2/src/video/android/SDL_androidmouse.h index 11c5ede205..6ff724986b 100644 --- a/vs/sdl2/src/video/android/SDL_androidmouse.h +++ b/vs/sdl2/src/video/android/SDL_androidmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidtouch.c b/vs/sdl2/src/video/android/SDL_androidtouch.c index a62ae9eb8e..c44f2b0ded 100644 --- a/vs/sdl2/src/video/android/SDL_androidtouch.c +++ b/vs/sdl2/src/video/android/SDL_androidtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include @@ -54,7 +54,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin SDL_TouchID touchDeviceId = 0; SDL_FingerID fingerId = 0; - if (window == NULL) { + if (!window) { return; } diff --git a/vs/sdl2/src/video/android/SDL_androidtouch.h b/vs/sdl2/src/video/android/SDL_androidtouch.h index 1e87391582..067842a606 100644 --- a/vs/sdl2/src/video/android/SDL_androidtouch.h +++ b/vs/sdl2/src/video/android/SDL_androidtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidvideo.c b/vs/sdl2/src/video/android/SDL_androidvideo.c index 714fa45a59..f54b4c3cdd 100644 --- a/vs/sdl2/src/video/android/SDL_androidvideo.c +++ b/vs/sdl2/src/video/android/SDL_androidvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID /* Android SDL video driver implementation */ @@ -41,6 +41,7 @@ #include "SDL_androidtouch.h" #include "SDL_androidwindow.h" #include "SDL_androidvulkan.h" +#include "SDL_androidmessagebox.h" #define ANDROID_VID_DRIVER_NAME "Android" @@ -88,13 +89,13 @@ static SDL_VideoDevice *Android_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -125,7 +126,7 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->free = Android_DeleteDevice; /* GL pointers */ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = Android_GLES_LoadLibrary; device->GL_GetProcAddress = Android_GLES_GetProcAddress; device->GL_UnloadLibrary = Android_GLES_UnloadLibrary; @@ -137,7 +138,7 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->GL_DeleteContext = Android_GLES_DeleteContext; #endif -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = Android_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = Android_Vulkan_GetInstanceExtensions; @@ -148,12 +149,12 @@ static SDL_VideoDevice *Android_CreateDevice(void) device->SuspendScreenSaver = Android_SuspendScreenSaver; /* Text input */ - device->StartTextInput = Android_StartTextInput; - device->StopTextInput = Android_StopTextInput; device->SetTextInputRect = Android_SetTextInputRect; /* Screen keyboard */ device->HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = Android_ShowScreenKeyboard; + device->HideScreenKeyboard = Android_HideScreenKeyboard; device->IsScreenKeyboardShown = Android_IsScreenKeyboardShown; /* Clipboard */ @@ -166,7 +167,8 @@ static SDL_VideoDevice *Android_CreateDevice(void) VideoBootStrap Android_bootstrap = { ANDROID_VID_DRIVER_NAME, "SDL Android video driver", - Android_CreateDevice + Android_CreateDevice, + Android_ShowMessageBox }; int Android_VideoInit(_THIS) diff --git a/vs/sdl2/src/video/android/SDL_androidvideo.h b/vs/sdl2/src/video/android/SDL_androidvideo.h index 41194b404a..7eb4f9ac50 100644 --- a/vs/sdl2/src/video/android/SDL_androidvideo.h +++ b/vs/sdl2/src/video/android/SDL_androidvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/android/SDL_androidvulkan.c b/vs/sdl2/src/video/android/SDL_androidvulkan.c index 088d85e781..6ade57ed8c 100644 --- a/vs/sdl2/src/video/android/SDL_androidvulkan.c +++ b/vs/sdl2/src/video/android/SDL_androidvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_ANDROID +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID) #include "SDL_androidvideo.h" #include "SDL_androidwindow.h" @@ -47,10 +47,10 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "libvulkan.so"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -75,7 +75,7 @@ int Android_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/vs/sdl2/src/video/android/SDL_androidvulkan.h b/vs/sdl2/src/video/android/SDL_androidvulkan.h index 5e39d93a97..caee0a6728 100644 --- a/vs/sdl2/src/video/android/SDL_androidvulkan.h +++ b/vs/sdl2/src/video/android/SDL_androidvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_ANDROID +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID) int Android_Vulkan_LoadLibrary(_THIS, const char *path); void Android_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/android/SDL_androidwindow.c b/vs/sdl2/src/video/android/SDL_androidwindow.c index 9b3573973a..2624331e07 100644 --- a/vs/sdl2/src/video/android/SDL_androidwindow.c +++ b/vs/sdl2/src/video/android/SDL_androidwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_ANDROID +#ifdef SDL_VIDEO_DRIVER_ANDROID #include "SDL_syswm.h" #include "../SDL_sysvideo.h" @@ -65,7 +65,7 @@ int Android_CreateWindow(_THIS, SDL_Window *window) SDL_SetKeyboardFocus(window); data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { retval = SDL_OutOfMemory(); goto endfunction; } @@ -80,7 +80,7 @@ int Android_CreateWindow(_THIS, SDL_Window *window) /* Do not create EGLSurface for Vulkan window since it will then make the window incompatible with vkCreateAndroidSurfaceKHR */ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->native_window); @@ -132,7 +132,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di } data = (SDL_WindowData *)window->driverdata; - if (data == NULL || !data->native_window) { + if (!data || !data->native_window) { if (data && !data->native_window) { SDL_SetError("Missing native window"); } @@ -180,7 +180,7 @@ void Android_DestroyWindow(_THIS, SDL_Window *window) if (window->driverdata) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); } @@ -205,7 +205,7 @@ SDL_bool Android_GetWindowWMInfo(_THIS, SDL_Window *window, SDL_SysWMinfo *info) info->subsystem = SDL_SYSWM_ANDROID; info->info.android.window = data->native_window; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL info->info.android.surface = data->egl_surface; #endif diff --git a/vs/sdl2/src/video/android/SDL_androidwindow.h b/vs/sdl2/src/video/android/SDL_androidwindow.h index 1d529365c5..240c77ce34 100644 --- a/vs/sdl2/src/video/android/SDL_androidwindow.h +++ b/vs/sdl2/src/video/android/SDL_androidwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ extern SDL_Window *Android_Window; typedef struct { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; EGLContext egl_context; /* We use this to preserve the context when losing focus */ #endif diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.h b/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.h index b6ec8e79c1..a7b7a548e4 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.m b/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.m index c64f2e4768..136dba44ec 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaclipboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_cocoavideo.h" #include "../../events/SDL_clipboardevents_c.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaevents.h b/vs/sdl2/src/video/cocoa/SDL_cocoaevents.h index 1f8f84d795..421df3aa19 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaevents.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaevents.m b/vs/sdl2/src/video/cocoa/SDL_cocoaevents.m index 99db10c694..441985da2d 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaevents.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_timer.h" @@ -138,6 +138,7 @@ @interface SDLAppDelegate : NSObject { - (id)init; - (void)localeDidChange:(NSNotification *)notification; +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app; @end @implementation SDLAppDelegate : NSObject @@ -310,6 +311,22 @@ - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEv SDL_SendDropComplete(NULL); } +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app +{ + // This just tells Cocoa that we didn't do any custom save state magic for the app, + // so the system is safe to use NSSecureCoding internally, instead of using unencrypted + // save states for backwards compatibility. If we don't return YES here, we'll get a + // warning on the console at startup: + // + // ``` + // WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. + // ``` + // + // More-detailed explanation: + // https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate/77320845#77320845 + return YES; +} + @end static SDLAppDelegate *appDelegate = nil; diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.h b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.h index 8b8df41123..d08066403c 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m index 616800d5cc..605a4d4fcf 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_cocoavideo.h" @@ -33,30 +33,11 @@ /*#define DEBUG_IME NSLog */ #define DEBUG_IME(...) -#if 1 // inserted for DOSBox-X -@interface IMETextView : NSView -@property (nonatomic, copy) NSAttributedString *text; -@end - -@implementation IMETextView -- (void)drawRect:(NSRect)dirtyRect -{ - CGSize size; - [super drawRect:dirtyRect]; - size = [_text size]; - [[NSColor whiteColor] set]; - NSRectFill(self.bounds); - [_text drawInRect:CGRectMake(0, 0, size.width, size.height)]; -} -@end -#endif - @interface SDLTranslatorResponder : NSView { NSString *_markedText; NSRange _markedRange; NSRange _selectedRange; SDL_Rect _inputRect; - IMETextView *_markedLabel; // inserted for DOSBox-X } - (void)doCommandBySelector:(SEL)myselector; - (void)setInputRect:(const SDL_Rect *)rect; @@ -91,8 +72,6 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange } SDL_SendKeyboardText(str); - [_markedLabel setHidden:YES]; // inserted for DOSBox-X - _markedLabel.text = nil; // inserted for DOSBox-X } - (void)doCommandBySelector:(SEL)myselector @@ -118,21 +97,9 @@ - (NSRange)selectedRange return _selectedRange; } -static SDL_bool ime_incompos = 0; // inserted for DOSBox-X -static long end_ticks = 0; // inserted for DOSBox-X - - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { if ([aString isKindOfClass:[NSAttributedString class]]) { -#if 1 // inserted for DOSBox-X - CGSize size; - [aString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:_inputRect.h] range:NSMakeRange(0, [aString length])]; - _markedLabel.text = aString; - size = [aString size]; - [_markedLabel setFrameSize:size]; - [_markedLabel setHidden:NO]; - [_markedLabel setNeedsDisplay:YES]; -#endif aString = [aString string]; } @@ -141,7 +108,6 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme return; } - ime_incompos = 1; // inserted for DOSBox-X if (_markedText != aString) { _markedText = aString; } @@ -154,50 +120,22 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme DEBUG_IME(@"setMarkedText: %@, (%d, %d)", _markedText, selectedRange.location, selectedRange.length); - ime_incompos = 0; //inserted for DOSBox-X - end_ticks = TickCount(); //inserted for DOSBox-X } - (void)unmarkText { - //[_markedText release]; // Maybe required for DOSBox-X - _markedText = nil; - [_markedLabel setHidden:YES]; // inserted for DOSBox-X - SDL_SendEditingText("", 0, 0); -} - -#if 1 // inserted for DOSBox-X -#define IME_END_CR_WAIT 25 -SDL_bool SDL_IM_Composition(int more) { - return ime_incompos||(end_ticks&&(TickCount()-end_ticks + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA extern int Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.m b/vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.m index a8f29a9b8c..4e342c1d5e 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoamessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_events.h" #include "SDL_timer.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoametalview.h b/vs/sdl2/src/video/cocoa/SDL_cocoametalview.h index 22571eb91b..d4a537400e 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoametalview.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoametalview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #ifndef SDL_cocoametalview_h_ #define SDL_cocoametalview_h_ -#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) +#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) #import "../SDL_sysvideo.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoametalview.m b/vs/sdl2/src/video/cocoa/SDL_cocoametalview.m index fab4652e7e..d71f6511d0 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoametalview.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoametalview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #import "SDL_cocoametalview.h" -#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) +#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) #include "SDL_events.h" #include "SDL_syswm.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoamodes.h b/vs/sdl2/src/video/cocoa/SDL_cocoamodes.h index 02b636357f..426036e8c7 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoamodes.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoamodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoamodes.m b/vs/sdl2/src/video/cocoa/SDL_cocoamodes.m index 0517302af3..d1ef99e9c0 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoamodes.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoamodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_cocoavideo.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoamouse.h b/vs/sdl2/src/video/cocoa/SDL_cocoamouse.h index b85ce1cddc..0d5f5db2a7 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoamouse.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoamouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoamouse.m b/vs/sdl2/src/video/cocoa/SDL_cocoamouse.m index e85e16c9fb..c14f9abdc7 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoamouse.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoamouse.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_events.h" #include "SDL_cocoamouse.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.h b/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.h index 0bd549fc91..26462bb765 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_cocoaopengl_h_ #define SDL_cocoaopengl_h_ -#if SDL_VIDEO_OPENGL_CGL +#ifdef SDL_VIDEO_OPENGL_CGL #include "SDL_atomic.h" #import diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.m b/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.m index 0ac8e3e247..bda93159da 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaopengl.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ /* NSOpenGL implementation of SDL OpenGL support */ -#if SDL_VIDEO_OPENGL_CGL +#ifdef SDL_VIDEO_OPENGL_CGL #include "SDL_cocoavideo.h" #include "SDL_cocoaopengl.h" #include "SDL_cocoaopengles.h" @@ -270,7 +270,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window) int interval; if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Switch to EGL based functions */ Cocoa_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.h b/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.h index 1230762159..0729b6be0b 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_cocoaopengles_h_ #define SDL_cocoaopengles_h_ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.m b/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.m index 17f0b4cb7b..abb2014c9f 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoaopengles.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_COCOA) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_cocoavideo.h" #include "SDL_cocoaopengles.h" @@ -32,7 +32,7 @@ int Cocoa_GLES_LoadLibrary(_THIS, const char *path) { /* If the profile requested is not GL ES, switch over to WIN_GL functions */ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { -#if SDL_VIDEO_OPENGL_CGL +#ifdef SDL_VIDEO_OPENGL_CGL Cocoa_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = Cocoa_GL_LoadLibrary; _this->GL_GetProcAddress = Cocoa_GL_GetProcAddress; @@ -62,7 +62,7 @@ SDL_GLContext Cocoa_GLES_CreateContext(_THIS, SDL_Window * window) SDL_GLContext context; SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; -#if SDL_VIDEO_OPENGL_CGL +#ifdef SDL_VIDEO_OPENGL_CGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { /* Switch to CGL based functions */ Cocoa_GLES_UnloadLibrary(_this); diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoashape.h b/vs/sdl2/src/video/cocoa/SDL_cocoashape.h index 9f29ff9734..f37c2d4e15 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoashape.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoashape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoashape.m b/vs/sdl2/src/video/cocoa/SDL_cocoashape.m index 2fd9f59468..11642ded0b 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoashape.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoashape.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #include "SDL_cocoavideo.h" #include "SDL_shape.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoavideo.h b/vs/sdl2/src/video/cocoa/SDL_cocoavideo.h index 246ad045ff..0082171d9c 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoavideo.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoavideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoavideo.m b/vs/sdl2/src/video/cocoa/SDL_cocoavideo.m index a626b1b405..156af89150 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoavideo.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoavideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #if !__has_feature(objc_arc) #error SDL must be built with Objective-C ARC (automatic reference counting) enabled @@ -33,6 +33,7 @@ #include "SDL_cocoavulkan.h" #include "SDL_cocoametalview.h" #include "SDL_cocoaopengles.h" +#include "SDL_cocoamessagebox.h" @implementation SDL_VideoData @@ -127,7 +128,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; -#if SDL_VIDEO_OPENGL_CGL +#ifdef SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; @@ -137,7 +138,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; device->GL_SwapWindow = Cocoa_GL_SwapWindow; device->GL_DeleteContext = Cocoa_GL_DeleteContext; -#elif SDL_VIDEO_OPENGL_EGL +#elif defined(SDL_VIDEO_OPENGL_EGL) device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; device->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary; @@ -149,7 +150,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) device->GL_DeleteContext = Cocoa_GLES_DeleteContext; #endif -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions; @@ -157,7 +158,7 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) device->Vulkan_GetDrawableSize = Cocoa_Vulkan_GetDrawableSize; #endif -#if SDL_VIDEO_METAL +#ifdef SDL_VIDEO_METAL device->Metal_CreateView = Cocoa_Metal_CreateView; device->Metal_DestroyView = Cocoa_Metal_DestroyView; device->Metal_GetLayer = Cocoa_Metal_GetLayer; @@ -179,7 +180,8 @@ static void Cocoa_DeleteDevice(SDL_VideoDevice * device) VideoBootStrap COCOA_bootstrap = { "cocoa", "SDL Cocoa video driver", - Cocoa_CreateDevice + Cocoa_CreateDevice, + Cocoa_ShowMessageBox }; diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.h b/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.h index 85fc1f3c5e..fc90ee168a 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +33,7 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA) int Cocoa_Vulkan_LoadLibrary(_THIS, const char *path); void Cocoa_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.m b/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.m index 7481326f0a..d1ea16fef4 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoavulkan.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA) #include "SDL_cocoavideo.h" #include "SDL_cocoawindow.h" diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoawindow.h b/vs/sdl2/src/video/cocoa/SDL_cocoawindow.h index 7ed00fe634..0cf9e9a6ee 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoawindow.h +++ b/vs/sdl2/src/video/cocoa/SDL_cocoawindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #import -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "../SDL_egl_c.h" #endif @@ -132,7 +132,7 @@ typedef enum @property (nonatomic) NSInteger flash_request; @property (nonatomic) Cocoa_WindowListener *listener; @property (nonatomic) SDL_VideoData *videodata; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL @property (nonatomic) EGLSurface egl_surface; #endif @end diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoawindow.m b/vs/sdl2/src/video/cocoa/SDL_cocoawindow.m index f586bdb610..828366095c 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoawindow.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoawindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_COCOA +#ifdef SDL_VIDEO_DRIVER_COCOA #if MAC_OS_X_VERSION_MAX_ALLOWED < 1070 # error SDL for Mac OS X must be built with a 10.7 SDK or above. @@ -260,7 +260,7 @@ static void ConvertNSRect(NSScreen *screen, BOOL fullscreen, NSRect *r) static void ScheduleContextUpdates(SDL_WindowData *data) { /* We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. */ - #if SDL_VIDEO_OPENGL + #ifdef SDL_VIDEO_OPENGL #ifdef __clang__ #pragma clang diagnostic push @@ -460,6 +460,17 @@ static void Cocoa_UpdateClipCursor(SDL_Window * window) } } +static NSCursor *Cocoa_GetDesiredCursor(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) { + return (__bridge NSCursor *)mouse->cur_cursor->driverdata; + } + + return [NSCursor invisibleCursor]; +} + @implementation Cocoa_WindowListener @@ -1323,6 +1334,7 @@ - (void)mouseMoved:(NSEvent *)theEvent NSPoint point; int x, y; SDL_Window *window; + NSView *contentView; if (!mouse) { return; @@ -1330,6 +1342,17 @@ - (void)mouseMoved:(NSEvent *)theEvent mouseID = mouse->mouseID; window = _data.window; + contentView = _data.sdlContentView; + point = [theEvent locationInWindow]; + + if ([contentView mouse:[contentView convertPoint:point fromView:nil] inRect:[contentView bounds]] && + [NSCursor currentCursor] != Cocoa_GetDesiredCursor()) { + // The wrong cursor is on screen, fix it. This fixes an macOS bug that is only known to + // occur in fullscreen windows on the built-in displays of newer MacBooks with camera + // notches. When the mouse is moved near the top of such a window (within about 44 units) + // and then moved back down, the cursor rects aren't respected. + [_data.nswindow invalidateCursorRectsForView:contentView]; + } if ([self processHitTest:theEvent]) { SDL_SendWindowEvent(window, SDL_WINDOWEVENT_HIT_TEST, 0, 0); @@ -1340,7 +1363,6 @@ - (void)mouseMoved:(NSEvent *)theEvent return; } - point = [theEvent locationInWindow]; x = (int)point.x; y = (int)(window->h - point.y); @@ -1590,17 +1612,9 @@ - (BOOL)mouseDownCanMoveWindow - (void)resetCursorRects { - SDL_Mouse *mouse; [super resetCursorRects]; - mouse = SDL_GetMouse(); - - if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) { - [self addCursorRect:[self bounds] - cursor:(__bridge NSCursor *)mouse->cur_cursor->driverdata]; - } else { - [self addCursorRect:[self bounds] - cursor:[NSCursor invisibleCursor]]; - } + [self addCursorRect:[self bounds] + cursor:Cocoa_GetDesiredCursor()]; } - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent @@ -1788,8 +1802,8 @@ int Cocoa_CreateWindow(_THIS, SDL_Window * window) #pragma clang diagnostic pop #endif -#if SDL_VIDEO_OPENGL_ES2 -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_ES2 +#ifdef SDL_VIDEO_OPENGL_EGL if ((window->flags & SDL_WINDOW_OPENGL) && _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { [contentView setWantsLayer:TRUE]; @@ -1807,9 +1821,9 @@ int Cocoa_CreateWindow(_THIS, SDL_Window * window) } /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ -#if SDL_VIDEO_OPENGL_ES2 +#ifdef SDL_VIDEO_OPENGL_ES2 if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (Cocoa_GLES_SetupWindow(_this, window) < 0) { Cocoa_DestroyWindow(_this, window); return -1; @@ -2344,7 +2358,7 @@ void Cocoa_DestroyWindow(_THIS, SDL_Window * window) [data.nswindow close]; } - #if SDL_VIDEO_OPENGL + #ifdef SDL_VIDEO_OPENGL contexts = [data.nscontexts copy]; for (SDLOpenGLContext *context in contexts) { diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.c index f185cac334..d32ab5db8e 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_window.h" @@ -79,13 +79,13 @@ static void LoadFont(_THIS, SDL_Window * window) SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - if (windata->font != NULL) { + if (windata->font) { SDL_DFB_RELEASE(windata->font); windata->font = NULL; SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); } - if (windata->theme.font != NULL) + if (windata->theme.font) { DFBFontDescription fdesc; @@ -317,7 +317,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) SDL_FALLTHROUGH; default: windata->wm_grab = pos; - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE); DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE); windata->wm_lastx = evt->cx; @@ -350,7 +350,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) } } DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE); - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE); windata->wm_grab = WM_POS_NONE; return 1; diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.h index f8201ba2f6..d373ee6a01 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_WM.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.c index 02ed371a99..b4c734aaa4 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_dyn.h" @@ -93,7 +93,7 @@ int SDL_DirectFB_LoadLibrary(void) void SDL_DirectFB_UnLoadLibrary(void) { - if (handle != NULL) { + if (handle) { SDL_UnloadObject(handle); handle = NULL; } diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.h index 5b676b60ef..dc08d98750 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_events.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_events.c index 47a8e62063..1b2d654cb3 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_events.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB /* Handle the event stream, converting DirectFB input events into SDL events */ @@ -308,7 +308,7 @@ static void ProcessInputEvent(_THIS, DFBInputEvent * ievt) if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { - if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { + if ((grabbed_window) && (ievt->flags & DIEF_AXISREL)) { if (ievt->axis == DIAI_X) SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, ievt->axisrel, 0, 0); @@ -405,7 +405,7 @@ void DirectFB_PumpEventsWindow(_THIS) DFBInputEvent ievt; SDL_Window *w; - for (w = devdata->firstwin; w != NULL; w = w->next) { + for (w = devdata->firstwin; w; w = w->next) { SDL_DFB_WINDOWDATA(w); DFBWindowEvent evt; diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_events.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_events.h index 232757fd3e..65ee229fd3 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_events.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.c index 135b0843a6..3c69a82f03 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_modes.h" diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.h index 4a7114d58d..236ea8b23a 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.c index d0e1f291c4..363509e878 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.h index 446634dce1..6d90970bd2 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.c index 1c146a0e18..338d53a878 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +20,11 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL #include "SDL_DirectFB_opengl.h" #include "SDL_DirectFB_window.h" @@ -33,7 +33,7 @@ #include "SDL_loadso.h" #endif -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL struct SDL_GLDriverData { @@ -113,15 +113,15 @@ int DirectFB_GL_LoadLibrary(_THIS, const char *path) } - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = "libGL.so.1"; } } handle = GL_LoadObject(path); - if (handle == NULL) { + if (!handle) { SDL_DFB_ERR("Library not found: %s\n", path); /* SDL_LoadObject() will call SDL_SetError() for us. */ return -1; @@ -210,7 +210,7 @@ int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) } - if (ctx != NULL) { + if (ctx) { SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context)); ctx->is_locked = 1; } @@ -242,7 +242,7 @@ int DirectFB_GL_SwapWindow(_THIS, SDL_Window * window) devdata->glFlush(); #endif - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window && p->is_locked) { SDL_DFB_CHECKERR(p->context->Unlock(p->context)); @@ -278,7 +278,7 @@ void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { if (p->is_locked) @@ -291,7 +291,7 @@ void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { SDL_DFB_WINDOWDATA(window); @@ -306,7 +306,7 @@ void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) DirectFB_GL_DeleteContext(_this, p); } diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.h index 2436bf4198..3700da7677 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "SDL_DirectFB_video.h" -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL #include "SDL_opengl.h" diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_render.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_render.c index 40f0e1a0ca..0d96f86002 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_render.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_render.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_window.h" #include "SDL_DirectFB_modes.h" diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_render.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_render.h index 25a65c751e..76370396f5 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_render.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_render.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.c index a6c9aa092b..f738605731 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_shape.h" @@ -76,7 +76,7 @@ int DirectFB_ResizeWindowShape(SDL_Window* window) int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { - if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) + if(!shaper || !shape || !shaper->driverdata) return -1; if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) return -2; diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.h index d8a579f4a0..a34b571920 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_video.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_video.c index 5292732487..931a705412 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_video.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB /* * #include "SDL_DirectFB_keyboard.h" @@ -65,7 +65,8 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void); VideoBootStrap DirectFB_bootstrap = { "directfb", "DirectFB", - DirectFB_CreateDevice + DirectFB_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; static const DirectFBSurfaceDrawingFlagsNames(drawing_flags); @@ -118,7 +119,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void) /* !!! FIXME: implement SetWindowBordered */ -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL device->GL_LoadLibrary = DirectFB_GL_LoadLibrary; device->GL_GetProcAddress = DirectFB_GL_GetProcAddress; device->GL_MakeCurrent = DirectFB_GL_MakeCurrent; @@ -136,7 +137,7 @@ static SDL_VideoDevice *DirectFB_CreateDevice(void) device->shape_driver.SetWindowShape = DirectFB_SetWindowShape; device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = DirectFB_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = DirectFB_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = DirectFB_Vulkan_GetInstanceExtensions; @@ -262,7 +263,7 @@ static int DirectFB_VideoInit(_THIS) DirectFB_InitModes(_this); -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL DirectFB_GL_Initialize(_this); #endif @@ -290,7 +291,7 @@ static void DirectFB_VideoQuit(_THIS) SDL_DFB_RELEASE(devdata->events); SDL_DFB_RELEASE(devdata->dfb); -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL DirectFB_GL_Shutdown(_this); #endif diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_video.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_video.h index 8cd2a59260..958caefe68 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_video.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.c index c29ec8be96..5dcd0219c4 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_DIRECTFB +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_DIRECTFB) #include "SDL_DirectFB_window.h" diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.h index 4612c0d070..de042130b5 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_vulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_DIRECTFB +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_DIRECTFB) int DirectFB_Vulkan_LoadLibrary(_THIS, const char *path); void DirectFB_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_window.c b/vs/sdl2/src/video/directfb/SDL_DirectFB_window.c index 91be03b236..fb9ce7b0b3 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_window.c +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +20,14 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DIRECTFB +#ifdef SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_modes.h" #include "SDL_DirectFB_window.h" #include "SDL_DirectFB_shape.h" -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL #include "SDL_DirectFB_opengl.h" #endif @@ -402,7 +402,7 @@ void DirectFB_DestroyWindow(_THIS, SDL_Window * window) SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin)); SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin)); -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL DirectFB_GL_DestroyWindowContexts(_this, window); #endif @@ -495,7 +495,7 @@ void DirectFB_AdjustWindowSurface(SDL_Window * window) } if (adjust) { -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window); #endif @@ -524,7 +524,7 @@ void DirectFB_AdjustWindowSurface(SDL_Window * window) #endif DirectFB_WM_RedrawLayout(SDL_GetVideoDevice(), window); -#if SDL_DIRECTFB_OPENGL +#ifdef SDL_DIRECTFB_OPENGL DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window); #endif } diff --git a/vs/sdl2/src/video/directfb/SDL_DirectFB_window.h b/vs/sdl2/src/video/directfb/SDL_DirectFB_window.h index 5d862fabaf..f736e1e30c 100644 --- a/vs/sdl2/src/video/directfb/SDL_DirectFB_window.h +++ b/vs/sdl2/src/video/directfb/SDL_DirectFB_window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/dummy/SDL_nullevents.c b/vs/sdl2/src/video/dummy/SDL_nullevents.c index 10712a81a8..bbe02e0cbf 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullevents.c +++ b/vs/sdl2/src/video/dummy/SDL_nullevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DUMMY +#ifdef SDL_VIDEO_DRIVER_DUMMY /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ diff --git a/vs/sdl2/src/video/dummy/SDL_nullevents_c.h b/vs/sdl2/src/video/dummy/SDL_nullevents_c.h index d6a11a595f..14021c50f6 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullevents_c.h +++ b/vs/sdl2/src/video/dummy/SDL_nullevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/dummy/SDL_nullframebuffer.c b/vs/sdl2/src/video/dummy/SDL_nullframebuffer.c index be10dd15ce..22a9d278ab 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullframebuffer.c +++ b/vs/sdl2/src/video/dummy/SDL_nullframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DUMMY +#ifdef SDL_VIDEO_DRIVER_DUMMY #include "../SDL_sysvideo.h" #include "SDL_nullframebuffer_c.h" @@ -39,7 +39,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -57,7 +57,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find dummy surface for window"); } diff --git a/vs/sdl2/src/video/dummy/SDL_nullframebuffer_c.h b/vs/sdl2/src/video/dummy/SDL_nullframebuffer_c.h index 31a9432b05..dea414e07c 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullframebuffer_c.h +++ b/vs/sdl2/src/video/dummy/SDL_nullframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/dummy/SDL_nullvideo.c b/vs/sdl2/src/video/dummy/SDL_nullvideo.c index 109066d359..930e989121 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullvideo.c +++ b/vs/sdl2/src/video/dummy/SDL_nullvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_DUMMY +#ifdef SDL_VIDEO_DRIVER_DUMMY /* Dummy SDL video driver implementation; this is just enough to make an * SDL-based application THINK it's got a working video driver, for @@ -53,10 +53,9 @@ /* Initialization/Query functions */ static int DUMMY_VideoInit(_THIS); -static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode); static void DUMMY_VideoQuit(_THIS); -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV static int evdev = 0; static void DUMMY_EVDEV_Poll(_THIS); #endif @@ -70,7 +69,7 @@ static int DUMMY_Available(void) if (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0) { return 1; } -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV if (SDL_strcmp(envr, DUMMYVID_DRIVER_EVDEV_NAME) == 0) { evdev = 1; return 1; @@ -95,7 +94,7 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -104,9 +103,8 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void) /* Set the function pointers */ device->VideoInit = DUMMY_VideoInit; device->VideoQuit = DUMMY_VideoQuit; - device->SetDisplayMode = DUMMY_SetDisplayMode; device->PumpEvents = DUMMY_PumpEvents; -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV if (evdev) { device->PumpEvents = DUMMY_EVDEV_Poll; } @@ -122,13 +120,15 @@ static SDL_VideoDevice *DUMMY_CreateDevice(void) VideoBootStrap DUMMY_bootstrap = { DUMMYVID_DRIVER_NAME, "SDL dummy video driver", - DUMMY_CreateDevice + DUMMY_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV VideoBootStrap DUMMY_evdev_bootstrap = { DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev", - DUMMY_CreateDevice + DUMMY_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; void SDL_EVDEV_Init(void); void SDL_EVDEV_Poll(); @@ -149,7 +149,7 @@ int DUMMY_VideoInit(_THIS) mode.format = SDL_PIXELFORMAT_RGB888; mode.w = 1024; mode.h = 768; - mode.refresh_rate = 0; + mode.refresh_rate = 60; mode.driverdata = NULL; if (SDL_AddBasicVideoDisplay(&mode) < 0) { return -1; @@ -157,7 +157,7 @@ int DUMMY_VideoInit(_THIS) SDL_AddDisplayMode(&_this->displays[0], &mode); -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Init(); #endif @@ -165,14 +165,9 @@ int DUMMY_VideoInit(_THIS) return 0; } -static int DUMMY_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) -{ - return 0; -} - void DUMMY_VideoQuit(_THIS) { -#if SDL_INPUT_LINUXEV +#ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Quit(); #endif } diff --git a/vs/sdl2/src/video/dummy/SDL_nullvideo.h b/vs/sdl2/src/video/dummy/SDL_nullvideo.h index 0b52f9da9a..84a18a9b25 100644 --- a/vs/sdl2/src/video/dummy/SDL_nullvideo.h +++ b/vs/sdl2/src/video/dummy/SDL_nullvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.c b/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.c index e08d06b80c..2017a6aee2 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.c +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_EMSCRIPTEN +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN #include #include @@ -964,7 +964,7 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data) /* Keyboard events are awkward */ keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (keyElement == NULL) { + if (!keyElement) { keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW; } @@ -1007,7 +1007,7 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (target == NULL) { + if (!target) { target = EMSCRIPTEN_EVENT_TARGET_WINDOW; } diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.h b/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.h index b6c4da009f..502236adef 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.h +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.c b/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.c index 6226198607..6a0e78fd43 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_EMSCRIPTEN +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN #include "SDL_emscriptenvideo.h" #include "SDL_emscriptenframebuffer.h" @@ -46,7 +46,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { return -1; } @@ -64,7 +64,7 @@ int Emscripten_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_WindowData *data = (SDL_WindowData *)window->driverdata; surface = data->surface; - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find framebuffer surface for window"); } diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.h b/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.h index f23e3acd85..fdf1c35ecc 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.h +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.c b/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.c index 822995c4b9..d189e5393c 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.c +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_EMSCRIPTEN +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN #include #include @@ -31,6 +31,15 @@ #include "../../events/SDL_mouse_c.h" +/* older Emscriptens don't have this, but we need to for wasm64 compatibility. */ +#ifndef MAIN_THREAD_EM_ASM_PTR + #ifdef __wasm64__ + #error You need to upgrade your Emscripten compiler to support wasm64 + #else + #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT + #endif +#endif + static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL_bool is_custom) { SDL_Cursor *cursor; @@ -39,7 +48,7 @@ static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL cursor = SDL_calloc(1, sizeof(SDL_Cursor)); if (cursor) { curdata = (Emscripten_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -60,6 +69,8 @@ static SDL_Cursor *Emscripten_CreateDefaultCursor() return Emscripten_CreateCursorFromString("default", SDL_FALSE); } +EM_JS_DEPS(sdlmouse, "$stringToUTF8,$UTF8ToString"); + static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) { const char *cursor_url = NULL; @@ -67,12 +78,12 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888, 0); - if (conv_surf == NULL) { + if (!conv_surf) { return NULL; } /* *INDENT-OFF* */ /* clang-format off */ - cursor_url = (const char *)MAIN_THREAD_EM_ASM_INT({ + cursor_url = (const char *)MAIN_THREAD_EM_ASM_PTR({ var w = $0; var h = $1; var hot_x = $2; @@ -130,49 +141,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int static SDL_Cursor *Emscripten_CreateSystemCursor(SDL_SystemCursor id) { - const char *cursor_name = NULL; - - switch (id) { - case SDL_SYSTEM_CURSOR_ARROW: - cursor_name = "default"; - break; - case SDL_SYSTEM_CURSOR_IBEAM: - cursor_name = "text"; - break; - case SDL_SYSTEM_CURSOR_WAIT: - cursor_name = "wait"; - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - cursor_name = "crosshair"; - break; - case SDL_SYSTEM_CURSOR_WAITARROW: - cursor_name = "progress"; - break; - case SDL_SYSTEM_CURSOR_SIZENWSE: - cursor_name = "nwse-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZENESW: - cursor_name = "nesw-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZEWE: - cursor_name = "ew-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZENS: - cursor_name = "ns-resize"; - break; - case SDL_SYSTEM_CURSOR_SIZEALL: - cursor_name = "move"; - break; - case SDL_SYSTEM_CURSOR_NO: - cursor_name = "not-allowed"; - break; - case SDL_SYSTEM_CURSOR_HAND: - cursor_name = "pointer"; - break; - default: - SDL_assert(0); - return NULL; - } + const char *cursor_name = SDL_GetCSSCursorName(id, NULL); return Emscripten_CreateCursorFromString(cursor_name, SDL_FALSE); } @@ -183,7 +152,7 @@ static void Emscripten_FreeCursor(SDL_Cursor *cursor) if (cursor) { curdata = (Emscripten_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->is_custom) { SDL_free((char *)curdata->system_cursor); } @@ -236,7 +205,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) /* TODO: pointer lock isn't actually enabled yet */ if (enabled) { window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return -1; } diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.h b/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.h index 8b0f65695e..10cd24e3b3 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.h +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.c b/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.c index aea127f029..baf9eb7ea5 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.c +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) && defined(SDL_VIDEO_OPENGL_EGL) #include #include diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.h b/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.h index 869982df10..184d0f2a4b 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.h +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_emscriptenopengles_h_ #define SDL_emscriptenopengles_h_ -#if SDL_VIDEO_DRIVER_EMSCRIPTEN && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) && defined(SDL_VIDEO_OPENGL_EGL) #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.c b/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.c index 8ddf910103..6319f92714 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.c +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_EMSCRIPTEN +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN #include "SDL_video.h" #include "SDL_mouse.h" @@ -66,7 +66,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -106,7 +106,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) device->UpdateWindowFramebuffer = Emscripten_UpdateWindowFramebuffer; device->DestroyWindowFramebuffer = Emscripten_DestroyWindowFramebuffer; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = Emscripten_GLES_LoadLibrary; device->GL_GetProcAddress = Emscripten_GLES_GetProcAddress; device->GL_UnloadLibrary = Emscripten_GLES_UnloadLibrary; @@ -125,7 +125,8 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) VideoBootStrap Emscripten_bootstrap = { EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver", - Emscripten_CreateDevice + Emscripten_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; int Emscripten_VideoInit(_THIS) @@ -209,7 +210,7 @@ static int Emscripten_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -247,7 +248,7 @@ static int Emscripten_CreateWindow(_THIS, SDL_Window *window) } } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { if (!_this->egl_data) { if (SDL_GL_LoadLibrary(NULL) < 0) { @@ -314,7 +315,7 @@ static void Emscripten_DestroyWindow(_THIS, SDL_Window *window) data = (SDL_WindowData *)window->driverdata; Emscripten_UnregisterEventHandlers(data); -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); data->egl_surface = EGL_NO_SURFACE; @@ -341,6 +342,7 @@ static void Emscripten_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoD SDL_bool is_desktop_fullscreen = (window->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP; int res; + SDL_zero(strategy); strategy.scaleMode = is_desktop_fullscreen ? EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH : EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT; if (!is_desktop_fullscreen) { diff --git a/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.h b/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.h index dd97dcfbb5..2cbb6716c8 100644 --- a/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.h +++ b/vs/sdl2/src/video/emscripten/SDL_emscriptenvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +28,13 @@ #include #include -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include #endif typedef struct SDL_WindowData { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif SDL_Window *window; diff --git a/vs/sdl2/src/video/haiku/SDL_BApp.h b/vs/sdl2/src/video/haiku/SDL_BApp.h index 0368081677..284445d986 100644 --- a/vs/sdl2/src/video/haiku/SDL_BApp.h +++ b/vs/sdl2/src/video/haiku/SDL_BApp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ #include #include #include -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL #include #endif @@ -85,7 +85,7 @@ class SDL_BLooper : public BLooper public: SDL_BLooper(const char* name) : BLooper(name) { -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL _current_context = NULL; #endif } @@ -199,7 +199,7 @@ class SDL_BLooper : public BLooper return _window_map[winID]; } -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *GetCurrentContext() { return _current_context; @@ -419,7 +419,7 @@ class SDL_BLooper : public BLooper /* Members */ std::vector _window_map; /* Keeps track of SDL_Windows by index-id */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *_current_context; #endif }; diff --git a/vs/sdl2/src/video/haiku/SDL_BWin.h b/vs/sdl2/src/video/haiku/SDL_BWin.h index ed1b961471..f1ad1ea2ff 100644 --- a/vs/sdl2/src/video/haiku/SDL_BWin.h +++ b/vs/sdl2/src/video/haiku/SDL_BWin.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ extern "C" { #include #include #include -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL #include #endif #include "SDL_events.h" @@ -99,7 +99,7 @@ class SDL_BWin : public BWindow _cur_view = NULL; _SDL_View = NULL; -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL _SDL_GLView = NULL; _gl_type = 0; #endif @@ -123,7 +123,7 @@ class SDL_BWin : public BWindow _SDL_View = NULL; } -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL if (_SDL_GLView) { if (SDL_Looper->GetCurrentContext() == _SDL_GLView) SDL_Looper->SetCurrentContext(NULL); @@ -189,7 +189,7 @@ class SDL_BWin : public BWindow } /* * * * * OpenGL functionality * * * * */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *CreateGLView(Uint32 gl_flags) { Lock(); @@ -476,7 +476,7 @@ class SDL_BWin : public BWindow BBitmap *GetBitmap() { return _bitmap; } BView *GetCurView() { return _cur_view; } SDL_BView *GetView() { return _SDL_View; } -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *GetGLView() { return _SDL_GLView; @@ -712,7 +712,7 @@ class SDL_BWin : public BWindow BView *_cur_view; SDL_BView *_SDL_View; -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL BGLView *_SDL_GLView; Uint32 _gl_type; #endif diff --git a/vs/sdl2/src/video/haiku/SDL_bclipboard.cc b/vs/sdl2/src/video/haiku/SDL_bclipboard.cc index 0fd3753217..11e79f3362 100644 --- a/vs/sdl2/src/video/haiku/SDL_bclipboard.cc +++ b/vs/sdl2/src/video/haiku/SDL_bclipboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU /* BWindow based clipboard implementation */ @@ -65,7 +65,7 @@ char *HAIKU_GetClipboardText(_THIS) { be_clipboard->Unlock(); } - if (text == NULL) { + if (!text) { result = SDL_strdup(""); } else { /* Copy the data and pass on to SDL */ diff --git a/vs/sdl2/src/video/haiku/SDL_bclipboard.h b/vs/sdl2/src/video/haiku/SDL_bclipboard.h index 5f34f9f4aa..89e9e90651 100644 --- a/vs/sdl2/src/video/haiku/SDL_bclipboard.h +++ b/vs/sdl2/src/video/haiku/SDL_bclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bevents.cc b/vs/sdl2/src/video/haiku/SDL_bevents.cc index f0b7e2d285..45727a66a8 100644 --- a/vs/sdl2/src/video/haiku/SDL_bevents.cc +++ b/vs/sdl2/src/video/haiku/SDL_bevents.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include "SDL_bevents.h" diff --git a/vs/sdl2/src/video/haiku/SDL_bevents.h b/vs/sdl2/src/video/haiku/SDL_bevents.h index 847bc4a86c..1afd33ad05 100644 --- a/vs/sdl2/src/video/haiku/SDL_bevents.h +++ b/vs/sdl2/src/video/haiku/SDL_bevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bframebuffer.cc b/vs/sdl2/src/video/haiku/SDL_bframebuffer.cc index 2cb4f64976..1961cea3b8 100644 --- a/vs/sdl2/src/video/haiku/SDL_bframebuffer.cc +++ b/vs/sdl2/src/video/haiku/SDL_bframebuffer.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include "SDL_bframebuffer.h" @@ -94,7 +94,7 @@ int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window * window, int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window * window, const SDL_Rect * rects, int numrects) { - if (window == NULL) { + if (!window) { return 0; } diff --git a/vs/sdl2/src/video/haiku/SDL_bframebuffer.h b/vs/sdl2/src/video/haiku/SDL_bframebuffer.h index 72d3aab589..ce3649c164 100644 --- a/vs/sdl2/src/video/haiku/SDL_bframebuffer.h +++ b/vs/sdl2/src/video/haiku/SDL_bframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bkeyboard.cc b/vs/sdl2/src/video/haiku/SDL_bkeyboard.cc index 84ac3c7d1f..b9499edb73 100644 --- a/vs/sdl2/src/video/haiku/SDL_bkeyboard.cc +++ b/vs/sdl2/src/video/haiku/SDL_bkeyboard.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include #include diff --git a/vs/sdl2/src/video/haiku/SDL_bkeyboard.h b/vs/sdl2/src/video/haiku/SDL_bkeyboard.h index f15611e034..46fd9d6b35 100644 --- a/vs/sdl2/src/video/haiku/SDL_bkeyboard.h +++ b/vs/sdl2/src/video/haiku/SDL_bkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bmessagebox.cc b/vs/sdl2/src/video/haiku/SDL_bmessagebox.cc index 60fce00789..d0c43e282c 100644 --- a/vs/sdl2/src/video/haiku/SDL_bmessagebox.cc +++ b/vs/sdl2/src/video/haiku/SDL_bmessagebox.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2018-2019 EXL This software is provided 'as-is', without any express or implied @@ -22,7 +22,7 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include "SDL_messagebox.h" @@ -356,15 +356,15 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid // "You need a valid BApplication object before interacting with the app_server." // "2 BApplication objects were created. Only one is allowed." BApplication *application = NULL; - if (be_app == NULL) { + if (!be_app) { application = new(std::nothrow) BApplication(SDL_signature); - if (application == NULL) { + if (!application) { return SDL_SetError("Cannot create the BApplication object. Lack of memory?"); } } HAIKU_SDL_MessageBox *SDL_MessageBox = new(std::nothrow) HAIKU_SDL_MessageBox(messageboxdata); - if (SDL_MessageBox == NULL) { + if (!SDL_MessageBox) { return SDL_SetError("Cannot create the HAIKU_SDL_MessageBox (BAlert inheritor) object. Lack of memory?"); } const int closeButton = SDL_MessageBox->GetCloseButtonId(); @@ -381,7 +381,7 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid delete messageBox; } */ - if (application != NULL) { + if (application) { delete application; } diff --git a/vs/sdl2/src/video/haiku/SDL_bmessagebox.h b/vs/sdl2/src/video/haiku/SDL_bmessagebox.h index 9c4243f428..822d7c230d 100644 --- a/vs/sdl2/src/video/haiku/SDL_bmessagebox.h +++ b/vs/sdl2/src/video/haiku/SDL_bmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2018-2019 EXL This software is provided 'as-is', without any express or implied @@ -25,7 +25,7 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #ifdef __cplusplus extern "C" { diff --git a/vs/sdl2/src/video/haiku/SDL_bmodes.cc b/vs/sdl2/src/video/haiku/SDL_bmodes.cc index eb8f153126..6a162f614d 100644 --- a/vs/sdl2/src/video/haiku/SDL_bmodes.cc +++ b/vs/sdl2/src/video/haiku/SDL_bmodes.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +20,14 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include #include #include "SDL_bmodes.h" #include "SDL_BWin.h" -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL #include "SDL_bopengl.h" #endif @@ -288,7 +288,7 @@ int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode free(bmode_list); /* This should not be SDL_free() */ -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL /* FIXME: Is there some way to reboot the OpenGL context? This doesn't help */ // HAIKU_GL_RebootContexts(_this); diff --git a/vs/sdl2/src/video/haiku/SDL_bmodes.h b/vs/sdl2/src/video/haiku/SDL_bmodes.h index 6b5f581445..e0d6f04c55 100644 --- a/vs/sdl2/src/video/haiku/SDL_bmodes.h +++ b/vs/sdl2/src/video/haiku/SDL_bmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bopengl.cc b/vs/sdl2/src/video/haiku/SDL_bopengl.cc index 7e12ad6a6e..d34d5923ba 100644 --- a/vs/sdl2/src/video/haiku/SDL_bopengl.cc +++ b/vs/sdl2/src/video/haiku/SDL_bopengl.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL +#if defined(SDL_VIDEO_DRIVER_HAIKU) && defined(SDL_VIDEO_OPENGL) #include "SDL_bopengl.h" @@ -65,7 +65,7 @@ int HAIKU_GL_LoadLibrary(_THIS, const char *path) void *HAIKU_GL_GetProcAddress(_THIS, const char *proc) { - if (_this->gl_config.dll_handle != NULL) { + if (_this->gl_config.dll_handle) { void *location = NULL; status_t err; if ((err = @@ -92,8 +92,8 @@ int HAIKU_GL_SwapWindow(_THIS, SDL_Window * window) { int HAIKU_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { BGLView* glView = (BGLView*)context; // printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL)); - if (glView != NULL) { - if ((glView->Window() == NULL) || (window == NULL) || (_ToBeWin(window)->GetGLView() != glView)) { + if (glView) { + if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) { return SDL_SetError("MakeCurrent failed"); } } @@ -146,7 +146,7 @@ void HAIKU_GL_DeleteContext(_THIS, SDL_GLContext context) { // printf("HAIKU_GL_DeleteContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL)); BGLView* glView = (BGLView*)context; SDL_BWin *bwin = (SDL_BWin*)glView->Window(); - if (bwin == NULL) { + if (!bwin) { delete glView; } else { bwin->RemoveGLView(); diff --git a/vs/sdl2/src/video/haiku/SDL_bopengl.h b/vs/sdl2/src/video/haiku/SDL_bopengl.h index 0085a1e5b9..0905b7c962 100644 --- a/vs/sdl2/src/video/haiku/SDL_bopengl.h +++ b/vs/sdl2/src/video/haiku/SDL_bopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #ifndef SDL_BOPENGL_H #define SDL_BOPENGL_H -#if SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL +#if defined(SDL_VIDEO_DRIVER_HAIKU) && defined(SDL_VIDEO_OPENGL) #ifdef __cplusplus extern "C" { diff --git a/vs/sdl2/src/video/haiku/SDL_bvideo.cc b/vs/sdl2/src/video/haiku/SDL_bvideo.cc index 0f23c4d7bd..aac091afc7 100644 --- a/vs/sdl2/src/video/haiku/SDL_bvideo.cc +++ b/vs/sdl2/src/video/haiku/SDL_bvideo.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "../../SDL_internal.h" #include "../../main/haiku/SDL_BApp.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include "SDL_BWin.h" #include @@ -39,6 +39,7 @@ extern "C" { #include "SDL_bmodes.h" #include "SDL_bframebuffer.h" #include "SDL_bevents.h" +#include "SDL_bmessagebox.h" static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { return (SDL_BWin *)(window->driverdata); @@ -104,7 +105,7 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void) device->shape_driver.SetWindowShape = NULL; device->shape_driver.ResizeWindowShape = NULL; -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL device->GL_LoadLibrary = HAIKU_GL_LoadLibrary; device->GL_GetProcAddress = HAIKU_GL_GetProcAddress; device->GL_UnloadLibrary = HAIKU_GL_UnloadLibrary; @@ -131,7 +132,8 @@ static SDL_VideoDevice * HAIKU_CreateDevice(void) VideoBootStrap HAIKU_bootstrap = { "haiku", "Haiku graphics", - HAIKU_CreateDevice + HAIKU_CreateDevice, + HAIKU_ShowMessageBox }; void HAIKU_DeleteDevice(SDL_VideoDevice * device) @@ -193,7 +195,7 @@ static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } @@ -215,7 +217,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return 0; } @@ -234,7 +236,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) { SDL_Window *window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return 0; } @@ -254,7 +256,7 @@ static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) static void HAIKU_MouseInit(_THIS) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return; } mouse->CreateCursor = HAIKU_CreateCursor; @@ -281,7 +283,7 @@ int HAIKU_VideoInit(_THIS) HAIKU_MouseInit(_this); -#if SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL /* testgl application doesn't load library, just tries to load symbols */ /* is it correct? if so we have to load library here */ HAIKU_GL_LoadLibrary(_this, NULL); diff --git a/vs/sdl2/src/video/haiku/SDL_bvideo.h b/vs/sdl2/src/video/haiku/SDL_bvideo.h index 0c5288f1bd..6c420480cb 100644 --- a/vs/sdl2/src/video/haiku/SDL_bvideo.h +++ b/vs/sdl2/src/video/haiku/SDL_bvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/haiku/SDL_bwindow.cc b/vs/sdl2/src/video/haiku/SDL_bwindow.cc index 18e03d4ae8..38863abfc1 100644 --- a/vs/sdl2/src/video/haiku/SDL_bwindow.cc +++ b/vs/sdl2/src/video/haiku/SDL_bwindow.cc @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_HAIKU +#ifdef SDL_VIDEO_DRIVER_HAIKU #include "../SDL_sysvideo.h" #include "SDL_BWin.h" @@ -67,7 +67,7 @@ static int _InitWindow(_THIS, SDL_Window *window) { } SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags); - if (bwin == NULL) { + if (!bwin) { return -1; } diff --git a/vs/sdl2/src/video/haiku/SDL_bwindow.h b/vs/sdl2/src/video/haiku/SDL_bwindow.h index 1f82266c7c..cf0bdfda1c 100644 --- a/vs/sdl2/src/video/haiku/SDL_bwindow.h +++ b/vs/sdl2/src/video/haiku/SDL_bwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/khronos/EGL/egl.h b/vs/sdl2/src/video/khronos/EGL/egl.h index 97d0878cc7..c58f552bf5 100644 --- a/vs/sdl2/src/video/khronos/EGL/egl.h +++ b/vs/sdl2/src/video/khronos/EGL/egl.h @@ -14,7 +14,7 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** -** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ +** Khronos $Git commit SHA1: f4cc936b88 $ on $Git commit date: 2023-12-16 01:21:49 -0500 $ */ #include @@ -23,7 +23,7 @@ extern "C" { #define EGL_EGL_PROTOTYPES 1 #endif -/* Generated on date 20220525 */ +/* Generated on date 20231215 */ /* Generated C header for: * API: egl diff --git a/vs/sdl2/src/video/khronos/EGL/eglext.h b/vs/sdl2/src/video/khronos/EGL/eglext.h index d58da70e6b..9932ebeec5 100644 --- a/vs/sdl2/src/video/khronos/EGL/eglext.h +++ b/vs/sdl2/src/video/khronos/EGL/eglext.h @@ -14,12 +14,12 @@ extern "C" { ** used to make the header, and the header can be found at ** http://www.khronos.org/registry/egl ** -** Khronos $Git commit SHA1: 6fb1daea15 $ on $Git commit date: 2022-05-25 09:41:13 -0600 $ +** Khronos $Git commit SHA1: f4cc936b88 $ on $Git commit date: 2023-12-16 01:21:49 -0500 $ */ #include -#define EGL_EGLEXT_VERSION 20220525 +#define EGL_EGLEXT_VERSION 20231215 /* Generated C header for: * API: egl @@ -727,6 +727,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceBinaryEXT (EGLDeviceEXT device, EGLi #define EGL_EXT_explicit_device 1 #endif /* EGL_EXT_explicit_device */ +#ifndef EGL_EXT_gl_colorspace_bt2020_hlg +#define EGL_EXT_gl_colorspace_bt2020_hlg 1 +#define EGL_GL_COLORSPACE_BT2020_HLG_EXT 0x3540 +#endif /* EGL_EXT_gl_colorspace_bt2020_hlg */ + #ifndef EGL_EXT_gl_colorspace_bt2020_linear #define EGL_EXT_gl_colorspace_bt2020_linear 1 #define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F @@ -923,6 +928,10 @@ EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, #define EGL_EXT_protected_surface 1 #endif /* EGL_EXT_protected_surface */ +#ifndef EGL_EXT_query_reset_notification_strategy +#define EGL_EXT_query_reset_notification_strategy 1 +#endif /* EGL_EXT_query_reset_notification_strategy */ + #ifndef EGL_EXT_stream_consumer_egloutput #define EGL_EXT_stream_consumer_egloutput 1 typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); @@ -1223,6 +1232,11 @@ EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStream #endif #endif /* EGL_NV_stream_consumer_eglimage */ +#ifndef EGL_NV_stream_consumer_eglimage_use_scanout_attrib +#define EGL_NV_stream_consumer_eglimage_use_scanout_attrib 1 +#define EGL_STREAM_CONSUMER_IMAGE_USE_SCANOUT_NV 0x3378 +#endif /* EGL_NV_stream_consumer_eglimage_use_scanout_attrib */ + #ifndef EGL_NV_stream_consumer_gltexture_yuv #define EGL_NV_stream_consumer_gltexture_yuv 1 #define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C @@ -1432,6 +1446,16 @@ EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); #define EGL_TRIPLE_BUFFER_NV 0x3230 #endif /* EGL_NV_triple_buffer */ +#ifndef EGL_QNX_image_native_buffer +#define EGL_QNX_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_QNX 0x3551 +#endif /* EGL_QNX_image_native_buffer */ + +#ifndef EGL_QNX_platform_screen +#define EGL_QNX_platform_screen 1 +#define EGL_PLATFORM_SCREEN_QNX 0x3550 +#endif /* EGL_QNX_platform_screen */ + #ifndef EGL_TIZEN_image_native_buffer #define EGL_TIZEN_image_native_buffer 1 #define EGL_NATIVE_BUFFER_TIZEN 0x32A0 diff --git a/vs/sdl2/src/video/khronos/EGL/eglplatform.h b/vs/sdl2/src/video/khronos/EGL/eglplatform.h index 99362a23de..6786afd90b 100644 --- a/vs/sdl2/src/video/khronos/EGL/eglplatform.h +++ b/vs/sdl2/src/video/khronos/EGL/eglplatform.h @@ -64,6 +64,12 @@ typedef HDC EGLNativeDisplayType; typedef HBITMAP EGLNativePixmapType; typedef HWND EGLNativeWindowType; +#elif defined(__QNX__) + +typedef khronos_uintptr_t EGLNativeDisplayType; +typedef struct _screen_pixmap* EGLNativePixmapType; /* screen_pixmap_t */ +typedef struct _screen_window* EGLNativeWindowType; /* screen_window_t */ + #elif defined(__EMSCRIPTEN__) typedef int EGLNativeDisplayType; diff --git a/vs/sdl2/src/video/khronos/GLES2/gl2.h b/vs/sdl2/src/video/khronos/GLES2/gl2.h index af244a70c1..6be4e3637b 100644 --- a/vs/sdl2/src/video/khronos/GLES2/gl2.h +++ b/vs/sdl2/src/video/khronos/GLES2/gl2.h @@ -25,7 +25,7 @@ extern "C" { #define GL_GLES_PROTOTYPES 1 #endif -/* Generated on date 20220530 */ +/* Generated on date 20231129 */ /* Generated C header for: * API: gles2 diff --git a/vs/sdl2/src/video/khronos/GLES2/gl2ext.h b/vs/sdl2/src/video/khronos/GLES2/gl2ext.h index 9448ce09fc..63b530b4b7 100644 --- a/vs/sdl2/src/video/khronos/GLES2/gl2ext.h +++ b/vs/sdl2/src/video/khronos/GLES2/gl2ext.h @@ -19,7 +19,7 @@ extern "C" { #define GL_APIENTRYP GL_APIENTRY* #endif -/* Generated on date 20220530 */ +/* Generated on date 20231129 */ /* Generated C header for: * API: gles2 @@ -1052,6 +1052,21 @@ GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei #define GL_ARM_rgba8 1 #endif /* GL_ARM_rgba8 */ +#ifndef GL_ARM_shader_core_properties +#define GL_ARM_shader_core_properties 1 +#define GL_SHADER_CORE_COUNT_ARM 0x96F0 +#define GL_SHADER_CORE_ACTIVE_COUNT_ARM 0x96F1 +#define GL_SHADER_CORE_PRESENT_MASK_ARM 0x96F2 +#define GL_SHADER_CORE_MAX_WARP_COUNT_ARM 0x96F3 +#define GL_SHADER_CORE_PIXEL_RATE_ARM 0x96F4 +#define GL_SHADER_CORE_TEXEL_RATE_ARM 0x96F5 +#define GL_SHADER_CORE_FMA_RATE_ARM 0x96F6 +typedef void (GL_APIENTRYP PFNGLMAXACTIVESHADERCORESARMPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxActiveShaderCoresARM (GLuint count); +#endif +#endif /* GL_ARM_shader_core_properties */ + #ifndef GL_ARM_shader_framebuffer_fetch #define GL_ARM_shader_framebuffer_fetch 1 #define GL_FETCH_PER_SAMPLE_ARM 0x8F65 @@ -1459,6 +1474,16 @@ GL_APICALL void GL_APIENTRY glFramebufferShadingRateEXT (GLenum target, GLenum a #endif #endif /* GL_EXT_fragment_shading_rate */ +#ifndef GL_EXT_framebuffer_blit_layers +#define GL_EXT_framebuffer_blit_layers 1 +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERLAYERSEXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERLAYEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferLayersEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glBlitFramebufferLayerEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit_layers */ + #ifndef GL_EXT_geometry_point_size #define GL_EXT_geometry_point_size 1 #endif /* GL_EXT_geometry_point_size */ @@ -1856,7 +1881,7 @@ GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLe #define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); -typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar **strings); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar *const*strings); typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); @@ -1901,7 +1926,7 @@ typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint progra #ifdef GL_GLEXT_PROTOTYPES GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); -GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar **strings); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar *const*strings); GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); @@ -2553,6 +2578,33 @@ GL_APICALL void GL_APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLen #define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F #endif /* GL_MESA_program_binary_formats */ +#ifndef GL_MESA_sampler_objects +#define GL_MESA_sampler_objects 1 +#define GL_SAMPLER_BINDING 0x8919 +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +#endif +#endif /* GL_MESA_sampler_objects */ + #ifndef GL_MESA_shader_integer_functions #define GL_MESA_shader_integer_functions 1 #endif /* GL_MESA_shader_integer_functions */ @@ -3186,6 +3238,13 @@ GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei coun #endif #endif /* GL_NV_non_square_matrices */ +#ifndef GL_NV_pack_subimage +#define GL_NV_pack_subimage 1 +#define GL_PACK_ROW_LENGTH_NV 0x0D02 +#define GL_PACK_SKIP_ROWS_NV 0x0D03 +#define GL_PACK_SKIP_PIXELS_NV 0x0D04 +#endif /* GL_NV_pack_subimage */ + #ifndef GL_NV_path_rendering #define GL_NV_path_rendering 1 typedef double GLdouble; @@ -3917,6 +3976,10 @@ GL_APICALL void GL_APIENTRY glTexEstimateMotionRegionsQCOM (GLuint ref, GLuint t #define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 #endif /* GL_QCOM_perfmon_global_mode */ +#ifndef GL_QCOM_render_sRGB_R8_RG8 +#define GL_QCOM_render_sRGB_R8_RG8 1 +#endif /* GL_QCOM_render_sRGB_R8_RG8 */ + #ifndef GL_QCOM_render_shared_exponent #define GL_QCOM_render_shared_exponent 1 #endif /* GL_QCOM_render_shared_exponent */ @@ -3974,6 +4037,11 @@ GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GL #define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 #endif /* GL_QCOM_texture_foveated_subsampled_layout */ +#ifndef GL_QCOM_texture_lod_bias +#define GL_QCOM_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_QCOM 0x8C96 +#endif /* GL_QCOM_texture_lod_bias */ + #ifndef GL_QCOM_tiled_rendering #define GL_QCOM_tiled_rendering 1 #define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std.h new file mode 100644 index 0000000000..6d27af37b7 --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std.h @@ -0,0 +1,312 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_H_ +#define VULKAN_VIDEO_CODEC_H264STD_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std 1 +#include "vulkan_video_codecs_common.h" +#define STD_VIDEO_H264_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H264_MAX_NUM_LIST_REF 32 +#define STD_VIDEO_H264_MAX_CHROMA_PLANES 2 +#define STD_VIDEO_H264_NO_REFERENCE_PICTURE 0xFF + +typedef enum StdVideoH264ChromaFormatIdc { + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ChromaFormatIdc; + +typedef enum StdVideoH264ProfileIdc { + STD_VIDEO_H264_PROFILE_IDC_BASELINE = 66, + STD_VIDEO_H264_PROFILE_IDC_MAIN = 77, + STD_VIDEO_H264_PROFILE_IDC_HIGH = 100, + STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE = 244, + STD_VIDEO_H264_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ProfileIdc; + +typedef enum StdVideoH264LevelIdc { + STD_VIDEO_H264_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H264_LEVEL_IDC_1_1 = 1, + STD_VIDEO_H264_LEVEL_IDC_1_2 = 2, + STD_VIDEO_H264_LEVEL_IDC_1_3 = 3, + STD_VIDEO_H264_LEVEL_IDC_2_0 = 4, + STD_VIDEO_H264_LEVEL_IDC_2_1 = 5, + STD_VIDEO_H264_LEVEL_IDC_2_2 = 6, + STD_VIDEO_H264_LEVEL_IDC_3_0 = 7, + STD_VIDEO_H264_LEVEL_IDC_3_1 = 8, + STD_VIDEO_H264_LEVEL_IDC_3_2 = 9, + STD_VIDEO_H264_LEVEL_IDC_4_0 = 10, + STD_VIDEO_H264_LEVEL_IDC_4_1 = 11, + STD_VIDEO_H264_LEVEL_IDC_4_2 = 12, + STD_VIDEO_H264_LEVEL_IDC_5_0 = 13, + STD_VIDEO_H264_LEVEL_IDC_5_1 = 14, + STD_VIDEO_H264_LEVEL_IDC_5_2 = 15, + STD_VIDEO_H264_LEVEL_IDC_6_0 = 16, + STD_VIDEO_H264_LEVEL_IDC_6_1 = 17, + STD_VIDEO_H264_LEVEL_IDC_6_2 = 18, + STD_VIDEO_H264_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264LevelIdc; + +typedef enum StdVideoH264PocType { + STD_VIDEO_H264_POC_TYPE_0 = 0, + STD_VIDEO_H264_POC_TYPE_1 = 1, + STD_VIDEO_H264_POC_TYPE_2 = 2, + STD_VIDEO_H264_POC_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_POC_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PocType; + +typedef enum StdVideoH264AspectRatioIdc { + STD_VIDEO_H264_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H264_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H264_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H264_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H264_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H264_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H264_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H264_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H264_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H264_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H264_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H264_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H264_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H264_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H264_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H264_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H264_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H264_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H264_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264AspectRatioIdc; + +typedef enum StdVideoH264WeightedBipredIdc { + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_DEFAULT = 0, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_EXPLICIT = 1, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_IMPLICIT = 2, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264WeightedBipredIdc; + +typedef enum StdVideoH264ModificationOfPicNumsIdc { + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_SUBTRACT = 0, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_ADD = 1, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_LONG_TERM = 2, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_END = 3, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ModificationOfPicNumsIdc; + +typedef enum StdVideoH264MemMgmtControlOp { + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_END = 0, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_SHORT_TERM = 1, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_LONG_TERM = 2, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_LONG_TERM = 3, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_SET_MAX_LONG_TERM_INDEX = 4, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_ALL = 5, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_CURRENT_AS_LONG_TERM = 6, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264MemMgmtControlOp; + +typedef enum StdVideoH264CabacInitIdc { + STD_VIDEO_H264_CABAC_INIT_IDC_0 = 0, + STD_VIDEO_H264_CABAC_INIT_IDC_1 = 1, + STD_VIDEO_H264_CABAC_INIT_IDC_2 = 2, + STD_VIDEO_H264_CABAC_INIT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CABAC_INIT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264CabacInitIdc; + +typedef enum StdVideoH264DisableDeblockingFilterIdc { + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_DISABLED = 0, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_ENABLED = 1, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_PARTIAL = 2, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264DisableDeblockingFilterIdc; + +typedef enum StdVideoH264SliceType { + STD_VIDEO_H264_SLICE_TYPE_P = 0, + STD_VIDEO_H264_SLICE_TYPE_B = 1, + STD_VIDEO_H264_SLICE_TYPE_I = 2, + STD_VIDEO_H264_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264SliceType; + +typedef enum StdVideoH264PictureType { + STD_VIDEO_H264_PICTURE_TYPE_P = 0, + STD_VIDEO_H264_PICTURE_TYPE_B = 1, + STD_VIDEO_H264_PICTURE_TYPE_I = 2, + STD_VIDEO_H264_PICTURE_TYPE_IDR = 5, + STD_VIDEO_H264_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PictureType; + +typedef enum StdVideoH264NonVclNaluType { + STD_VIDEO_H264_NON_VCL_NALU_TYPE_SPS = 0, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PPS = 1, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_AUD = 2, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PREFIX = 3, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_SEQUENCE = 4, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_STREAM = 5, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PRECODED = 6, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264NonVclNaluType; +typedef struct StdVideoH264SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t color_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t timing_info_present_flag : 1; + uint32_t fixed_frame_rate_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; +} StdVideoH264SpsVuiFlags; + +typedef struct StdVideoH264HrdParameters { + uint8_t cpb_cnt_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t reserved1; + uint32_t bit_rate_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint8_t cbr_flag[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t initial_cpb_removal_delay_length_minus1; + uint32_t cpb_removal_delay_length_minus1; + uint32_t dpb_output_delay_length_minus1; + uint32_t time_offset_length; +} StdVideoH264HrdParameters; + +typedef struct StdVideoH264SequenceParameterSetVui { + StdVideoH264SpsVuiFlags flags; + StdVideoH264AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coefficients; + uint32_t num_units_in_tick; + uint32_t time_scale; + uint8_t max_num_reorder_frames; + uint8_t max_dec_frame_buffering; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint32_t reserved1; + const StdVideoH264HrdParameters* pHrdParameters; +} StdVideoH264SequenceParameterSetVui; + +typedef struct StdVideoH264SpsFlags { + uint32_t constraint_set0_flag : 1; + uint32_t constraint_set1_flag : 1; + uint32_t constraint_set2_flag : 1; + uint32_t constraint_set3_flag : 1; + uint32_t constraint_set4_flag : 1; + uint32_t constraint_set5_flag : 1; + uint32_t direct_8x8_inference_flag : 1; + uint32_t mb_adaptive_frame_field_flag : 1; + uint32_t frame_mbs_only_flag : 1; + uint32_t delta_pic_order_always_zero_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t gaps_in_frame_num_value_allowed_flag : 1; + uint32_t qpprime_y_zero_transform_bypass_flag : 1; + uint32_t frame_cropping_flag : 1; + uint32_t seq_scaling_matrix_present_flag : 1; + uint32_t vui_parameters_present_flag : 1; +} StdVideoH264SpsFlags; + +typedef struct StdVideoH264ScalingLists { + uint16_t scaling_list_present_mask; + uint16_t use_default_scaling_matrix_mask; + uint8_t ScalingList4x4[STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS]; +} StdVideoH264ScalingLists; + +typedef struct StdVideoH264SequenceParameterSet { + StdVideoH264SpsFlags flags; + StdVideoH264ProfileIdc profile_idc; + StdVideoH264LevelIdc level_idc; + StdVideoH264ChromaFormatIdc chroma_format_idc; + uint8_t seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_frame_num_minus4; + StdVideoH264PocType pic_order_cnt_type; + int32_t offset_for_non_ref_pic; + int32_t offset_for_top_to_bottom_field; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t num_ref_frames_in_pic_order_cnt_cycle; + uint8_t max_num_ref_frames; + uint8_t reserved1; + uint32_t pic_width_in_mbs_minus1; + uint32_t pic_height_in_map_units_minus1; + uint32_t frame_crop_left_offset; + uint32_t frame_crop_right_offset; + uint32_t frame_crop_top_offset; + uint32_t frame_crop_bottom_offset; + uint32_t reserved2; + const int32_t* pOffsetForRefFrame; + const StdVideoH264ScalingLists* pScalingLists; + const StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui; +} StdVideoH264SequenceParameterSet; + +typedef struct StdVideoH264PpsFlags { + uint32_t transform_8x8_mode_flag : 1; + uint32_t redundant_pic_cnt_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t bottom_field_pic_order_in_frame_present_flag : 1; + uint32_t entropy_coding_mode_flag : 1; + uint32_t pic_scaling_matrix_present_flag : 1; +} StdVideoH264PpsFlags; + +typedef struct StdVideoH264PictureParameterSet { + StdVideoH264PpsFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + StdVideoH264WeightedBipredIdc weighted_bipred_idc; + int8_t pic_init_qp_minus26; + int8_t pic_init_qs_minus26; + int8_t chroma_qp_index_offset; + int8_t second_chroma_qp_index_offset; + const StdVideoH264ScalingLists* pScalingLists; +} StdVideoH264PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h new file mode 100644 index 0000000000..439cb885e7 --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h @@ -0,0 +1,77 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std_decode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std_decode 1 +#include "vulkan_video_codec_h264std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_decode" +#define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2 + +typedef enum StdVideoDecodeH264FieldOrderCount { + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF +} StdVideoDecodeH264FieldOrderCount; +typedef struct StdVideoDecodeH264PictureInfoFlags { + uint32_t field_pic_flag : 1; + uint32_t is_intra : 1; + uint32_t IdrPicFlag : 1; + uint32_t bottom_field_flag : 1; + uint32_t is_reference : 1; + uint32_t complementary_field_pair : 1; +} StdVideoDecodeH264PictureInfoFlags; + +typedef struct StdVideoDecodeH264PictureInfo { + StdVideoDecodeH264PictureInfoFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t reserved1; + uint8_t reserved2; + uint16_t frame_num; + uint16_t idr_pic_id; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264PictureInfo; + +typedef struct StdVideoDecodeH264ReferenceInfoFlags { + uint32_t top_field_flag : 1; + uint32_t bottom_field_flag : 1; + uint32_t used_for_long_term_reference : 1; + uint32_t is_non_existing : 1; +} StdVideoDecodeH264ReferenceInfoFlags; + +typedef struct StdVideoDecodeH264ReferenceInfo { + StdVideoDecodeH264ReferenceInfoFlags flags; + uint16_t FrameNum; + uint16_t reserved; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h new file mode 100644 index 0000000000..9e24aa5d99 --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h @@ -0,0 +1,147 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std_encode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std_encode 1 +#include "vulkan_video_codec_h264std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_encode" +typedef struct StdVideoEncodeH264WeightTableFlags { + uint32_t luma_weight_l0_flag; + uint32_t chroma_weight_l0_flag; + uint32_t luma_weight_l1_flag; + uint32_t chroma_weight_l1_flag; +} StdVideoEncodeH264WeightTableFlags; + +typedef struct StdVideoEncodeH264WeightTable { + StdVideoEncodeH264WeightTableFlags flags; + uint8_t luma_log2_weight_denom; + uint8_t chroma_log2_weight_denom; + int8_t luma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t luma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t chroma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t chroma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t luma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t luma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t chroma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t chroma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; +} StdVideoEncodeH264WeightTable; + +typedef struct StdVideoEncodeH264SliceHeaderFlags { + uint32_t direct_spatial_mv_pred_flag : 1; + uint32_t num_ref_idx_active_override_flag : 1; + uint32_t reserved : 30; +} StdVideoEncodeH264SliceHeaderFlags; + +typedef struct StdVideoEncodeH264PictureInfoFlags { + uint32_t IdrPicFlag : 1; + uint32_t is_reference : 1; + uint32_t no_output_of_prior_pics_flag : 1; + uint32_t long_term_reference_flag : 1; + uint32_t adaptive_ref_pic_marking_mode_flag : 1; + uint32_t reserved : 27; +} StdVideoEncodeH264PictureInfoFlags; + +typedef struct StdVideoEncodeH264ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t reserved : 31; +} StdVideoEncodeH264ReferenceInfoFlags; + +typedef struct StdVideoEncodeH264ReferenceListsInfoFlags { + uint32_t ref_pic_list_modification_flag_l0 : 1; + uint32_t ref_pic_list_modification_flag_l1 : 1; + uint32_t reserved : 30; +} StdVideoEncodeH264ReferenceListsInfoFlags; + +typedef struct StdVideoEncodeH264RefListModEntry { + StdVideoH264ModificationOfPicNumsIdc modification_of_pic_nums_idc; + uint16_t abs_diff_pic_num_minus1; + uint16_t long_term_pic_num; +} StdVideoEncodeH264RefListModEntry; + +typedef struct StdVideoEncodeH264RefPicMarkingEntry { + StdVideoH264MemMgmtControlOp memory_management_control_operation; + uint16_t difference_of_pic_nums_minus1; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; + uint16_t max_long_term_frame_idx_plus1; +} StdVideoEncodeH264RefPicMarkingEntry; + +typedef struct StdVideoEncodeH264ReferenceListsInfo { + StdVideoEncodeH264ReferenceListsInfoFlags flags; + uint8_t num_ref_idx_l0_active_minus1; + uint8_t num_ref_idx_l1_active_minus1; + uint8_t RefPicList0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + uint8_t RefPicList1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + uint8_t refList0ModOpCount; + uint8_t refList1ModOpCount; + uint8_t refPicMarkingOpCount; + uint8_t reserved1[7]; + const StdVideoEncodeH264RefListModEntry* pRefList0ModOperations; + const StdVideoEncodeH264RefListModEntry* pRefList1ModOperations; + const StdVideoEncodeH264RefPicMarkingEntry* pRefPicMarkingOperations; +} StdVideoEncodeH264ReferenceListsInfo; + +typedef struct StdVideoEncodeH264PictureInfo { + StdVideoEncodeH264PictureInfoFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint16_t idr_pic_id; + StdVideoH264PictureType primary_pic_type; + uint32_t frame_num; + int32_t PicOrderCnt; + uint8_t temporal_id; + uint8_t reserved1[3]; + const StdVideoEncodeH264ReferenceListsInfo* pRefLists; +} StdVideoEncodeH264PictureInfo; + +typedef struct StdVideoEncodeH264ReferenceInfo { + StdVideoEncodeH264ReferenceInfoFlags flags; + StdVideoH264PictureType primary_pic_type; + uint32_t FrameNum; + int32_t PicOrderCnt; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; + uint8_t temporal_id; +} StdVideoEncodeH264ReferenceInfo; + +typedef struct StdVideoEncodeH264SliceHeader { + StdVideoEncodeH264SliceHeaderFlags flags; + uint32_t first_mb_in_slice; + StdVideoH264SliceType slice_type; + int8_t slice_alpha_c0_offset_div2; + int8_t slice_beta_offset_div2; + int8_t slice_qp_delta; + uint8_t reserved1; + StdVideoH264CabacInitIdc cabac_init_idc; + StdVideoH264DisableDeblockingFilterIdc disable_deblocking_filter_idc; + const StdVideoEncodeH264WeightTable* pWeightTable; +} StdVideoEncodeH264SliceHeader; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std.h new file mode 100644 index 0000000000..d0a1bacbea --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std.h @@ -0,0 +1,446 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_H_ +#define VULKAN_VIDEO_CODEC_H265STD_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std 1 +#include "vulkan_video_codecs_common.h" +#define STD_VIDEO_H265_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H265_SUBLAYERS_LIST_SIZE 7 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS 2 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE 6 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE 19 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE 21 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE 3 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE 128 +#define STD_VIDEO_H265_MAX_NUM_LIST_REF 15 +#define STD_VIDEO_H265_MAX_CHROMA_PLANES 2 +#define STD_VIDEO_H265_MAX_SHORT_TERM_REF_PIC_SETS 64 +#define STD_VIDEO_H265_MAX_DPB_SIZE 16 +#define STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS 32 +#define STD_VIDEO_H265_MAX_LONG_TERM_PICS 16 +#define STD_VIDEO_H265_MAX_DELTA_POC 48 +#define STD_VIDEO_H265_NO_REFERENCE_PICTURE 0xFF + +typedef enum StdVideoH265ChromaFormatIdc { + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ChromaFormatIdc; + +typedef enum StdVideoH265ProfileIdc { + STD_VIDEO_H265_PROFILE_IDC_MAIN = 1, + STD_VIDEO_H265_PROFILE_IDC_MAIN_10 = 2, + STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE = 3, + STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS = 4, + STD_VIDEO_H265_PROFILE_IDC_SCC_EXTENSIONS = 9, + STD_VIDEO_H265_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ProfileIdc; + +typedef enum StdVideoH265LevelIdc { + STD_VIDEO_H265_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H265_LEVEL_IDC_2_0 = 1, + STD_VIDEO_H265_LEVEL_IDC_2_1 = 2, + STD_VIDEO_H265_LEVEL_IDC_3_0 = 3, + STD_VIDEO_H265_LEVEL_IDC_3_1 = 4, + STD_VIDEO_H265_LEVEL_IDC_4_0 = 5, + STD_VIDEO_H265_LEVEL_IDC_4_1 = 6, + STD_VIDEO_H265_LEVEL_IDC_5_0 = 7, + STD_VIDEO_H265_LEVEL_IDC_5_1 = 8, + STD_VIDEO_H265_LEVEL_IDC_5_2 = 9, + STD_VIDEO_H265_LEVEL_IDC_6_0 = 10, + STD_VIDEO_H265_LEVEL_IDC_6_1 = 11, + STD_VIDEO_H265_LEVEL_IDC_6_2 = 12, + STD_VIDEO_H265_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265LevelIdc; + +typedef enum StdVideoH265SliceType { + STD_VIDEO_H265_SLICE_TYPE_B = 0, + STD_VIDEO_H265_SLICE_TYPE_P = 1, + STD_VIDEO_H265_SLICE_TYPE_I = 2, + STD_VIDEO_H265_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265SliceType; + +typedef enum StdVideoH265PictureType { + STD_VIDEO_H265_PICTURE_TYPE_P = 0, + STD_VIDEO_H265_PICTURE_TYPE_B = 1, + STD_VIDEO_H265_PICTURE_TYPE_I = 2, + STD_VIDEO_H265_PICTURE_TYPE_IDR = 3, + STD_VIDEO_H265_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265PictureType; + +typedef enum StdVideoH265AspectRatioIdc { + STD_VIDEO_H265_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H265_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H265_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H265_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H265_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H265_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H265_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H265_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H265_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H265_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H265_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H265_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H265_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H265_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H265_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H265_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H265_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H265_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H265_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265AspectRatioIdc; +typedef struct StdVideoH265DecPicBufMgr { + uint32_t max_latency_increase_plus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_dec_pic_buffering_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_num_reorder_pics[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; +} StdVideoH265DecPicBufMgr; + +typedef struct StdVideoH265SubLayerHrdParameters { + uint32_t bit_rate_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t bit_rate_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cbr_flag; +} StdVideoH265SubLayerHrdParameters; + +typedef struct StdVideoH265HrdFlags { + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; + uint32_t sub_pic_hrd_params_present_flag : 1; + uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1; + uint32_t fixed_pic_rate_general_flag : 8; + uint32_t fixed_pic_rate_within_cvs_flag : 8; + uint32_t low_delay_hrd_flag : 8; +} StdVideoH265HrdFlags; + +typedef struct StdVideoH265HrdParameters { + StdVideoH265HrdFlags flags; + uint8_t tick_divisor_minus2; + uint8_t du_cpb_removal_delay_increment_length_minus1; + uint8_t dpb_output_delay_du_length_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t cpb_size_du_scale; + uint8_t initial_cpb_removal_delay_length_minus1; + uint8_t au_cpb_removal_delay_length_minus1; + uint8_t dpb_output_delay_length_minus1; + uint8_t cpb_cnt_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t elemental_duration_in_tc_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t reserved[3]; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersNal; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersVcl; +} StdVideoH265HrdParameters; + +typedef struct StdVideoH265VpsFlags { + uint32_t vps_temporal_id_nesting_flag : 1; + uint32_t vps_sub_layer_ordering_info_present_flag : 1; + uint32_t vps_timing_info_present_flag : 1; + uint32_t vps_poc_proportional_to_timing_flag : 1; +} StdVideoH265VpsFlags; + +typedef struct StdVideoH265ProfileTierLevelFlags { + uint32_t general_tier_flag : 1; + uint32_t general_progressive_source_flag : 1; + uint32_t general_interlaced_source_flag : 1; + uint32_t general_non_packed_constraint_flag : 1; + uint32_t general_frame_only_constraint_flag : 1; +} StdVideoH265ProfileTierLevelFlags; + +typedef struct StdVideoH265ProfileTierLevel { + StdVideoH265ProfileTierLevelFlags flags; + StdVideoH265ProfileIdc general_profile_idc; + StdVideoH265LevelIdc general_level_idc; +} StdVideoH265ProfileTierLevel; + +typedef struct StdVideoH265VideoParameterSet { + StdVideoH265VpsFlags flags; + uint8_t vps_video_parameter_set_id; + uint8_t vps_max_sub_layers_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint32_t vps_num_units_in_tick; + uint32_t vps_time_scale; + uint32_t vps_num_ticks_poc_diff_one_minus1; + uint32_t reserved3; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265HrdParameters* pHrdParameters; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; +} StdVideoH265VideoParameterSet; + +typedef struct StdVideoH265ScalingLists { + uint8_t ScalingList4x4[STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS]; + uint8_t ScalingList16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS]; + uint8_t ScalingList32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS]; + uint8_t ScalingListDCCoef16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS]; + uint8_t ScalingListDCCoef32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS]; +} StdVideoH265ScalingLists; + +typedef struct StdVideoH265SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t colour_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t neutral_chroma_indication_flag : 1; + uint32_t field_seq_flag : 1; + uint32_t frame_field_info_present_flag : 1; + uint32_t default_display_window_flag : 1; + uint32_t vui_timing_info_present_flag : 1; + uint32_t vui_poc_proportional_to_timing_flag : 1; + uint32_t vui_hrd_parameters_present_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t tiles_fixed_structure_flag : 1; + uint32_t motion_vectors_over_pic_boundaries_flag : 1; + uint32_t restricted_ref_pic_lists_flag : 1; +} StdVideoH265SpsVuiFlags; + +typedef struct StdVideoH265SequenceParameterSetVui { + StdVideoH265SpsVuiFlags flags; + StdVideoH265AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coeffs; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint8_t reserved1; + uint8_t reserved2; + uint16_t def_disp_win_left_offset; + uint16_t def_disp_win_right_offset; + uint16_t def_disp_win_top_offset; + uint16_t def_disp_win_bottom_offset; + uint32_t vui_num_units_in_tick; + uint32_t vui_time_scale; + uint32_t vui_num_ticks_poc_diff_one_minus1; + uint16_t min_spatial_segmentation_idc; + uint16_t reserved3; + uint8_t max_bytes_per_pic_denom; + uint8_t max_bits_per_min_cu_denom; + uint8_t log2_max_mv_length_horizontal; + uint8_t log2_max_mv_length_vertical; + const StdVideoH265HrdParameters* pHrdParameters; +} StdVideoH265SequenceParameterSetVui; + +typedef struct StdVideoH265PredictorPaletteEntries { + uint16_t PredictorPaletteEntries[STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE][STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE]; +} StdVideoH265PredictorPaletteEntries; + +typedef struct StdVideoH265SpsFlags { + uint32_t sps_temporal_id_nesting_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t conformance_window_flag : 1; + uint32_t sps_sub_layer_ordering_info_present_flag : 1; + uint32_t scaling_list_enabled_flag : 1; + uint32_t sps_scaling_list_data_present_flag : 1; + uint32_t amp_enabled_flag : 1; + uint32_t sample_adaptive_offset_enabled_flag : 1; + uint32_t pcm_enabled_flag : 1; + uint32_t pcm_loop_filter_disabled_flag : 1; + uint32_t long_term_ref_pics_present_flag : 1; + uint32_t sps_temporal_mvp_enabled_flag : 1; + uint32_t strong_intra_smoothing_enabled_flag : 1; + uint32_t vui_parameters_present_flag : 1; + uint32_t sps_extension_present_flag : 1; + uint32_t sps_range_extension_flag : 1; + uint32_t transform_skip_rotation_enabled_flag : 1; + uint32_t transform_skip_context_enabled_flag : 1; + uint32_t implicit_rdpcm_enabled_flag : 1; + uint32_t explicit_rdpcm_enabled_flag : 1; + uint32_t extended_precision_processing_flag : 1; + uint32_t intra_smoothing_disabled_flag : 1; + uint32_t high_precision_offsets_enabled_flag : 1; + uint32_t persistent_rice_adaptation_enabled_flag : 1; + uint32_t cabac_bypass_alignment_enabled_flag : 1; + uint32_t sps_scc_extension_flag : 1; + uint32_t sps_curr_pic_ref_enabled_flag : 1; + uint32_t palette_mode_enabled_flag : 1; + uint32_t sps_palette_predictor_initializers_present_flag : 1; + uint32_t intra_boundary_filtering_disabled_flag : 1; +} StdVideoH265SpsFlags; + +typedef struct StdVideoH265ShortTermRefPicSetFlags { + uint32_t inter_ref_pic_set_prediction_flag : 1; + uint32_t delta_rps_sign : 1; +} StdVideoH265ShortTermRefPicSetFlags; + +typedef struct StdVideoH265ShortTermRefPicSet { + StdVideoH265ShortTermRefPicSetFlags flags; + uint32_t delta_idx_minus1; + uint16_t use_delta_flag; + uint16_t abs_delta_rps_minus1; + uint16_t used_by_curr_pic_flag; + uint16_t used_by_curr_pic_s0_flag; + uint16_t used_by_curr_pic_s1_flag; + uint16_t reserved1; + uint8_t reserved2; + uint8_t reserved3; + uint8_t num_negative_pics; + uint8_t num_positive_pics; + uint16_t delta_poc_s0_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; + uint16_t delta_poc_s1_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; +} StdVideoH265ShortTermRefPicSet; + +typedef struct StdVideoH265LongTermRefPicsSps { + uint32_t used_by_curr_pic_lt_sps_flag; + uint32_t lt_ref_pic_poc_lsb_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]; +} StdVideoH265LongTermRefPicsSps; + +typedef struct StdVideoH265SequenceParameterSet { + StdVideoH265SpsFlags flags; + StdVideoH265ChromaFormatIdc chroma_format_idc; + uint32_t pic_width_in_luma_samples; + uint32_t pic_height_in_luma_samples; + uint8_t sps_video_parameter_set_id; + uint8_t sps_max_sub_layers_minus1; + uint8_t sps_seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t log2_min_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_luma_coding_block_size; + uint8_t log2_min_luma_transform_block_size_minus2; + uint8_t log2_diff_max_min_luma_transform_block_size; + uint8_t max_transform_hierarchy_depth_inter; + uint8_t max_transform_hierarchy_depth_intra; + uint8_t num_short_term_ref_pic_sets; + uint8_t num_long_term_ref_pics_sps; + uint8_t pcm_sample_bit_depth_luma_minus1; + uint8_t pcm_sample_bit_depth_chroma_minus1; + uint8_t log2_min_pcm_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_pcm_luma_coding_block_size; + uint8_t reserved1; + uint8_t reserved2; + uint8_t palette_max_size; + uint8_t delta_palette_max_predictor_size; + uint8_t motion_vector_resolution_control_idc; + uint8_t sps_num_palette_predictor_initializers_minus1; + uint32_t conf_win_left_offset; + uint32_t conf_win_right_offset; + uint32_t conf_win_top_offset; + uint32_t conf_win_bottom_offset; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet; + const StdVideoH265LongTermRefPicsSps* pLongTermRefPicsSps; + const StdVideoH265SequenceParameterSetVui* pSequenceParameterSetVui; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265SequenceParameterSet; + +typedef struct StdVideoH265PpsFlags { + uint32_t dependent_slice_segments_enabled_flag : 1; + uint32_t output_flag_present_flag : 1; + uint32_t sign_data_hiding_enabled_flag : 1; + uint32_t cabac_init_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t transform_skip_enabled_flag : 1; + uint32_t cu_qp_delta_enabled_flag : 1; + uint32_t pps_slice_chroma_qp_offsets_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_flag : 1; + uint32_t transquant_bypass_enabled_flag : 1; + uint32_t tiles_enabled_flag : 1; + uint32_t entropy_coding_sync_enabled_flag : 1; + uint32_t uniform_spacing_flag : 1; + uint32_t loop_filter_across_tiles_enabled_flag : 1; + uint32_t pps_loop_filter_across_slices_enabled_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t deblocking_filter_override_enabled_flag : 1; + uint32_t pps_deblocking_filter_disabled_flag : 1; + uint32_t pps_scaling_list_data_present_flag : 1; + uint32_t lists_modification_present_flag : 1; + uint32_t slice_segment_header_extension_present_flag : 1; + uint32_t pps_extension_present_flag : 1; + uint32_t cross_component_prediction_enabled_flag : 1; + uint32_t chroma_qp_offset_list_enabled_flag : 1; + uint32_t pps_curr_pic_ref_enabled_flag : 1; + uint32_t residual_adaptive_colour_transform_enabled_flag : 1; + uint32_t pps_slice_act_qp_offsets_present_flag : 1; + uint32_t pps_palette_predictor_initializers_present_flag : 1; + uint32_t monochrome_palette_flag : 1; + uint32_t pps_range_extension_flag : 1; +} StdVideoH265PpsFlags; + +typedef struct StdVideoH265PictureParameterSet { + StdVideoH265PpsFlags flags; + uint8_t pps_pic_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t sps_video_parameter_set_id; + uint8_t num_extra_slice_header_bits; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + int8_t init_qp_minus26; + uint8_t diff_cu_qp_delta_depth; + int8_t pps_cb_qp_offset; + int8_t pps_cr_qp_offset; + int8_t pps_beta_offset_div2; + int8_t pps_tc_offset_div2; + uint8_t log2_parallel_merge_level_minus2; + uint8_t log2_max_transform_skip_block_size_minus2; + uint8_t diff_cu_chroma_qp_offset_depth; + uint8_t chroma_qp_offset_list_len_minus1; + int8_t cb_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + int8_t cr_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + uint8_t log2_sao_offset_scale_luma; + uint8_t log2_sao_offset_scale_chroma; + int8_t pps_act_y_qp_offset_plus5; + int8_t pps_act_cb_qp_offset_plus5; + int8_t pps_act_cr_qp_offset_plus3; + uint8_t pps_num_palette_predictor_initializers; + uint8_t luma_bit_depth_entry_minus8; + uint8_t chroma_bit_depth_entry_minus8; + uint8_t num_tile_columns_minus1; + uint8_t num_tile_rows_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint16_t column_width_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE]; + uint16_t row_height_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE]; + uint32_t reserved3; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h new file mode 100644 index 0000000000..0178793e51 --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h @@ -0,0 +1,67 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std_decode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std_decode 1 +#include "vulkan_video_codec_h265std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_decode" +#define STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE 8 +typedef struct StdVideoDecodeH265PictureInfoFlags { + uint32_t IrapPicFlag : 1; + uint32_t IdrPicFlag : 1; + uint32_t IsReference : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; +} StdVideoDecodeH265PictureInfoFlags; + +typedef struct StdVideoDecodeH265PictureInfo { + StdVideoDecodeH265PictureInfoFlags flags; + uint8_t sps_video_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t NumDeltaPocsOfRefRpsIdx; + int32_t PicOrderCntVal; + uint16_t NumBitsForSTRefPicSetInSlice; + uint16_t reserved; + uint8_t RefPicSetStCurrBefore[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetStCurrAfter[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetLtCurr[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; +} StdVideoDecodeH265PictureInfo; + +typedef struct StdVideoDecodeH265ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t unused_for_reference : 1; +} StdVideoDecodeH265ReferenceInfoFlags; + +typedef struct StdVideoDecodeH265ReferenceInfo { + StdVideoDecodeH265ReferenceInfoFlags flags; + int32_t PicOrderCntVal; +} StdVideoDecodeH265ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h new file mode 100644 index 0000000000..ee34491f4e --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h @@ -0,0 +1,157 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std_encode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std_encode 1 +#include "vulkan_video_codec_h265std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_encode" +typedef struct StdVideoEncodeH265WeightTableFlags { + uint16_t luma_weight_l0_flag; + uint16_t chroma_weight_l0_flag; + uint16_t luma_weight_l1_flag; + uint16_t chroma_weight_l1_flag; +} StdVideoEncodeH265WeightTableFlags; + +typedef struct StdVideoEncodeH265WeightTable { + StdVideoEncodeH265WeightTableFlags flags; + uint8_t luma_log2_weight_denom; + int8_t delta_chroma_log2_weight_denom; + int8_t delta_luma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t luma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t delta_chroma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_chroma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_luma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t luma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t delta_chroma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_chroma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; +} StdVideoEncodeH265WeightTable; + +typedef struct StdVideoEncodeH265SliceSegmentHeaderFlags { + uint32_t first_slice_segment_in_pic_flag : 1; + uint32_t dependent_slice_segment_flag : 1; + uint32_t slice_sao_luma_flag : 1; + uint32_t slice_sao_chroma_flag : 1; + uint32_t num_ref_idx_active_override_flag : 1; + uint32_t mvd_l1_zero_flag : 1; + uint32_t cabac_init_flag : 1; + uint32_t cu_chroma_qp_offset_enabled_flag : 1; + uint32_t deblocking_filter_override_flag : 1; + uint32_t slice_deblocking_filter_disabled_flag : 1; + uint32_t collocated_from_l0_flag : 1; + uint32_t slice_loop_filter_across_slices_enabled_flag : 1; + uint32_t reserved : 20; +} StdVideoEncodeH265SliceSegmentHeaderFlags; + +typedef struct StdVideoEncodeH265SliceSegmentHeader { + StdVideoEncodeH265SliceSegmentHeaderFlags flags; + StdVideoH265SliceType slice_type; + uint32_t slice_segment_address; + uint8_t collocated_ref_idx; + uint8_t MaxNumMergeCand; + int8_t slice_cb_qp_offset; + int8_t slice_cr_qp_offset; + int8_t slice_beta_offset_div2; + int8_t slice_tc_offset_div2; + int8_t slice_act_y_qp_offset; + int8_t slice_act_cb_qp_offset; + int8_t slice_act_cr_qp_offset; + int8_t slice_qp_delta; + uint16_t reserved1; + const StdVideoEncodeH265WeightTable* pWeightTable; +} StdVideoEncodeH265SliceSegmentHeader; + +typedef struct StdVideoEncodeH265ReferenceListsInfoFlags { + uint32_t ref_pic_list_modification_flag_l0 : 1; + uint32_t ref_pic_list_modification_flag_l1 : 1; + uint32_t reserved : 30; +} StdVideoEncodeH265ReferenceListsInfoFlags; + +typedef struct StdVideoEncodeH265ReferenceListsInfo { + StdVideoEncodeH265ReferenceListsInfoFlags flags; + uint8_t num_ref_idx_l0_active_minus1; + uint8_t num_ref_idx_l1_active_minus1; + uint8_t RefPicList0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t RefPicList1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t list_entry_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t list_entry_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; +} StdVideoEncodeH265ReferenceListsInfo; + +typedef struct StdVideoEncodeH265PictureInfoFlags { + uint32_t is_reference : 1; + uint32_t IrapPicFlag : 1; + uint32_t used_for_long_term_reference : 1; + uint32_t discardable_flag : 1; + uint32_t cross_layer_bla_flag : 1; + uint32_t pic_output_flag : 1; + uint32_t no_output_of_prior_pics_flag : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; + uint32_t slice_temporal_mvp_enabled_flag : 1; + uint32_t reserved : 23; +} StdVideoEncodeH265PictureInfoFlags; + +typedef struct StdVideoEncodeH265LongTermRefPics { + uint8_t num_long_term_sps; + uint8_t num_long_term_pics; + uint8_t lt_idx_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]; + uint8_t poc_lsb_lt[STD_VIDEO_H265_MAX_LONG_TERM_PICS]; + uint16_t used_by_curr_pic_lt_flag; + uint8_t delta_poc_msb_present_flag[STD_VIDEO_H265_MAX_DELTA_POC]; + uint8_t delta_poc_msb_cycle_lt[STD_VIDEO_H265_MAX_DELTA_POC]; +} StdVideoEncodeH265LongTermRefPics; + +typedef struct StdVideoEncodeH265PictureInfo { + StdVideoEncodeH265PictureInfoFlags flags; + StdVideoH265PictureType pic_type; + uint8_t sps_video_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t short_term_ref_pic_set_idx; + int32_t PicOrderCntVal; + uint8_t TemporalId; + uint8_t reserved1[7]; + const StdVideoEncodeH265ReferenceListsInfo* pRefLists; + const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet; + const StdVideoEncodeH265LongTermRefPics* pLongTermRefPics; +} StdVideoEncodeH265PictureInfo; + +typedef struct StdVideoEncodeH265ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t unused_for_reference : 1; + uint32_t reserved : 30; +} StdVideoEncodeH265ReferenceInfoFlags; + +typedef struct StdVideoEncodeH265ReferenceInfo { + StdVideoEncodeH265ReferenceInfoFlags flags; + StdVideoH265PictureType pic_type; + int32_t PicOrderCntVal; + uint8_t TemporalId; +} StdVideoEncodeH265ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codecs_common.h b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codecs_common.h new file mode 100644 index 0000000000..5e6ef1db48 --- /dev/null +++ b/vs/sdl2/src/video/khronos/vk_video/vulkan_video_codecs_common.h @@ -0,0 +1,36 @@ +#ifndef VULKAN_VIDEO_CODECS_COMMON_H_ +#define VULKAN_VIDEO_CODECS_COMMON_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codecs_common is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codecs_common 1 +#if !defined(VK_NO_STDINT_H) + #include +#endif + +#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/vs/sdl2/src/video/khronos/vulkan/vk_icd.h b/vs/sdl2/src/video/khronos/vulkan/vk_icd.h index 41989ee354..59204a3419 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vk_icd.h +++ b/vs/sdl2/src/video/khronos/vulkan/vk_icd.h @@ -1,27 +1,11 @@ -// -// File: vk_icd.h -// /* - * Copyright (c) 2015-2016 The Khronos Group Inc. - * Copyright (c) 2015-2016 Valve Corporation - * Copyright (c) 2015-2016 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2015-2023 The Khronos Group Inc. + * Copyright 2015-2023 Valve Corporation + * Copyright 2015-2023 LunarG, Inc. * + * SPDX-License-Identifier: Apache-2.0 */ - -#ifndef VKICD_H -#define VKICD_H +#pragma once #include "vulkan.h" #include @@ -42,7 +26,17 @@ // call for any API version > 1.0. Otherwise, the loader will // manually determine if it can support the expected version. // Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices. -#define CURRENT_LOADER_ICD_INTERFACE_VERSION 6 +// Version 7 - If an ICD supports any of the following functions, they must be +// queryable with vk_icdGetInstanceProcAddr: +// vk_icdNegotiateLoaderICDInterfaceVersion +// vk_icdGetPhysicalDeviceProcAddr +// vk_icdEnumerateAdapterPhysicalDevices (Windows only) +// In addition, these functions no longer need to be exported directly. +// This version allows drivers provided through the extension +// VK_LUNARG_direct_driver_loading be able to support the entire +// Driver-Loader interface. + +#define CURRENT_LOADER_ICD_INTERFACE_VERSION 7 #define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 #define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4 @@ -70,7 +64,7 @@ extern "C" { #endif VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion); VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName); - VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance isntance, const char* pName); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName); #if defined(VK_USE_PLATFORM_WIN32_KHR) VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); @@ -123,6 +117,7 @@ typedef enum { VK_ICD_WSI_PLATFORM_VI, VK_ICD_WSI_PLATFORM_GGP, VK_ICD_WSI_PLATFORM_SCREEN, + VK_ICD_WSI_PLATFORM_FUCHSIA, } VkIcdWsiPlatform; typedef struct { @@ -242,4 +237,8 @@ typedef struct { } VkIcdSurfaceScreen; #endif // VK_USE_PLATFORM_SCREEN_QNX -#endif // VKICD_H +#ifdef VK_USE_PLATFORM_FUCHSIA +typedef struct { + VkIcdSurfaceBase base; +} VkIcdSurfaceImagePipe; +#endif // VK_USE_PLATFORM_FUCHSIA diff --git a/vs/sdl2/src/video/khronos/vulkan/vk_layer.h b/vs/sdl2/src/video/khronos/vulkan/vk_layer.h index 0651870c70..19d88fce4b 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vk_layer.h +++ b/vs/sdl2/src/video/khronos/vulkan/vk_layer.h @@ -1,39 +1,18 @@ -// -// File: vk_layer.h -// /* - * Copyright (c) 2015-2017 The Khronos Group Inc. - * Copyright (c) 2015-2017 Valve Corporation - * Copyright (c) 2015-2017 LunarG, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Copyright 2015-2023 The Khronos Group Inc. + * Copyright 2015-2023 Valve Corporation + * Copyright 2015-2023 LunarG, Inc. * + * SPDX-License-Identifier: Apache-2.0 */ +#pragma once /* Need to define dispatch table * Core struct can then have ptr to dispatch table at the top * Along with object ptrs for current and next OBJ */ -#pragma once -#include "vulkan.h" -#if defined(__GNUC__) && __GNUC__ >= 4 -#define VK_LAYER_EXPORT __attribute__((visibility("default"))) -#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) -#define VK_LAYER_EXPORT __attribute__((visibility("default"))) -#else -#define VK_LAYER_EXPORT -#endif +#include "vulkan_core.h" #define MAX_NUM_UNKNOWN_EXTS 250 diff --git a/vs/sdl2/src/video/khronos/vulkan/vk_platform.h b/vs/sdl2/src/video/khronos/vulkan/vk_platform.h index 3ff8c5d146..0ecd4f6471 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vk_platform.h +++ b/vs/sdl2/src/video/khronos/vulkan/vk_platform.h @@ -2,7 +2,7 @@ // File: vk_platform.h // /* -** Copyright 2014-2022 The Khronos Group Inc. +** Copyright 2014-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan.h b/vs/sdl2/src/video/khronos/vulkan/vulkan.h index 004fa70952..ef94006bb3 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan.h @@ -2,7 +2,7 @@ #define VULKAN_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,6 @@ #ifdef VK_USE_PLATFORM_WAYLAND_KHR -#include #include "vulkan_wayland.h" #endif @@ -85,6 +84,14 @@ #include "vulkan_screen.h" #endif + +#ifdef VK_USE_PLATFORM_SCI +#include +#include +#include "vulkan_sci.h" +#endif + + #ifdef VK_ENABLE_BETA_EXTENSIONS #include "vulkan_beta.h" #endif diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_android.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_android.h index 11f5397966..61ff40ba8c 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_android.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_android.h @@ -2,7 +2,7 @@ #define VULKAN_ANDROID_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_KHR_android_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_android_surface 1 struct ANativeWindow; #define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6 @@ -42,6 +43,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( #endif +// VK_ANDROID_external_memory_android_hardware_buffer is a preprocessor guard. Do not pass it to API calls. #define VK_ANDROID_external_memory_android_hardware_buffer 1 struct AHardwareBuffer; #define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 5 @@ -118,6 +120,32 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID( struct AHardwareBuffer** pBuffer); #endif + +// VK_ANDROID_external_format_resolve is a preprocessor guard. Do not pass it to API calls. +#define VK_ANDROID_external_format_resolve 1 +#define VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_SPEC_VERSION 1 +#define VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_EXTENSION_NAME "VK_ANDROID_external_format_resolve" +typedef struct VkPhysicalDeviceExternalFormatResolveFeaturesANDROID { + VkStructureType sType; + void* pNext; + VkBool32 externalFormatResolve; +} VkPhysicalDeviceExternalFormatResolveFeaturesANDROID; + +typedef struct VkPhysicalDeviceExternalFormatResolvePropertiesANDROID { + VkStructureType sType; + void* pNext; + VkBool32 nullColorAttachmentWithExternalFormatResolve; + VkChromaLocation externalFormatResolveChromaOffsetX; + VkChromaLocation externalFormatResolveChromaOffsetY; +} VkPhysicalDeviceExternalFormatResolvePropertiesANDROID; + +typedef struct VkAndroidHardwareBufferFormatResolvePropertiesANDROID { + VkStructureType sType; + void* pNext; + VkFormat colorAttachmentFormat; +} VkAndroidHardwareBufferFormatResolvePropertiesANDROID; + + #ifdef __cplusplus } #endif diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_beta.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_beta.h index db03af41bd..df18b4042b 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_beta.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_beta.h @@ -2,7 +2,7 @@ #define VULKAN_BETA_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,356 +19,7 @@ extern "C" { -#define VK_KHR_video_queue 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR) -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR) -#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 5 -#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue" - -typedef enum VkQueryResultStatusKHR { - VK_QUERY_RESULT_STATUS_ERROR_KHR = -1, - VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0, - VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1, - VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkQueryResultStatusKHR; - -typedef enum VkVideoCodecOperationFlagBitsKHR { - VK_VIDEO_CODEC_OPERATION_NONE_KHR = 0, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_EXT = 0x00010000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_EXT = 0x00020000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_EXT = 0x00000001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_EXT = 0x00000002, -#endif - VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoCodecOperationFlagBitsKHR; -typedef VkFlags VkVideoCodecOperationFlagsKHR; - -typedef enum VkVideoChromaSubsamplingFlagBitsKHR { - VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR = 0, - VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001, - VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002, - VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004, - VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008, - VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoChromaSubsamplingFlagBitsKHR; -typedef VkFlags VkVideoChromaSubsamplingFlagsKHR; - -typedef enum VkVideoComponentBitDepthFlagBitsKHR { - VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0, - VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001, - VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004, - VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010, - VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoComponentBitDepthFlagBitsKHR; -typedef VkFlags VkVideoComponentBitDepthFlagsKHR; - -typedef enum VkVideoCapabilityFlagBitsKHR { - VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001, - VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002, - VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoCapabilityFlagBitsKHR; -typedef VkFlags VkVideoCapabilityFlagsKHR; - -typedef enum VkVideoSessionCreateFlagBitsKHR { - VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001, - VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoSessionCreateFlagBitsKHR; -typedef VkFlags VkVideoSessionCreateFlagsKHR; -typedef VkFlags VkVideoSessionParametersCreateFlagsKHR; -typedef VkFlags VkVideoBeginCodingFlagsKHR; -typedef VkFlags VkVideoEndCodingFlagsKHR; - -typedef enum VkVideoCodingControlFlagBitsKHR { - VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR = 0x00000002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_LAYER_BIT_KHR = 0x00000004, -#endif - VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoCodingControlFlagBitsKHR; -typedef VkFlags VkVideoCodingControlFlagsKHR; -typedef struct VkQueueFamilyQueryResultStatusPropertiesKHR { - VkStructureType sType; - void* pNext; - VkBool32 queryResultStatusSupport; -} VkQueueFamilyQueryResultStatusPropertiesKHR; - -typedef struct VkQueueFamilyVideoPropertiesKHR { - VkStructureType sType; - void* pNext; - VkVideoCodecOperationFlagsKHR videoCodecOperations; -} VkQueueFamilyVideoPropertiesKHR; - -typedef struct VkVideoProfileInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoCodecOperationFlagBitsKHR videoCodecOperation; - VkVideoChromaSubsamplingFlagsKHR chromaSubsampling; - VkVideoComponentBitDepthFlagsKHR lumaBitDepth; - VkVideoComponentBitDepthFlagsKHR chromaBitDepth; -} VkVideoProfileInfoKHR; - -typedef struct VkVideoProfileListInfoKHR { - VkStructureType sType; - const void* pNext; - uint32_t profileCount; - const VkVideoProfileInfoKHR* pProfiles; -} VkVideoProfileListInfoKHR; - -typedef struct VkVideoCapabilitiesKHR { - VkStructureType sType; - void* pNext; - VkVideoCapabilityFlagsKHR capabilityFlags; - VkDeviceSize minBitstreamBufferOffsetAlignment; - VkDeviceSize minBitstreamBufferSizeAlignment; - VkExtent2D videoPictureExtentGranularity; - VkExtent2D minExtent; - VkExtent2D maxExtent; - uint32_t maxReferencePicturesSlotsCount; - uint32_t maxReferencePicturesActiveCount; - VkExtensionProperties stdHeaderVersion; -} VkVideoCapabilitiesKHR; - -typedef struct VkPhysicalDeviceVideoFormatInfoKHR { - VkStructureType sType; - const void* pNext; - VkImageUsageFlags imageUsage; -} VkPhysicalDeviceVideoFormatInfoKHR; - -typedef struct VkVideoFormatPropertiesKHR { - VkStructureType sType; - void* pNext; - VkFormat format; - VkComponentMapping componentMapping; - VkImageCreateFlags imageCreateFlags; - VkImageType imageType; - VkImageTiling imageTiling; - VkImageUsageFlags imageUsageFlags; -} VkVideoFormatPropertiesKHR; - -typedef struct VkVideoPictureResourceInfoKHR { - VkStructureType sType; - const void* pNext; - VkOffset2D codedOffset; - VkExtent2D codedExtent; - uint32_t baseArrayLayer; - VkImageView imageViewBinding; -} VkVideoPictureResourceInfoKHR; - -typedef struct VkVideoReferenceSlotInfoKHR { - VkStructureType sType; - const void* pNext; - int8_t slotIndex; - const VkVideoPictureResourceInfoKHR* pPictureResource; -} VkVideoReferenceSlotInfoKHR; - -typedef struct VkVideoSessionMemoryRequirementsKHR { - VkStructureType sType; - void* pNext; - uint32_t memoryBindIndex; - VkMemoryRequirements memoryRequirements; -} VkVideoSessionMemoryRequirementsKHR; - -typedef struct VkBindVideoSessionMemoryInfoKHR { - VkStructureType sType; - const void* pNext; - uint32_t memoryBindIndex; - VkDeviceMemory memory; - VkDeviceSize memoryOffset; - VkDeviceSize memorySize; -} VkBindVideoSessionMemoryInfoKHR; - -typedef struct VkVideoSessionCreateInfoKHR { - VkStructureType sType; - const void* pNext; - uint32_t queueFamilyIndex; - VkVideoSessionCreateFlagsKHR flags; - const VkVideoProfileInfoKHR* pVideoProfile; - VkFormat pictureFormat; - VkExtent2D maxCodedExtent; - VkFormat referencePicturesFormat; - uint32_t maxReferencePicturesSlotsCount; - uint32_t maxReferencePicturesActiveCount; - const VkExtensionProperties* pStdHeaderVersion; -} VkVideoSessionCreateInfoKHR; - -typedef struct VkVideoSessionParametersCreateInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoSessionParametersCreateFlagsKHR flags; - VkVideoSessionParametersKHR videoSessionParametersTemplate; - VkVideoSessionKHR videoSession; -} VkVideoSessionParametersCreateInfoKHR; - -typedef struct VkVideoSessionParametersUpdateInfoKHR { - VkStructureType sType; - const void* pNext; - uint32_t updateSequenceCount; -} VkVideoSessionParametersUpdateInfoKHR; - -typedef struct VkVideoBeginCodingInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoBeginCodingFlagsKHR flags; - VkVideoSessionKHR videoSession; - VkVideoSessionParametersKHR videoSessionParameters; - uint32_t referenceSlotCount; - const VkVideoReferenceSlotInfoKHR* pReferenceSlots; -} VkVideoBeginCodingInfoKHR; - -typedef struct VkVideoEndCodingInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoEndCodingFlagsKHR flags; -} VkVideoEndCodingInfoKHR; - -typedef struct VkVideoCodingControlInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoCodingControlFlagsKHR flags; -} VkVideoCodingControlInfoKHR; - -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileInfoKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities); -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties); -typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession); -typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator); -typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pMemoryRequirementsCount, VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); -typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t bindSessionMemoryInfoCount, const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); -typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters); -typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); -typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator); -typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo); -typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo); -typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR( - VkPhysicalDevice physicalDevice, - const VkVideoProfileInfoKHR* pVideoProfile, - VkVideoCapabilitiesKHR* pCapabilities); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR( - VkPhysicalDevice physicalDevice, - const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, - uint32_t* pVideoFormatPropertyCount, - VkVideoFormatPropertiesKHR* pVideoFormatProperties); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR( - VkDevice device, - const VkVideoSessionCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkVideoSessionKHR* pVideoSession); - -VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR( - VkDevice device, - VkVideoSessionKHR videoSession, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR( - VkDevice device, - VkVideoSessionKHR videoSession, - uint32_t* pMemoryRequirementsCount, - VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); - -VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR( - VkDevice device, - VkVideoSessionKHR videoSession, - uint32_t bindSessionMemoryInfoCount, - const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); - -VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR( - VkDevice device, - const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, - const VkAllocationCallbacks* pAllocator, - VkVideoSessionParametersKHR* pVideoSessionParameters); - -VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR( - VkDevice device, - VkVideoSessionParametersKHR videoSessionParameters, - const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); - -VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR( - VkDevice device, - VkVideoSessionParametersKHR videoSessionParameters, - const VkAllocationCallbacks* pAllocator); - -VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR( - VkCommandBuffer commandBuffer, - const VkVideoBeginCodingInfoKHR* pBeginInfo); - -VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR( - VkCommandBuffer commandBuffer, - const VkVideoEndCodingInfoKHR* pEndCodingInfo); - -VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR( - VkCommandBuffer commandBuffer, - const VkVideoCodingControlInfoKHR* pCodingControlInfo); -#endif - - -#define VK_KHR_video_decode_queue 1 -#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 6 -#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue" - -typedef enum VkVideoDecodeCapabilityFlagBitsKHR { - VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR = 0x00000001, - VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR = 0x00000002, - VK_VIDEO_DECODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoDecodeCapabilityFlagBitsKHR; -typedef VkFlags VkVideoDecodeCapabilityFlagsKHR; - -typedef enum VkVideoDecodeUsageFlagBitsKHR { - VK_VIDEO_DECODE_USAGE_DEFAULT_KHR = 0, - VK_VIDEO_DECODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, - VK_VIDEO_DECODE_USAGE_OFFLINE_BIT_KHR = 0x00000002, - VK_VIDEO_DECODE_USAGE_STREAMING_BIT_KHR = 0x00000004, - VK_VIDEO_DECODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoDecodeUsageFlagBitsKHR; -typedef VkFlags VkVideoDecodeUsageFlagsKHR; -typedef VkFlags VkVideoDecodeFlagsKHR; -typedef struct VkVideoDecodeCapabilitiesKHR { - VkStructureType sType; - void* pNext; - VkVideoDecodeCapabilityFlagsKHR flags; -} VkVideoDecodeCapabilitiesKHR; - -typedef struct VkVideoDecodeUsageInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoDecodeUsageFlagsKHR videoUsageHints; -} VkVideoDecodeUsageInfoKHR; - -typedef struct VkVideoDecodeInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoDecodeFlagsKHR flags; - VkBuffer srcBuffer; - VkDeviceSize srcBufferOffset; - VkDeviceSize srcBufferRange; - VkVideoPictureResourceInfoKHR dstPictureResource; - const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; - uint32_t referenceSlotCount; - const VkVideoReferenceSlotInfoKHR* pReferenceSlots; -} VkVideoDecodeInfoKHR; - -typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pFrameInfo); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR( - VkCommandBuffer commandBuffer, - const VkVideoDecodeInfoKHR* pFrameInfo); -#endif - - +// VK_KHR_portability_subset is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_portability_subset 1 #define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1 #define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset" @@ -400,617 +51,162 @@ typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR { -#define VK_KHR_video_encode_queue 1 -#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 7 -#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue" - -typedef enum VkVideoEncodeTuningModeKHR { - VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR = 0, - VK_VIDEO_ENCODE_TUNING_MODE_HIGH_QUALITY_KHR = 1, - VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR = 2, - VK_VIDEO_ENCODE_TUNING_MODE_ULTRA_LOW_LATENCY_KHR = 3, - VK_VIDEO_ENCODE_TUNING_MODE_LOSSLESS_KHR = 4, - VK_VIDEO_ENCODE_TUNING_MODE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoEncodeTuningModeKHR; -typedef VkFlags VkVideoEncodeFlagsKHR; - -typedef enum VkVideoEncodeCapabilityFlagBitsKHR { - VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR = 0x00000001, - VK_VIDEO_ENCODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoEncodeCapabilityFlagBitsKHR; -typedef VkFlags VkVideoEncodeCapabilityFlagsKHR; - -typedef enum VkVideoEncodeRateControlModeFlagBitsKHR { - VK_VIDEO_ENCODE_RATE_CONTROL_MODE_NONE_BIT_KHR = 0, - VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 1, - VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 2, - VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoEncodeRateControlModeFlagBitsKHR; -typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR; - -typedef enum VkVideoEncodeUsageFlagBitsKHR { - VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR = 0, - VK_VIDEO_ENCODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, - VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR = 0x00000002, - VK_VIDEO_ENCODE_USAGE_RECORDING_BIT_KHR = 0x00000004, - VK_VIDEO_ENCODE_USAGE_CONFERENCING_BIT_KHR = 0x00000008, - VK_VIDEO_ENCODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoEncodeUsageFlagBitsKHR; -typedef VkFlags VkVideoEncodeUsageFlagsKHR; - -typedef enum VkVideoEncodeContentFlagBitsKHR { - VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR = 0, - VK_VIDEO_ENCODE_CONTENT_CAMERA_BIT_KHR = 0x00000001, - VK_VIDEO_ENCODE_CONTENT_DESKTOP_BIT_KHR = 0x00000002, - VK_VIDEO_ENCODE_CONTENT_RENDERED_BIT_KHR = 0x00000004, - VK_VIDEO_ENCODE_CONTENT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF -} VkVideoEncodeContentFlagBitsKHR; -typedef VkFlags VkVideoEncodeContentFlagsKHR; -typedef VkFlags VkVideoEncodeRateControlFlagsKHR; -typedef struct VkVideoEncodeInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoEncodeFlagsKHR flags; - uint32_t qualityLevel; - VkBuffer dstBitstreamBuffer; - VkDeviceSize dstBitstreamBufferOffset; - VkDeviceSize dstBitstreamBufferMaxRange; - VkVideoPictureResourceInfoKHR srcPictureResource; - const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; - uint32_t referenceSlotCount; - const VkVideoReferenceSlotInfoKHR* pReferenceSlots; - uint32_t precedingExternallyEncodedBytes; -} VkVideoEncodeInfoKHR; - -typedef struct VkVideoEncodeCapabilitiesKHR { - VkStructureType sType; - void* pNext; - VkVideoEncodeCapabilityFlagsKHR flags; - VkVideoEncodeRateControlModeFlagsKHR rateControlModes; - uint8_t rateControlLayerCount; - uint8_t qualityLevelCount; - VkExtent2D inputImageDataFillAlignment; -} VkVideoEncodeCapabilitiesKHR; - -typedef struct VkVideoEncodeUsageInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoEncodeUsageFlagsKHR videoUsageHints; - VkVideoEncodeContentFlagsKHR videoContentHints; - VkVideoEncodeTuningModeKHR tuningMode; -} VkVideoEncodeUsageInfoKHR; - -typedef struct VkVideoEncodeRateControlLayerInfoKHR { +// VK_AMDX_shader_enqueue is a preprocessor guard. Do not pass it to API calls. +#define VK_AMDX_shader_enqueue 1 +#define VK_AMDX_SHADER_ENQUEUE_SPEC_VERSION 1 +#define VK_AMDX_SHADER_ENQUEUE_EXTENSION_NAME "VK_AMDX_shader_enqueue" +#define VK_SHADER_INDEX_UNUSED_AMDX (~0U) +typedef struct VkPhysicalDeviceShaderEnqueueFeaturesAMDX { VkStructureType sType; - const void* pNext; - uint32_t averageBitrate; - uint32_t maxBitrate; - uint32_t frameRateNumerator; - uint32_t frameRateDenominator; - uint32_t virtualBufferSizeInMs; - uint32_t initialVirtualBufferSizeInMs; -} VkVideoEncodeRateControlLayerInfoKHR; - -typedef struct VkVideoEncodeRateControlInfoKHR { - VkStructureType sType; - const void* pNext; - VkVideoEncodeRateControlFlagsKHR flags; - VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode; - uint8_t layerCount; - const VkVideoEncodeRateControlLayerInfoKHR* pLayerConfigs; -} VkVideoEncodeRateControlInfoKHR; - -typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo); + void* pNext; + VkBool32 shaderEnqueue; +} VkPhysicalDeviceShaderEnqueueFeaturesAMDX; + +typedef struct VkPhysicalDeviceShaderEnqueuePropertiesAMDX { + VkStructureType sType; + void* pNext; + uint32_t maxExecutionGraphDepth; + uint32_t maxExecutionGraphShaderOutputNodes; + uint32_t maxExecutionGraphShaderPayloadSize; + uint32_t maxExecutionGraphShaderPayloadCount; + uint32_t executionGraphDispatchAddressAlignment; +} VkPhysicalDeviceShaderEnqueuePropertiesAMDX; + +typedef struct VkExecutionGraphPipelineScratchSizeAMDX { + VkStructureType sType; + void* pNext; + VkDeviceSize size; +} VkExecutionGraphPipelineScratchSizeAMDX; + +typedef struct VkExecutionGraphPipelineCreateInfoAMDX { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + const VkPipelineLibraryCreateInfoKHR* pLibraryInfo; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkExecutionGraphPipelineCreateInfoAMDX; + +typedef union VkDeviceOrHostAddressConstAMDX { + VkDeviceAddress deviceAddress; + const void* hostAddress; +} VkDeviceOrHostAddressConstAMDX; + +typedef struct VkDispatchGraphInfoAMDX { + uint32_t nodeIndex; + uint32_t payloadCount; + VkDeviceOrHostAddressConstAMDX payloads; + uint64_t payloadStride; +} VkDispatchGraphInfoAMDX; + +typedef struct VkDispatchGraphCountInfoAMDX { + uint32_t count; + VkDeviceOrHostAddressConstAMDX infos; + uint64_t stride; +} VkDispatchGraphCountInfoAMDX; + +typedef struct VkPipelineShaderStageNodeCreateInfoAMDX { + VkStructureType sType; + const void* pNext; + const char* pName; + uint32_t index; +} VkPipelineShaderStageNodeCreateInfoAMDX; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateExecutionGraphPipelinesAMDX)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkExecutionGraphPipelineCreateInfoAMDX* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)(VkDevice device, VkPipeline executionGraph, VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)(VkDevice device, VkPipeline executionGraph, const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, uint32_t* pNodeIndex); +typedef void (VKAPI_PTR *PFN_vkCmdInitializeGraphScratchMemoryAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectCountAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceAddress countInfo); #ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR( +VKAPI_ATTR VkResult VKAPI_CALL vkCreateExecutionGraphPipelinesAMDX( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkExecutionGraphPipelineCreateInfoAMDX* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetExecutionGraphPipelineScratchSizeAMDX( + VkDevice device, + VkPipeline executionGraph, + VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetExecutionGraphPipelineNodeIndexAMDX( + VkDevice device, + VkPipeline executionGraph, + const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, + uint32_t* pNodeIndex); + +VKAPI_ATTR void VKAPI_CALL vkCmdInitializeGraphScratchMemoryAMDX( VkCommandBuffer commandBuffer, - const VkVideoEncodeInfoKHR* pEncodeInfo); + VkDeviceAddress scratch); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + const VkDispatchGraphCountInfoAMDX* pCountInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + const VkDispatchGraphCountInfoAMDX* pCountInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectCountAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + VkDeviceAddress countInfo); #endif -#define VK_EXT_video_encode_h264 1 -#include "vk_video/vulkan_video_codec_h264std.h" -#include "vk_video/vulkan_video_codec_h264std_encode.h" -#define VK_EXT_VIDEO_ENCODE_H264_SPEC_VERSION 8 -#define VK_EXT_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_EXT_video_encode_h264" - -typedef enum VkVideoEncodeH264RateControlStructureEXT { - VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0, - VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_FLAT_EXT = 1, - VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_DYADIC_EXT = 2, - VK_VIDEO_ENCODE_H264_RATE_CONTROL_STRUCTURE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH264RateControlStructureEXT; - -typedef enum VkVideoEncodeH264CapabilityFlagBitsEXT { - VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_ENABLED_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H264_CAPABILITY_DIRECT_8X8_INFERENCE_DISABLED_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H264_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H264_CAPABILITY_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_BIT_EXT = 0x00000008, - VK_VIDEO_ENCODE_H264_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000010, - VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020, - VK_VIDEO_ENCODE_H264_CAPABILITY_CHROMA_QP_OFFSET_BIT_EXT = 0x00000040, - VK_VIDEO_ENCODE_H264_CAPABILITY_SECOND_CHROMA_QP_OFFSET_BIT_EXT = 0x00000080, - VK_VIDEO_ENCODE_H264_CAPABILITY_PIC_INIT_QP_MINUS26_BIT_EXT = 0x00000100, - VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00000200, - VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_EXPLICIT_BIT_EXT = 0x00000400, - VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_BIPRED_IMPLICIT_BIT_EXT = 0x00000800, - VK_VIDEO_ENCODE_H264_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00001000, - VK_VIDEO_ENCODE_H264_CAPABILITY_TRANSFORM_8X8_BIT_EXT = 0x00002000, - VK_VIDEO_ENCODE_H264_CAPABILITY_CABAC_BIT_EXT = 0x00004000, - VK_VIDEO_ENCODE_H264_CAPABILITY_CAVLC_BIT_EXT = 0x00008000, - VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_DISABLED_BIT_EXT = 0x00010000, - VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_ENABLED_BIT_EXT = 0x00020000, - VK_VIDEO_ENCODE_H264_CAPABILITY_DEBLOCKING_FILTER_PARTIAL_BIT_EXT = 0x00040000, - VK_VIDEO_ENCODE_H264_CAPABILITY_DISABLE_DIRECT_SPATIAL_MV_PRED_BIT_EXT = 0x00080000, - VK_VIDEO_ENCODE_H264_CAPABILITY_MULTIPLE_SLICE_PER_FRAME_BIT_EXT = 0x00100000, - VK_VIDEO_ENCODE_H264_CAPABILITY_SLICE_MB_COUNT_BIT_EXT = 0x00200000, - VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_EXT = 0x00400000, - VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x00800000, - VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x01000000, - VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH264CapabilityFlagBitsEXT; -typedef VkFlags VkVideoEncodeH264CapabilityFlagsEXT; - -typedef enum VkVideoEncodeH264InputModeFlagBitsEXT { - VK_VIDEO_ENCODE_H264_INPUT_MODE_FRAME_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H264_INPUT_MODE_SLICE_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H264_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H264_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH264InputModeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH264InputModeFlagsEXT; - -typedef enum VkVideoEncodeH264OutputModeFlagBitsEXT { - VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H264_OUTPUT_MODE_SLICE_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H264_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H264_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH264OutputModeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH264OutputModeFlagsEXT; -typedef struct VkVideoEncodeH264CapabilitiesEXT { - VkStructureType sType; - void* pNext; - VkVideoEncodeH264CapabilityFlagsEXT flags; - VkVideoEncodeH264InputModeFlagsEXT inputModeFlags; - VkVideoEncodeH264OutputModeFlagsEXT outputModeFlags; - uint8_t maxPPictureL0ReferenceCount; - uint8_t maxBPictureL0ReferenceCount; - uint8_t maxL1ReferenceCount; - VkBool32 motionVectorsOverPicBoundariesFlag; - uint32_t maxBytesPerPicDenom; - uint32_t maxBitsPerMbDenom; - uint32_t log2MaxMvLengthHorizontal; - uint32_t log2MaxMvLengthVertical; -} VkVideoEncodeH264CapabilitiesEXT; - -typedef struct VkVideoEncodeH264SessionParametersAddInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t spsStdCount; - const StdVideoH264SequenceParameterSet* pSpsStd; - uint32_t ppsStdCount; - const StdVideoH264PictureParameterSet* pPpsStd; -} VkVideoEncodeH264SessionParametersAddInfoEXT; - -typedef struct VkVideoEncodeH264SessionParametersCreateInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t maxSpsStdCount; - uint32_t maxPpsStdCount; - const VkVideoEncodeH264SessionParametersAddInfoEXT* pParametersAddInfo; -} VkVideoEncodeH264SessionParametersCreateInfoEXT; - -typedef struct VkVideoEncodeH264DpbSlotInfoEXT { - VkStructureType sType; - const void* pNext; - int8_t slotIndex; - const StdVideoEncodeH264ReferenceInfo* pStdReferenceInfo; -} VkVideoEncodeH264DpbSlotInfoEXT; - -typedef struct VkVideoEncodeH264ReferenceListsInfoEXT { - VkStructureType sType; - const void* pNext; - uint8_t referenceList0EntryCount; - const VkVideoEncodeH264DpbSlotInfoEXT* pReferenceList0Entries; - uint8_t referenceList1EntryCount; - const VkVideoEncodeH264DpbSlotInfoEXT* pReferenceList1Entries; - const StdVideoEncodeH264RefMemMgmtCtrlOperations* pMemMgmtCtrlOperations; -} VkVideoEncodeH264ReferenceListsInfoEXT; - -typedef struct VkVideoEncodeH264NaluSliceInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t mbCount; - const VkVideoEncodeH264ReferenceListsInfoEXT* pReferenceFinalLists; - const StdVideoEncodeH264SliceHeader* pSliceHeaderStd; -} VkVideoEncodeH264NaluSliceInfoEXT; - -typedef struct VkVideoEncodeH264VclFrameInfoEXT { - VkStructureType sType; - const void* pNext; - const VkVideoEncodeH264ReferenceListsInfoEXT* pReferenceFinalLists; - uint32_t naluSliceEntryCount; - const VkVideoEncodeH264NaluSliceInfoEXT* pNaluSliceEntries; - const StdVideoEncodeH264PictureInfo* pCurrentPictureInfo; -} VkVideoEncodeH264VclFrameInfoEXT; - -typedef struct VkVideoEncodeH264EmitPictureParametersInfoEXT { +// VK_NV_displacement_micromap is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_displacement_micromap 1 +#define VK_NV_DISPLACEMENT_MICROMAP_SPEC_VERSION 2 +#define VK_NV_DISPLACEMENT_MICROMAP_EXTENSION_NAME "VK_NV_displacement_micromap" + +typedef enum VkDisplacementMicromapFormatNV { + VK_DISPLACEMENT_MICROMAP_FORMAT_64_TRIANGLES_64_BYTES_NV = 1, + VK_DISPLACEMENT_MICROMAP_FORMAT_256_TRIANGLES_128_BYTES_NV = 2, + VK_DISPLACEMENT_MICROMAP_FORMAT_1024_TRIANGLES_128_BYTES_NV = 3, + VK_DISPLACEMENT_MICROMAP_FORMAT_MAX_ENUM_NV = 0x7FFFFFFF +} VkDisplacementMicromapFormatNV; +typedef struct VkPhysicalDeviceDisplacementMicromapFeaturesNV { VkStructureType sType; - const void* pNext; - uint8_t spsId; - VkBool32 emitSpsEnable; - uint32_t ppsIdEntryCount; - const uint8_t* ppsIdEntries; -} VkVideoEncodeH264EmitPictureParametersInfoEXT; - -typedef struct VkVideoEncodeH264ProfileInfoEXT { - VkStructureType sType; - const void* pNext; - StdVideoH264ProfileIdc stdProfileIdc; -} VkVideoEncodeH264ProfileInfoEXT; - -typedef struct VkVideoEncodeH264RateControlInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t gopFrameCount; - uint32_t idrPeriod; - uint32_t consecutiveBFrameCount; - VkVideoEncodeH264RateControlStructureEXT rateControlStructure; - uint8_t temporalLayerCount; -} VkVideoEncodeH264RateControlInfoEXT; - -typedef struct VkVideoEncodeH264QpEXT { - int32_t qpI; - int32_t qpP; - int32_t qpB; -} VkVideoEncodeH264QpEXT; - -typedef struct VkVideoEncodeH264FrameSizeEXT { - uint32_t frameISize; - uint32_t framePSize; - uint32_t frameBSize; -} VkVideoEncodeH264FrameSizeEXT; - -typedef struct VkVideoEncodeH264RateControlLayerInfoEXT { - VkStructureType sType; - const void* pNext; - uint8_t temporalLayerId; - VkBool32 useInitialRcQp; - VkVideoEncodeH264QpEXT initialRcQp; - VkBool32 useMinQp; - VkVideoEncodeH264QpEXT minQp; - VkBool32 useMaxQp; - VkVideoEncodeH264QpEXT maxQp; - VkBool32 useMaxFrameSize; - VkVideoEncodeH264FrameSizeEXT maxFrameSize; -} VkVideoEncodeH264RateControlLayerInfoEXT; - - - -#define VK_EXT_video_encode_h265 1 -#include "vk_video/vulkan_video_codec_h265std.h" -#include "vk_video/vulkan_video_codec_h265std_encode.h" -#define VK_EXT_VIDEO_ENCODE_H265_SPEC_VERSION 8 -#define VK_EXT_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_EXT_video_encode_h265" - -typedef enum VkVideoEncodeH265RateControlStructureEXT { - VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_UNKNOWN_EXT = 0, - VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_FLAT_EXT = 1, - VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_DYADIC_EXT = 2, - VK_VIDEO_ENCODE_H265_RATE_CONTROL_STRUCTURE_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265RateControlStructureEXT; - -typedef enum VkVideoEncodeH265CapabilityFlagBitsEXT { - VK_VIDEO_ENCODE_H265_CAPABILITY_SEPARATE_COLOUR_PLANE_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H265_CAPABILITY_SCALING_LISTS_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H265_CAPABILITY_SAMPLE_ADAPTIVE_OFFSET_ENABLED_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H265_CAPABILITY_PCM_ENABLE_BIT_EXT = 0x00000008, - VK_VIDEO_ENCODE_H265_CAPABILITY_SPS_TEMPORAL_MVP_ENABLED_BIT_EXT = 0x00000010, - VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_EXT = 0x00000020, - VK_VIDEO_ENCODE_H265_CAPABILITY_INIT_QP_MINUS26_BIT_EXT = 0x00000040, - VK_VIDEO_ENCODE_H265_CAPABILITY_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_EXT = 0x00000080, - VK_VIDEO_ENCODE_H265_CAPABILITY_SIGN_DATA_HIDING_ENABLED_BIT_EXT = 0x00000100, - VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_ENABLED_BIT_EXT = 0x00000200, - VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSFORM_SKIP_DISABLED_BIT_EXT = 0x00000400, - VK_VIDEO_ENCODE_H265_CAPABILITY_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_BIT_EXT = 0x00000800, - VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_BIT_EXT = 0x00001000, - VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_BIPRED_BIT_EXT = 0x00002000, - VK_VIDEO_ENCODE_H265_CAPABILITY_WEIGHTED_PRED_NO_TABLE_BIT_EXT = 0x00004000, - VK_VIDEO_ENCODE_H265_CAPABILITY_TRANSQUANT_BYPASS_ENABLED_BIT_EXT = 0x00008000, - VK_VIDEO_ENCODE_H265_CAPABILITY_ENTROPY_CODING_SYNC_ENABLED_BIT_EXT = 0x00010000, - VK_VIDEO_ENCODE_H265_CAPABILITY_DEBLOCKING_FILTER_OVERRIDE_ENABLED_BIT_EXT = 0x00020000, - VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_FRAME_BIT_EXT = 0x00040000, - VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_PER_TILE_BIT_EXT = 0x00080000, - VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILE_PER_SLICE_BIT_EXT = 0x00100000, - VK_VIDEO_ENCODE_H265_CAPABILITY_SLICE_SEGMENT_CTB_COUNT_BIT_EXT = 0x00200000, - VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_EXT = 0x00400000, - VK_VIDEO_ENCODE_H265_CAPABILITY_DEPENDENT_SLICE_SEGMENT_BIT_EXT = 0x00800000, - VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_EXT = 0x01000000, - VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_EXT = 0x02000000, - VK_VIDEO_ENCODE_H265_CAPABILITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265CapabilityFlagBitsEXT; -typedef VkFlags VkVideoEncodeH265CapabilityFlagsEXT; - -typedef enum VkVideoEncodeH265InputModeFlagBitsEXT { - VK_VIDEO_ENCODE_H265_INPUT_MODE_FRAME_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H265_INPUT_MODE_SLICE_SEGMENT_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H265_INPUT_MODE_NON_VCL_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H265_INPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265InputModeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH265InputModeFlagsEXT; - -typedef enum VkVideoEncodeH265OutputModeFlagBitsEXT { - VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FRAME_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H265_OUTPUT_MODE_SLICE_SEGMENT_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H265_OUTPUT_MODE_NON_VCL_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H265_OUTPUT_MODE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265OutputModeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH265OutputModeFlagsEXT; - -typedef enum VkVideoEncodeH265CtbSizeFlagBitsEXT { - VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265CtbSizeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH265CtbSizeFlagsEXT; - -typedef enum VkVideoEncodeH265TransformBlockSizeFlagBitsEXT { - VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_EXT = 0x00000001, - VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_EXT = 0x00000002, - VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_EXT = 0x00000004, - VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_EXT = 0x00000008, - VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoEncodeH265TransformBlockSizeFlagBitsEXT; -typedef VkFlags VkVideoEncodeH265TransformBlockSizeFlagsEXT; -typedef struct VkVideoEncodeH265CapabilitiesEXT { - VkStructureType sType; - void* pNext; - VkVideoEncodeH265CapabilityFlagsEXT flags; - VkVideoEncodeH265InputModeFlagsEXT inputModeFlags; - VkVideoEncodeH265OutputModeFlagsEXT outputModeFlags; - VkVideoEncodeH265CtbSizeFlagsEXT ctbSizes; - VkVideoEncodeH265TransformBlockSizeFlagsEXT transformBlockSizes; - uint8_t maxPPictureL0ReferenceCount; - uint8_t maxBPictureL0ReferenceCount; - uint8_t maxL1ReferenceCount; - uint8_t maxSubLayersCount; - uint8_t minLog2MinLumaCodingBlockSizeMinus3; - uint8_t maxLog2MinLumaCodingBlockSizeMinus3; - uint8_t minLog2MinLumaTransformBlockSizeMinus2; - uint8_t maxLog2MinLumaTransformBlockSizeMinus2; - uint8_t minMaxTransformHierarchyDepthInter; - uint8_t maxMaxTransformHierarchyDepthInter; - uint8_t minMaxTransformHierarchyDepthIntra; - uint8_t maxMaxTransformHierarchyDepthIntra; - uint8_t maxDiffCuQpDeltaDepth; - uint8_t minMaxNumMergeCand; - uint8_t maxMaxNumMergeCand; -} VkVideoEncodeH265CapabilitiesEXT; - -typedef struct VkVideoEncodeH265SessionParametersAddInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t vpsStdCount; - const StdVideoH265VideoParameterSet* pVpsStd; - uint32_t spsStdCount; - const StdVideoH265SequenceParameterSet* pSpsStd; - uint32_t ppsStdCount; - const StdVideoH265PictureParameterSet* pPpsStd; -} VkVideoEncodeH265SessionParametersAddInfoEXT; - -typedef struct VkVideoEncodeH265SessionParametersCreateInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t maxVpsStdCount; - uint32_t maxSpsStdCount; - uint32_t maxPpsStdCount; - const VkVideoEncodeH265SessionParametersAddInfoEXT* pParametersAddInfo; -} VkVideoEncodeH265SessionParametersCreateInfoEXT; - -typedef struct VkVideoEncodeH265DpbSlotInfoEXT { - VkStructureType sType; - const void* pNext; - int8_t slotIndex; - const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo; -} VkVideoEncodeH265DpbSlotInfoEXT; - -typedef struct VkVideoEncodeH265ReferenceListsInfoEXT { - VkStructureType sType; - const void* pNext; - uint8_t referenceList0EntryCount; - const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList0Entries; - uint8_t referenceList1EntryCount; - const VkVideoEncodeH265DpbSlotInfoEXT* pReferenceList1Entries; - const StdVideoEncodeH265ReferenceModifications* pReferenceModifications; -} VkVideoEncodeH265ReferenceListsInfoEXT; - -typedef struct VkVideoEncodeH265NaluSliceSegmentInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t ctbCount; - const VkVideoEncodeH265ReferenceListsInfoEXT* pReferenceFinalLists; - const StdVideoEncodeH265SliceSegmentHeader* pSliceSegmentHeaderStd; -} VkVideoEncodeH265NaluSliceSegmentInfoEXT; - -typedef struct VkVideoEncodeH265VclFrameInfoEXT { - VkStructureType sType; - const void* pNext; - const VkVideoEncodeH265ReferenceListsInfoEXT* pReferenceFinalLists; - uint32_t naluSliceSegmentEntryCount; - const VkVideoEncodeH265NaluSliceSegmentInfoEXT* pNaluSliceSegmentEntries; - const StdVideoEncodeH265PictureInfo* pCurrentPictureInfo; -} VkVideoEncodeH265VclFrameInfoEXT; - -typedef struct VkVideoEncodeH265EmitPictureParametersInfoEXT { + void* pNext; + VkBool32 displacementMicromap; +} VkPhysicalDeviceDisplacementMicromapFeaturesNV; + +typedef struct VkPhysicalDeviceDisplacementMicromapPropertiesNV { VkStructureType sType; - const void* pNext; - uint8_t vpsId; - uint8_t spsId; - VkBool32 emitVpsEnable; - VkBool32 emitSpsEnable; - uint32_t ppsIdEntryCount; - const uint8_t* ppsIdEntries; -} VkVideoEncodeH265EmitPictureParametersInfoEXT; - -typedef struct VkVideoEncodeH265ProfileInfoEXT { - VkStructureType sType; - const void* pNext; - StdVideoH265ProfileIdc stdProfileIdc; -} VkVideoEncodeH265ProfileInfoEXT; - -typedef struct VkVideoEncodeH265RateControlInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t gopFrameCount; - uint32_t idrPeriod; - uint32_t consecutiveBFrameCount; - VkVideoEncodeH265RateControlStructureEXT rateControlStructure; - uint8_t subLayerCount; -} VkVideoEncodeH265RateControlInfoEXT; - -typedef struct VkVideoEncodeH265QpEXT { - int32_t qpI; - int32_t qpP; - int32_t qpB; -} VkVideoEncodeH265QpEXT; - -typedef struct VkVideoEncodeH265FrameSizeEXT { - uint32_t frameISize; - uint32_t framePSize; - uint32_t frameBSize; -} VkVideoEncodeH265FrameSizeEXT; - -typedef struct VkVideoEncodeH265RateControlLayerInfoEXT { - VkStructureType sType; - const void* pNext; - uint8_t temporalId; - VkBool32 useInitialRcQp; - VkVideoEncodeH265QpEXT initialRcQp; - VkBool32 useMinQp; - VkVideoEncodeH265QpEXT minQp; - VkBool32 useMaxQp; - VkVideoEncodeH265QpEXT maxQp; - VkBool32 useMaxFrameSize; - VkVideoEncodeH265FrameSizeEXT maxFrameSize; -} VkVideoEncodeH265RateControlLayerInfoEXT; - - - -#define VK_EXT_video_decode_h264 1 -#include "vk_video/vulkan_video_codec_h264std_decode.h" -#define VK_EXT_VIDEO_DECODE_H264_SPEC_VERSION 6 -#define VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME "VK_EXT_video_decode_h264" - -typedef enum VkVideoDecodeH264PictureLayoutFlagBitsEXT { - VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_EXT = 0, - VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_EXT = 0x00000001, - VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_EXT = 0x00000002, - VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkVideoDecodeH264PictureLayoutFlagBitsEXT; -typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsEXT; -typedef struct VkVideoDecodeH264ProfileInfoEXT { - VkStructureType sType; - const void* pNext; - StdVideoH264ProfileIdc stdProfileIdc; - VkVideoDecodeH264PictureLayoutFlagsEXT pictureLayout; -} VkVideoDecodeH264ProfileInfoEXT; - -typedef struct VkVideoDecodeH264CapabilitiesEXT { - VkStructureType sType; - void* pNext; - StdVideoH264Level maxLevel; - VkOffset2D fieldOffsetGranularity; -} VkVideoDecodeH264CapabilitiesEXT; - -typedef struct VkVideoDecodeH264SessionParametersAddInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t spsStdCount; - const StdVideoH264SequenceParameterSet* pSpsStd; - uint32_t ppsStdCount; - const StdVideoH264PictureParameterSet* pPpsStd; -} VkVideoDecodeH264SessionParametersAddInfoEXT; - -typedef struct VkVideoDecodeH264SessionParametersCreateInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t maxSpsStdCount; - uint32_t maxPpsStdCount; - const VkVideoDecodeH264SessionParametersAddInfoEXT* pParametersAddInfo; -} VkVideoDecodeH264SessionParametersCreateInfoEXT; - -typedef struct VkVideoDecodeH264PictureInfoEXT { - VkStructureType sType; - const void* pNext; - const StdVideoDecodeH264PictureInfo* pStdPictureInfo; - uint32_t slicesCount; - const uint32_t* pSlicesDataOffsets; -} VkVideoDecodeH264PictureInfoEXT; - -typedef struct VkVideoDecodeH264MvcInfoEXT { - VkStructureType sType; - const void* pNext; - const StdVideoDecodeH264Mvc* pStdMvc; -} VkVideoDecodeH264MvcInfoEXT; - -typedef struct VkVideoDecodeH264DpbSlotInfoEXT { - VkStructureType sType; - const void* pNext; - const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo; -} VkVideoDecodeH264DpbSlotInfoEXT; - - - -#define VK_EXT_video_decode_h265 1 -#include "vk_video/vulkan_video_codec_h265std_decode.h" -#define VK_EXT_VIDEO_DECODE_H265_SPEC_VERSION 4 -#define VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME "VK_EXT_video_decode_h265" -typedef struct VkVideoDecodeH265ProfileInfoEXT { - VkStructureType sType; - const void* pNext; - StdVideoH265ProfileIdc stdProfileIdc; -} VkVideoDecodeH265ProfileInfoEXT; - -typedef struct VkVideoDecodeH265CapabilitiesEXT { - VkStructureType sType; - void* pNext; - StdVideoH265Level maxLevel; -} VkVideoDecodeH265CapabilitiesEXT; - -typedef struct VkVideoDecodeH265SessionParametersAddInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t vpsStdCount; - const StdVideoH265VideoParameterSet* pVpsStd; - uint32_t spsStdCount; - const StdVideoH265SequenceParameterSet* pSpsStd; - uint32_t ppsStdCount; - const StdVideoH265PictureParameterSet* pPpsStd; -} VkVideoDecodeH265SessionParametersAddInfoEXT; - -typedef struct VkVideoDecodeH265SessionParametersCreateInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t maxVpsStdCount; - uint32_t maxSpsStdCount; - uint32_t maxPpsStdCount; - const VkVideoDecodeH265SessionParametersAddInfoEXT* pParametersAddInfo; -} VkVideoDecodeH265SessionParametersCreateInfoEXT; - -typedef struct VkVideoDecodeH265PictureInfoEXT { - VkStructureType sType; - const void* pNext; - StdVideoDecodeH265PictureInfo* pStdPictureInfo; - uint32_t slicesCount; - const uint32_t* pSlicesDataOffsets; -} VkVideoDecodeH265PictureInfoEXT; - -typedef struct VkVideoDecodeH265DpbSlotInfoEXT { - VkStructureType sType; - const void* pNext; - const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo; -} VkVideoDecodeH265DpbSlotInfoEXT; + void* pNext; + uint32_t maxDisplacementMicromapSubdivisionLevel; +} VkPhysicalDeviceDisplacementMicromapPropertiesNV; + +typedef struct VkAccelerationStructureTrianglesDisplacementMicromapNV { + VkStructureType sType; + void* pNext; + VkFormat displacementBiasAndScaleFormat; + VkFormat displacementVectorFormat; + VkDeviceOrHostAddressConstKHR displacementBiasAndScaleBuffer; + VkDeviceSize displacementBiasAndScaleStride; + VkDeviceOrHostAddressConstKHR displacementVectorBuffer; + VkDeviceSize displacementVectorStride; + VkDeviceOrHostAddressConstKHR displacedMicromapPrimitiveFlags; + VkDeviceSize displacedMicromapPrimitiveFlagsStride; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexBuffer; + VkDeviceSize indexStride; + uint32_t baseTriangle; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkMicromapEXT micromap; +} VkAccelerationStructureTrianglesDisplacementMicromapNV; #ifdef __cplusplus diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_core.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_core.h index 00f32b3353..5354f61dc9 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_core.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_core.h @@ -2,7 +2,7 @@ #define VULKAN_CORE_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_VERSION_1_0 is a preprocessor guard. Do not pass it to API calls. #define VK_VERSION_1_0 1 #include "vk_platform.h" @@ -26,7 +27,7 @@ extern "C" { #ifndef VK_USE_64_BIT_PTR_DEFINES - #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64) #define VK_USE_64_BIT_PTR_DEFINES 1 #else #define VK_USE_64_BIT_PTR_DEFINES 0 @@ -58,37 +59,37 @@ extern "C" { #endif #endif -// DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. -#define VK_MAKE_VERSION(major, minor, patch) \ - ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) +#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ + ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) // DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. -//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0 - -#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ - ((((uint32_t)(variant)) << 29) | (((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) +//#define VK_API_VERSION VK_MAKE_API_VERSION(0, 1, 0, 0) // Patch version should always be set to 0 // Vulkan 1.0 version number #define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0 // Version of this file -#define VK_HEADER_VERSION 227 +#define VK_HEADER_VERSION 275 // Complete version of this file #define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION) +// DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. +#define VK_MAKE_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + // DEPRECATED: This define is deprecated. VK_API_VERSION_MAJOR should be used instead. -#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22) +#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22U) // DEPRECATED: This define is deprecated. VK_API_VERSION_MINOR should be used instead. -#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU) +#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) // DEPRECATED: This define is deprecated. VK_API_VERSION_PATCH should be used instead. #define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) -#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29) -#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22) & 0x7FU) -#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3FFU) +#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29U) +#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22U) & 0x7FU) +#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) #define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) typedef uint32_t VkBool32; typedef uint64_t VkDeviceAddress; @@ -168,24 +169,12 @@ typedef enum VkResult { VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, VK_ERROR_INVALID_SHADER_NV = -1000012000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR = -1000023000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR = -1000023001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR = -1000023002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR = -1000023003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR = -1000023004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR = -1000023005, -#endif VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, VK_ERROR_NOT_PERMITTED_KHR = -1000174001, VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, @@ -193,7 +182,9 @@ typedef enum VkResult { VK_THREAD_DONE_KHR = 1000268001, VK_OPERATION_DEFERRED_KHR = 1000268002, VK_OPERATION_NOT_DEFERRED_KHR = 1000268003, + VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR = -1000299000, VK_ERROR_COMPRESSION_EXHAUSTED_EXT = -1000338000, + VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT = 1000482000, VK_ERROR_OUT_OF_POOL_MEMORY_KHR = VK_ERROR_OUT_OF_POOL_MEMORY, VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR = VK_ERROR_INVALID_EXTERNAL_HANDLE, VK_ERROR_FRAGMENTATION_EXT = VK_ERROR_FRAGMENTATION, @@ -443,66 +434,26 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR = 1000023000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR = 1000023001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR = 1000023002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR = 1000023003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR = 1000023004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR = 1000023005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR = 1000023008, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR = 1000023009, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR = 1000023010, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR = 1000023011, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR = 1000023012, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR = 1000023013, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR = 1000023015, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR = 1000023016, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR = 1000024000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR = 1000024001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR = 1000024002, -#endif VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, @@ -514,93 +465,40 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_CU_LAUNCH_INFO_NVX = 1000029002, VK_STRUCTURE_TYPE_IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000, VK_STRUCTURE_TYPE_IMAGE_VIEW_ADDRESS_PROPERTIES_NVX = 1000030001, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_EXT = 1000038000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000038001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000038002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_VCL_FRAME_INFO_EXT = 1000038003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_EXT = 1000038004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_EXT = 1000038005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_EMIT_PICTURE_PARAMETERS_INFO_EXT = 1000038006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_EXT = 1000038007, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_EXT = 1000038008, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_EXT = 1000038009, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_REFERENCE_LISTS_INFO_EXT = 1000038010, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_EXT = 1000039000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000039001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000039002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_VCL_FRAME_INFO_EXT = 1000039003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_DPB_SLOT_INFO_EXT = 1000039004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_EXT = 1000039005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_EMIT_PICTURE_PARAMETERS_INFO_EXT = 1000039006, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_EXT = 1000039007, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_REFERENCE_LISTS_INFO_EXT = 1000039008, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_INFO_EXT = 1000039009, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_EXT = 1000039010, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_EXT = 1000040000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_EXT = 1000040001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_MVC_INFO_EXT = 1000040002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_EXT = 1000040003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000040004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_EXT = 1000040005, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_EXT = 1000040006, -#endif + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_KHR = 1000038000, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000038001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000038002, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PICTURE_INFO_KHR = 1000038003, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_KHR = 1000038004, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_KHR = 1000038005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_GOP_REMAINING_FRAME_INFO_KHR = 1000038006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_KHR = 1000038007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_KHR = 1000038008, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_KHR = 1000038009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_CREATE_INFO_KHR = 1000038010, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_QUALITY_LEVEL_PROPERTIES_KHR = 1000038011, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_GET_INFO_KHR = 1000038012, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000038013, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_KHR = 1000039000, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000039001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000039002, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PICTURE_INFO_KHR = 1000039003, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_DPB_SLOT_INFO_KHR = 1000039004, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_KHR = 1000039005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_GOP_REMAINING_FRAME_INFO_KHR = 1000039006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_KHR = 1000039007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_INFO_KHR = 1000039009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_KHR = 1000039010, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_CREATE_INFO_KHR = 1000039011, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_QUALITY_LEVEL_PROPERTIES_KHR = 1000039012, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_GET_INFO_KHR = 1000039013, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000039014, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR = 1000040000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR = 1000040001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR = 1000040003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000040004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000040005, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_KHR = 1000040006, VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000044006, VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT = 1000044007, @@ -655,6 +553,7 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000, VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001, VK_STRUCTURE_TYPE_HDR_METADATA_EXT = 1000105000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RELAXED_LINE_RASTERIZATION_FEATURES_IMG = 1000110000, VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, VK_STRUCTURE_TYPE_IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000, VK_STRUCTURE_TYPE_EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001, @@ -690,6 +589,21 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004, VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID = 1000129005, VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID = 1000129006, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ENQUEUE_FEATURES_AMDX = 1000134000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ENQUEUE_PROPERTIES_AMDX = 1000134001, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_EXECUTION_GRAPH_PIPELINE_SCRATCH_SIZE_AMDX = 1000134002, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_EXECUTION_GRAPH_PIPELINE_CREATE_INFO_AMDX = 1000134003, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NODE_CREATE_INFO_AMDX = 1000134004, +#endif VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT = 1000143000, VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001, VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002, @@ -761,33 +675,18 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000, VK_STRUCTURE_TYPE_PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, - VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT = 1000184000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_EXT = 1000187000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_EXT = 1000187001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_EXT = 1000187002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_EXT = 1000187003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_EXT = 1000187004, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_EXT = 1000187005, -#endif + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR = 1000187000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000187001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000187002, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR = 1000187003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR = 1000187004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR = 1000187005, VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR = 1000388000, VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR = 1000388001, VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000, - VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = 1000190001, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = 1000190002, VK_STRUCTURE_TYPE_PRESENT_FRAME_TOKEN_GGP = 1000191000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, @@ -856,7 +755,28 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT = 1000270000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT = 1000270001, + VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY_EXT = 1000270002, + VK_STRUCTURE_TYPE_IMAGE_TO_MEMORY_COPY_EXT = 1000270003, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_MEMORY_INFO_EXT = 1000270004, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO_EXT = 1000270005, + VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO_EXT = 1000270006, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_IMAGE_INFO_EXT = 1000270007, + VK_STRUCTURE_TYPE_SUBRESOURCE_HOST_MEMCPY_SIZE_EXT = 1000270008, + VK_STRUCTURE_TYPE_HOST_IMAGE_COPY_DEVICE_PERFORMANCE_QUERY_EXT = 1000270009, + VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR = 1000271000, + VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR = 1000271001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT = 1000273000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT = 1000274000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT = 1000274001, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT = 1000274002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT = 1000275000, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_EXT = 1000275001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT = 1000275002, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT = 1000275003, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_SCALING_CREATE_INFO_EXT = 1000275004, + VK_STRUCTURE_TYPE_RELEASE_SWAPCHAIN_IMAGES_INFO_EXT = 1000275005, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_PROPERTIES_NV = 1000277000, VK_STRUCTURE_TYPE_GRAPHICS_SHADER_GROUP_CREATE_INFO_NV = 1000277001, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_SHADER_GROUPS_CREATE_INFO_NV = 1000277002, @@ -870,6 +790,9 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDER_PASS_TRANSFORM_INFO_QCOM = 1000282000, VK_STRUCTURE_TYPE_RENDER_PASS_TRANSFORM_BEGIN_INFO_QCOM = 1000282001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_BIAS_CONTROL_FEATURES_EXT = 1000283000, + VK_STRUCTURE_TYPE_DEPTH_BIAS_INFO_EXT = 1000283001, + VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT = 1000283002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT = 1000284000, VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT = 1000284001, VK_STRUCTURE_TYPE_DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT = 1000284002, @@ -879,25 +802,30 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002, VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV = 1000292000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_BARRIER_NV = 1000292001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV = 1000292002, VK_STRUCTURE_TYPE_PRESENT_ID_KHR = 1000294000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_INFO_KHR = 1000299000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR = 1000299001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_LAYER_INFO_KHR = 1000299002, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_STRUCTURE_TYPE_VIDEO_ENCODE_USAGE_INFO_KHR = 1000299004, -#endif + VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR = 1000299005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR = 1000299006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_PROPERTIES_KHR = 1000299007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR = 1000299008, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_GET_INFO_KHR = 1000299009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000299010, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000, VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001, + VK_STRUCTURE_TYPE_CUDA_MODULE_CREATE_INFO_NV = 1000307000, + VK_STRUCTURE_TYPE_CUDA_FUNCTION_CREATE_INFO_NV = 1000307001, + VK_STRUCTURE_TYPE_CUDA_LAUNCH_INFO_NV = 1000307002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUDA_KERNEL_LAUNCH_FEATURES_NV = 1000307003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUDA_KERNEL_LAUNCH_PROPERTIES_NV = 1000307004, + VK_STRUCTURE_TYPE_QUERY_LOW_LATENCY_SUPPORT_NV = 1000310000, VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT = 1000311000, VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECTS_INFO_EXT = 1000311001, VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT = 1000311002, @@ -912,6 +840,19 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_IMPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311011, VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV = 1000314008, VK_STRUCTURE_TYPE_CHECKPOINT_DATA_2_NV = 1000314009, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT = 1000316000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_DENSITY_MAP_PROPERTIES_EXT = 1000316001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT = 1000316002, + VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT = 1000316003, + VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT = 1000316004, + VK_STRUCTURE_TYPE_BUFFER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316005, + VK_STRUCTURE_TYPE_IMAGE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316006, + VK_STRUCTURE_TYPE_IMAGE_VIEW_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316007, + VK_STRUCTURE_TYPE_SAMPLER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316008, + VK_STRUCTURE_TYPE_OPAQUE_CAPTURE_DESCRIPTOR_DATA_CREATE_INFO_EXT = 1000316010, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT = 1000316011, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_PUSH_DESCRIPTOR_BUFFER_HANDLE_EXT = 1000316012, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316009, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT = 1000320000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT = 1000320001, VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT = 1000320002, @@ -934,19 +875,20 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR = 1000336000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT = 1000338000, VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT = 1000338001, - VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT = 1000338002, - VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT = 1000338003, VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT = 1000338004, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT = 1000339000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT = 1000341000, + VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT = 1000341001, + VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT = 1000341002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000, VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000, - VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = 1000351000, - VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = 1000351002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000, VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001, VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT = 1000354000, + VK_STRUCTURE_TYPE_DEVICE_ADDRESS_BINDING_CALLBACK_DATA_EXT = 1000354001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000, VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000, @@ -973,6 +915,8 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV = 1000371001, VK_STRUCTURE_TYPE_PIPELINE_PROPERTIES_IDENTIFIER_EXT = 1000372000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROPERTIES_FEATURES_EXT = 1000372001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAME_BOUNDARY_FEATURES_EXT = 1000375000, + VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT = 1000375001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT = 1000376000, VK_STRUCTURE_TYPE_SUBPASS_RESOLVE_PERFORMANCE_QUERY_EXT = 1000376001, VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_EXT = 1000376002, @@ -987,36 +931,167 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT = 1000395000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT = 1000395001, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_INFO_EXT = 1000396000, + VK_STRUCTURE_TYPE_MICROMAP_VERSION_INFO_EXT = 1000396001, + VK_STRUCTURE_TYPE_COPY_MICROMAP_INFO_EXT = 1000396002, + VK_STRUCTURE_TYPE_COPY_MICROMAP_TO_MEMORY_INFO_EXT = 1000396003, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_MICROMAP_INFO_EXT = 1000396004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT = 1000396005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_PROPERTIES_EXT = 1000396006, + VK_STRUCTURE_TYPE_MICROMAP_CREATE_INFO_EXT = 1000396007, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_SIZES_INFO_EXT = 1000396008, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT = 1000396009, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV = 1000397000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV = 1000397001, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV = 1000397002, +#endif + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI = 1000404000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI = 1000404001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_VRS_FEATURES_HUAWEI = 1000404002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000, VK_STRUCTURE_TYPE_SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM = 1000415000, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_SHADER_CORE_CONTROL_CREATE_INFO_ARM = 1000417000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_FEATURES_ARM = 1000417001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_PROPERTIES_ARM = 1000417002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT = 1000418000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_SLICED_CREATE_INFO_EXT = 1000418001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001, VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT = 1000421000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT = 1000422000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RENDER_PASS_STRIPED_FEATURES_ARM = 1000424000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RENDER_PASS_STRIPED_PROPERTIES_ARM = 1000424001, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_BEGIN_INFO_ARM = 1000424002, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_INFO_ARM = 1000424003, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_SUBMIT_INFO_ARM = 1000424004, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001, VK_STRUCTURE_TYPE_SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM = 1000425002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_FEATURES_NV = 1000426000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_PROPERTIES_NV = 1000426001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV = 1000427000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_PROPERTIES_NV = 1000427001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_COMPUTE_FEATURES_NV = 1000428000, + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_INDIRECT_BUFFER_INFO_NV = 1000428001, + VK_STRUCTURE_TYPE_PIPELINE_INDIRECT_DEVICE_ADDRESS_INFO_NV = 1000428002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV = 1000430000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT = 1000437000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM = 1000440000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_PROPERTIES_QCOM = 1000440001, VK_STRUCTURE_TYPE_IMAGE_VIEW_SAMPLE_WEIGHT_CREATE_INFO_QCOM = 1000440002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NESTED_COMMAND_BUFFER_FEATURES_EXT = 1000451000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NESTED_COMMAND_BUFFER_PROPERTIES_EXT = 1000451001, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXT = 1000453000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT = 1000455000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT = 1000455001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT = 1000458000, VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_CONTROL_EXT = 1000458001, VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000458002, VK_STRUCTURE_TYPE_RENDER_PASS_SUBPASS_FEEDBACK_CREATE_INFO_EXT = 1000458003, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_INFO_LUNARG = 1000459000, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG = 1000459001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT = 1000462000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT = 1000462001, VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT = 1000462002, VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT = 1000462003, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT = 1000342000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV = 1000464000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV = 1000464001, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV = 1000464002, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV = 1000464003, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_INFO_NV = 1000464004, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV = 1000464005, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV = 1000464010, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT = 1000465000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT = 1000466000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_FEATURES_ANDROID = 1000468000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_PROPERTIES_ANDROID = 1000468001, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_RESOLVE_PROPERTIES_ANDROID = 1000468002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR = 1000470000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR = 1000470001, + VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR = 1000470003, + VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR = 1000470004, + VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR = 1000338002, + VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR = 1000338003, + VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR = 1000470005, + VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR = 1000470006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR = 1000481000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT = 1000482000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT = 1000482001, + VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT = 1000482002, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM = 1000484000, VK_STRUCTURE_TYPE_TILE_PROPERTIES_QCOM = 1000484001, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC = 1000485000, VK_STRUCTURE_TYPE_AMIGO_PROFILING_SUBMIT_INFO_SEC = 1000485001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_VIEWPORTS_FEATURES_QCOM = 1000488000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV = 1000490000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_PROPERTIES_NV = 1000490001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_SPARSE_ADDRESS_SPACE_FEATURES_NV = 1000492000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_SPARSE_ADDRESS_SPACE_PROPERTIES_NV = 1000492001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT = 1000351000, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT = 1000351002, + VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT = 1000496000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM = 1000497000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM = 1000497001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT = 1000498000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_FEATURES_EXT = 1000499000, + VK_STRUCTURE_TYPE_LATENCY_SLEEP_MODE_INFO_NV = 1000505000, + VK_STRUCTURE_TYPE_LATENCY_SLEEP_INFO_NV = 1000505001, + VK_STRUCTURE_TYPE_SET_LATENCY_MARKER_INFO_NV = 1000505002, + VK_STRUCTURE_TYPE_GET_LATENCY_MARKER_INFO_NV = 1000505003, + VK_STRUCTURE_TYPE_LATENCY_TIMINGS_FRAME_REPORT_NV = 1000505004, + VK_STRUCTURE_TYPE_LATENCY_SUBMISSION_PRESENT_ID_NV = 1000505005, + VK_STRUCTURE_TYPE_OUT_OF_BAND_QUEUE_TYPE_INFO_NV = 1000505006, + VK_STRUCTURE_TYPE_SWAPCHAIN_LATENCY_CREATE_INFO_NV = 1000505007, + VK_STRUCTURE_TYPE_LATENCY_SURFACE_CAPABILITIES_NV = 1000505008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR = 1000506000, + VK_STRUCTURE_TYPE_COOPERATIVE_MATRIX_PROPERTIES_KHR = 1000506001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR = 1000506002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM = 1000510000, + VK_STRUCTURE_TYPE_MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM = 1000510001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR = 1000515000, + VK_STRUCTURE_TYPE_VIDEO_INLINE_QUERY_INFO_KHR = 1000515001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PER_STAGE_DESCRIPTOR_SET_FEATURES_NV = 1000516000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_2_FEATURES_QCOM = 1000518000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_2_PROPERTIES_QCOM = 1000518001, + VK_STRUCTURE_TYPE_SAMPLER_BLOCK_MATCH_WINDOW_CREATE_INFO_QCOM = 1000518002, + VK_STRUCTURE_TYPE_SAMPLER_CUBIC_WEIGHTS_CREATE_INFO_QCOM = 1000519000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_WEIGHTS_FEATURES_QCOM = 1000519001, + VK_STRUCTURE_TYPE_BLIT_IMAGE_CUBIC_WEIGHTS_INFO_QCOM = 1000519002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_DEGAMMA_FEATURES_QCOM = 1000520000, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_YCBCR_DEGAMMA_CREATE_INFO_QCOM = 1000520001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM = 1000521000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT = 1000524000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_KHR = 1000525000, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_KHR = 1000190001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_KHR = 1000190002, + VK_STRUCTURE_TYPE_SCREEN_BUFFER_PROPERTIES_QNX = 1000529000, + VK_STRUCTURE_TYPE_SCREEN_BUFFER_FORMAT_PROPERTIES_QNX = 1000529001, + VK_STRUCTURE_TYPE_IMPORT_SCREEN_BUFFER_INFO_QNX = 1000529002, + VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_QNX = 1000529003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_SCREEN_BUFFER_FEATURES_QNX = 1000529004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_DRIVER_PROPERTIES_MSFT = 1000530000, + VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_KHR = 1000184000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_FEATURES_KHR = 1000545000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_PROPERTIES_KHR = 1000545001, + VK_STRUCTURE_TYPE_BIND_MEMORY_STATUS_KHR = 1000545002, + VK_STRUCTURE_TYPE_BIND_DESCRIPTOR_SETS_INFO_KHR = 1000545003, + VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR = 1000545004, + VK_STRUCTURE_TYPE_PUSH_DESCRIPTOR_SET_INFO_KHR = 1000545005, + VK_STRUCTURE_TYPE_PUSH_DESCRIPTOR_SET_WITH_TEMPLATE_INFO_KHR = 1000545006, + VK_STRUCTURE_TYPE_SET_DESCRIPTOR_BUFFER_OFFSETS_INFO_EXT = 1000545007, + VK_STRUCTURE_TYPE_BIND_DESCRIPTOR_BUFFER_EMBEDDED_SAMPLERS_INFO_EXT = 1000545008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_POOL_OVERALLOCATION_FEATURES_NV = 1000546000, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, @@ -1117,6 +1192,9 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, + VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_KHR, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_KHR, VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, @@ -1179,7 +1257,11 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_IMAGE_BLIT_2_KHR = VK_STRUCTURE_TYPE_IMAGE_BLIT_2, VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2_KHR = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2, VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR = VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2, + VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT = VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR, + VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT = VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT, VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3, VK_STRUCTURE_TYPE_PIPELINE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, @@ -1188,6 +1270,7 @@ typedef enum VkStructureType { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES, VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS, VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS, + VK_STRUCTURE_TYPE_SHADER_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF } VkStructureType; @@ -1215,27 +1298,15 @@ typedef enum VkImageLayout { VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL = 1000314000, VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL = 1000314001, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR = 1000024000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_SRC_KHR = 1000024001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR = 1000024002, -#endif VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000, VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_ENCODE_DST_KHR = 1000299000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR = 1000299001, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR = 1000299002, -#endif VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT = 1000339000, VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, @@ -1284,12 +1355,8 @@ typedef enum VkObjectType { VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000, VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001, VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_OBJECT_TYPE_VIDEO_SESSION_KHR = 1000023000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR = 1000023001, -#endif VK_OBJECT_TYPE_CU_MODULE_NVX = 1000029000, VK_OBJECT_TYPE_CU_FUNCTION_NVX = 1000029001, VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT = 1000128000, @@ -1299,7 +1366,12 @@ typedef enum VkObjectType { VK_OBJECT_TYPE_PERFORMANCE_CONFIGURATION_INTEL = 1000210000, VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR = 1000268000, VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV = 1000277000, + VK_OBJECT_TYPE_CUDA_MODULE_NV = 1000307000, + VK_OBJECT_TYPE_CUDA_FUNCTION_NV = 1000307001, VK_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA = 1000366000, + VK_OBJECT_TYPE_MICROMAP_EXT = 1000396000, + VK_OBJECT_TYPE_OPTICAL_FLOW_SESSION_NV = 1000464000, + VK_OBJECT_TYPE_SHADER_EXT = 1000482000, VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE, VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR = VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION, VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT = VK_OBJECT_TYPE_PRIVATE_DATA_SLOT, @@ -1313,6 +1385,7 @@ typedef enum VkVendorId { VK_VENDOR_ID_CODEPLAY = 0x10004, VK_VENDOR_ID_MESA = 0x10005, VK_VENDOR_ID_POCL = 0x10006, + VK_VENDOR_ID_MOBILEYE = 0x10007, VK_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF } VkVendorId; @@ -1578,6 +1651,9 @@ typedef enum VkFormat { VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, + VK_FORMAT_R16G16_S10_5_NV = 1000464000, + VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR = 1000470000, + VK_FORMAT_A8_UNORM_KHR = 1000470001, VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK, VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK, VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK, @@ -1662,22 +1738,20 @@ typedef enum VkQueryType { VK_QUERY_TYPE_OCCLUSION = 0, VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, VK_QUERY_TYPE_TIMESTAMP = 2, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR = 1000023000, -#endif VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR = 1000116000, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR = 1000150000, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR = 1000150001, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL = 1000210000, -#ifdef VK_ENABLE_BETA_EXTENSIONS - VK_QUERY_TYPE_VIDEO_ENCODE_BITSTREAM_BUFFER_RANGE_KHR = 1000299000, -#endif + VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR = 1000299000, VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT = 1000328000, VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT = 1000382000, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR = 1000386000, VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR = 1000386001, + VK_QUERY_TYPE_MICROMAP_SERIALIZATION_SIZE_EXT = 1000396000, + VK_QUERY_TYPE_MICROMAP_COMPACTED_SIZE_EXT = 1000396001, VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF } VkQueryType; @@ -1826,10 +1900,13 @@ typedef enum VkDynamicState { VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE = 1000377004, VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000, VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_ENABLE_EXT = 1000099001, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_MODE_EXT = 1000099002, VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT = 1000143000, VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000, VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, + VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV = 1000205000, VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV = 1000205001, VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR = 1000226000, VK_DYNAMIC_STATE_LINE_STIPPLE_EXT = 1000259000, @@ -1837,6 +1914,38 @@ typedef enum VkDynamicState { VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT = 1000377000, VK_DYNAMIC_STATE_LOGIC_OP_EXT = 1000377003, VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT = 1000381000, + VK_DYNAMIC_STATE_TESSELLATION_DOMAIN_ORIGIN_EXT = 1000455002, + VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT = 1000455003, + VK_DYNAMIC_STATE_POLYGON_MODE_EXT = 1000455004, + VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT = 1000455005, + VK_DYNAMIC_STATE_SAMPLE_MASK_EXT = 1000455006, + VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT = 1000455007, + VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT = 1000455008, + VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT = 1000455009, + VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT = 1000455010, + VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT = 1000455011, + VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT = 1000455012, + VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT = 1000455013, + VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT = 1000455014, + VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT = 1000455015, + VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT = 1000455016, + VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT = 1000455017, + VK_DYNAMIC_STATE_COLOR_BLEND_ADVANCED_EXT = 1000455018, + VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT = 1000455019, + VK_DYNAMIC_STATE_LINE_RASTERIZATION_MODE_EXT = 1000455020, + VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT = 1000455021, + VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT = 1000455022, + VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_ENABLE_NV = 1000455023, + VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV = 1000455024, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_ENABLE_NV = 1000455025, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_LOCATION_NV = 1000455026, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV = 1000455027, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_ENABLE_NV = 1000455028, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_NV = 1000455029, + VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV = 1000455030, + VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV = 1000455031, + VK_DYNAMIC_STATE_COVERAGE_REDUCTION_MODE_NV = 1000455032, + VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT = 1000524000, VK_DYNAMIC_STATE_CULL_MODE_EXT = VK_DYNAMIC_STATE_CULL_MODE, VK_DYNAMIC_STATE_FRONT_FACE_EXT = VK_DYNAMIC_STATE_FRONT_FACE, VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT = VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, @@ -1973,10 +2082,11 @@ typedef enum VkDescriptorType { VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK = 1000138000, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, - VK_DESCRIPTOR_TYPE_MUTABLE_VALVE = 1000351000, VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM = 1000440000, VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM = 1000440001, + VK_DESCRIPTOR_TYPE_MUTABLE_EXT = 1000351000, VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK, + VK_DESCRIPTOR_TYPE_MUTABLE_VALVE = VK_DESCRIPTOR_TYPE_MUTABLE_EXT, VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF } VkDescriptorType; @@ -2001,6 +2111,9 @@ typedef enum VkAttachmentStoreOp { typedef enum VkPipelineBindPoint { VK_PIPELINE_BIND_POINT_GRAPHICS = 0, VK_PIPELINE_BIND_POINT_COMPUTE = 1, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_PIPELINE_BIND_POINT_EXECUTION_GRAPH_AMDX = 1000134000, +#endif VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR = 1000165000, VK_PIPELINE_BIND_POINT_SUBPASS_SHADING_HUAWEI = 1000369003, VK_PIPELINE_BIND_POINT_RAY_TRACING_NV = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, @@ -2025,6 +2138,7 @@ typedef enum VkIndexType { typedef enum VkSubpassContents { VK_SUBPASS_CONTENTS_INLINE = 0, VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1, + VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT = 1000451000, VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF } VkSubpassContents; @@ -2111,22 +2225,14 @@ typedef enum VkFormatFeatureFlagBits { VK_FORMAT_FEATURE_DISJOINT_BIT = 0x00400000, VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 0x00800000, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 0x00010000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000, -#endif VK_FORMAT_FEATURE_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = 0x00002000, VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000, VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_ENCODE_INPUT_BIT_KHR = 0x08000000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_FORMAT_FEATURE_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000, -#endif VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT, VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT, VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_DST_BIT, @@ -2158,9 +2264,11 @@ typedef enum VkImageCreateFlagBits { VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV = 0x00002000, VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT = 0x00001000, VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT = 0x00004000, + VK_IMAGE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00010000, VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT = 0x00040000, VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT = 0x00020000, VK_IMAGE_CREATE_FRAGMENT_DENSITY_MAP_OFFSET_BIT_QCOM = 0x00008000, + VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR = 0x00100000, VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT, VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT, VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT, @@ -2192,26 +2300,15 @@ typedef enum VkImageUsageFlagBits { VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00000400, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00000800, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR = 0x00001000, -#endif VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200, VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00000100, -#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT = 0x00400000, VK_IMAGE_USAGE_VIDEO_ENCODE_DST_BIT_KHR = 0x00002000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR = 0x00004000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR = 0x00008000, -#endif VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x00080000, VK_IMAGE_USAGE_INVOCATION_MASK_BIT_HUAWEI = 0x00040000, VK_IMAGE_USAGE_SAMPLE_WEIGHT_BIT_QCOM = 0x00100000, @@ -2255,12 +2352,9 @@ typedef enum VkQueueFlagBits { VK_QUEUE_TRANSFER_BIT = 0x00000004, VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008, VK_QUEUE_PROTECTED_BIT = 0x00000010, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUEUE_VIDEO_DECODE_BIT_KHR = 0x00000020, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUEUE_VIDEO_ENCODE_BIT_KHR = 0x00000040, -#endif + VK_QUEUE_OPTICAL_FLOW_BIT_NV = 0x00000100, VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueueFlagBits; typedef VkFlags VkQueueFlags; @@ -2353,6 +2447,7 @@ typedef enum VkQueryPipelineStatisticFlagBits { VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, VK_QUERY_PIPELINE_STATISTIC_TASK_SHADER_INVOCATIONS_BIT_EXT = 0x00000800, VK_QUERY_PIPELINE_STATISTIC_MESH_SHADER_INVOCATIONS_BIT_EXT = 0x00001000, + VK_QUERY_PIPELINE_STATISTIC_CLUSTER_CULLING_SHADER_INVOCATIONS_BIT_HUAWEI = 0x00002000, VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueryPipelineStatisticFlagBits; typedef VkFlags VkQueryPipelineStatisticFlags; @@ -2363,9 +2458,7 @@ typedef enum VkQueryResultFlagBits { VK_QUERY_RESULT_WAIT_BIT = 0x00000002, VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_QUERY_RESULT_WITH_STATUS_BIT_KHR = 0x00000010, -#endif VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkQueryResultFlagBits; typedef VkFlags VkQueryResultFlags; @@ -2376,6 +2469,8 @@ typedef enum VkBufferCreateFlagBits { VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, VK_BUFFER_CREATE_PROTECTED_BIT = 0x00000008, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000010, + VK_BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000020, + VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR = 0x00000040, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF @@ -2393,24 +2488,24 @@ typedef enum VkBufferUsageFlagBits { VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT = 0x00020000, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00002000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00004000, -#endif VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800, VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000, VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_BUFFER_USAGE_EXECUTION_GRAPH_SCRATCH_BIT_AMDX = 0x02000000, +#endif VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR = 0x00080000, VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR = 0x00100000, VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR = 0x00000400, -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR = 0x00008000, -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS VK_BUFFER_USAGE_VIDEO_ENCODE_SRC_BIT_KHR = 0x00010000, -#endif + VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT = 0x00200000, + VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00400000, + VK_BUFFER_USAGE_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT = 0x04000000, + VK_BUFFER_USAGE_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT = 0x00800000, + VK_BUFFER_USAGE_MICROMAP_STORAGE_BIT_EXT = 0x01000000, VK_BUFFER_USAGE_RAY_TRACING_BIT_NV = VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, @@ -2421,6 +2516,7 @@ typedef VkFlags VkBufferViewCreateFlags; typedef enum VkImageViewCreateFlagBits { VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001, + VK_IMAGE_VIEW_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000004, VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DEFERRED_BIT_EXT = 0x00000002, VK_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkImageViewCreateFlagBits; @@ -2465,11 +2561,18 @@ typedef enum VkPipelineCreateFlagBits { VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080, VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV = 0x00040000, VK_PIPELINE_CREATE_LIBRARY_BIT_KHR = 0x00000800, + VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x20000000, VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT = 0x00800000, VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT = 0x00000400, VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV = 0x00100000, VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x02000000, VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x04000000, + VK_PIPELINE_CREATE_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT = 0x01000000, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_PIPELINE_CREATE_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV = 0x10000000, +#endif + VK_PIPELINE_CREATE_NO_PROTECTED_ACCESS_BIT_EXT = 0x08000000, + VK_PIPELINE_CREATE_PROTECTED_ACCESS_ONLY_BIT_EXT = 0x40000000, VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT, VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT, @@ -2508,6 +2611,7 @@ typedef enum VkShaderStageFlagBits { VK_SHADER_STAGE_TASK_BIT_EXT = 0x00000040, VK_SHADER_STAGE_MESH_BIT_EXT = 0x00000080, VK_SHADER_STAGE_SUBPASS_SHADING_BIT_HUAWEI = 0x00004000, + VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI = 0x00080000, VK_SHADER_STAGE_RAYGEN_BIT_NV = VK_SHADER_STAGE_RAYGEN_BIT_KHR, VK_SHADER_STAGE_ANY_HIT_BIT_NV = VK_SHADER_STAGE_ANY_HIT_BIT_KHR, VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV = VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, @@ -2561,6 +2665,7 @@ typedef VkFlags VkShaderStageFlags; typedef enum VkSamplerCreateFlagBits { VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001, VK_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002, + VK_SAMPLER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT = 0x00000004, VK_SAMPLER_CREATE_IMAGE_PROCESSING_BIT_QCOM = 0x00000010, VK_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF @@ -2570,8 +2675,11 @@ typedef VkFlags VkSamplerCreateFlags; typedef enum VkDescriptorPoolCreateFlagBits { VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT = 0x00000002, - VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE = 0x00000004, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT = 0x00000004, + VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_SETS_BIT_NV = 0x00000008, + VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_POOLS_BIT_NV = 0x00000010, VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE = VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT, VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkDescriptorPoolCreateFlagBits; typedef VkFlags VkDescriptorPoolCreateFlags; @@ -2580,8 +2688,13 @@ typedef VkFlags VkDescriptorPoolResetFlags; typedef enum VkDescriptorSetLayoutCreateFlagBits { VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT = 0x00000002, VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, - VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE = 0x00000004, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00000010, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT = 0x00000020, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_INDIRECT_BINDABLE_BIT_NV = 0x00000080, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT = 0x00000004, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_PER_STAGE_BIT_NV = 0x00000040, VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE = VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT, VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF } VkDescriptorSetLayoutCreateFlagBits; typedef VkFlags VkDescriptorSetLayoutCreateFlags; @@ -4735,6 +4848,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( #endif +// VK_VERSION_1_1 is a preprocessor guard. Do not pass it to API calls. #define VK_VERSION_1_1 1 // Vulkan 1.1 version number #define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0)// Patch version should always be set to 0 @@ -4852,6 +4966,7 @@ typedef enum VkExternalMemoryHandleTypeFlagBits { VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT = 0x00000100, VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA = 0x00000800, VK_EXTERNAL_MEMORY_HANDLE_TYPE_RDMA_ADDRESS_BIT_NV = 0x00001000, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX = 0x00004000, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, @@ -5600,6 +5715,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport( #endif +// VK_VERSION_1_2 is a preprocessor guard. Do not pass it to API calls. #define VK_VERSION_1_2 1 // Vulkan 1.2 version number #define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0)// Patch version should always be set to 0 @@ -5631,6 +5747,9 @@ typedef enum VkDriverId { VK_DRIVER_ID_SAMSUNG_PROPRIETARY = 21, VK_DRIVER_ID_MESA_VENUS = 22, VK_DRIVER_ID_MESA_DOZEN = 23, + VK_DRIVER_ID_MESA_NVK = 24, + VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA = 25, + VK_DRIVER_ID_MESA_AGXV = 26, VK_DRIVER_ID_AMD_PROPRIETARY_KHR = VK_DRIVER_ID_AMD_PROPRIETARY, VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR = VK_DRIVER_ID_AMD_OPEN_SOURCE, VK_DRIVER_ID_MESA_RADV_KHR = VK_DRIVER_ID_MESA_RADV, @@ -5660,6 +5779,7 @@ typedef enum VkSamplerReductionMode { VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE = 0, VK_SAMPLER_REDUCTION_MODE_MIN = 1, VK_SAMPLER_REDUCTION_MODE_MAX = 2, + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM = 1000521000, VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, VK_SAMPLER_REDUCTION_MODE_MIN_EXT = VK_SAMPLER_REDUCTION_MODE_MIN, VK_SAMPLER_REDUCTION_MODE_MAX_EXT = VK_SAMPLER_REDUCTION_MODE_MAX, @@ -5680,6 +5800,7 @@ typedef enum VkResolveModeFlagBits { VK_RESOLVE_MODE_AVERAGE_BIT = 0x00000002, VK_RESOLVE_MODE_MIN_BIT = 0x00000004, VK_RESOLVE_MODE_MAX_BIT = 0x00000008, + VK_RESOLVE_MODE_EXTERNAL_FORMAT_DOWNSAMPLE_ANDROID = 0x00000010, VK_RESOLVE_MODE_NONE_KHR = VK_RESOLVE_MODE_NONE, VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, VK_RESOLVE_MODE_AVERAGE_BIT_KHR = VK_RESOLVE_MODE_AVERAGE_BIT, @@ -6352,6 +6473,7 @@ VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddress( #endif +// VK_VERSION_1_3 is a preprocessor guard. Do not pass it to API calls. #define VK_VERSION_1_3 1 // Vulkan 1.3 version number #define VK_API_VERSION_1_3 VK_MAKE_API_VERSION(0, 1, 3, 0)// Patch version should always be set to 0 @@ -6443,12 +6565,8 @@ static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT_KHR = 0x2000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT = 0x4000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT_KHR = 0x4000000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR = 0x04000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR = 0x08000000ULL; -#endif static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT = 0x01000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT = 0x00040000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV = 0x00020000ULL; @@ -6463,9 +6581,13 @@ static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_NV = 0 static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_NV = 0x00100000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_EXT = 0x00080000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_EXT = 0x00100000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI = 0x8000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SUBPASS_SHADING_BIT_HUAWEI = 0x8000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI = 0x10000000000ULL; static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR = 0x10000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT = 0x40000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLUSTER_CULLING_SHADER_BIT_HUAWEI = 0x20000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV = 0x20000000ULL; typedef VkFlags64 VkAccessFlags2; @@ -6513,18 +6635,10 @@ static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT = 0x200000000 static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT_KHR = 0x200000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT = 0x400000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT_KHR = 0x400000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR = 0x800000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR = 0x1000000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR = 0x2000000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR = 0x4000000000ULL; -#endif static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT = 0x02000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT = 0x04000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT = 0x08000000ULL; @@ -6539,8 +6653,13 @@ static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_NV = static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT = 0x20000000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI = 0x8000000000ULL; static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR = 0x10000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_READ_BIT_EXT = 0x100000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT = 0x200000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV = 0x40000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV = 0x80000000000ULL; typedef enum VkSubmitFlagBits { @@ -6554,6 +6673,7 @@ typedef enum VkRenderingFlagBits { VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT = 0x00000001, VK_RENDERING_SUSPENDING_BIT = 0x00000002, VK_RENDERING_RESUMING_BIT = 0x00000004, + VK_RENDERING_CONTENTS_INLINE_BIT_EXT = 0x00000010, VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT = 0x00000008, VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT, VK_RENDERING_SUSPENDING_BIT_KHR = VK_RENDERING_SUSPENDING_BIT, @@ -6619,26 +6739,22 @@ static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_ static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR = 0x100000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT = 0x200000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR = 0x200000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000ULL; -#endif static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000ULL; -#ifdef VK_ENABLE_BETA_EXTENSIONS +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT = 0x400000000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR = 0x08000000ULL; -#endif -#ifdef VK_ENABLE_BETA_EXTENSIONS static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000ULL; -#endif static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV = 0x4000000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_IMAGE_BIT_QCOM = 0x400000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_SAMPLED_IMAGE_BIT_QCOM = 0x800000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLOCK_MATCHING_BIT_QCOM = 0x1000000000ULL; static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BOX_FILTER_SAMPLED_BIT_QCOM = 0x2000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_IMAGE_BIT_NV = 0x10000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_VECTOR_BIT_NV = 0x20000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_COST_BIT_NV = 0x40000000000ULL; typedef struct VkPhysicalDeviceVulkan13Features { VkStructureType sType; @@ -7392,6 +7508,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirements( #endif +// VK_KHR_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_surface 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) #define VK_KHR_SURFACE_SPEC_VERSION 25 @@ -7506,6 +7623,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( #endif +// VK_KHR_swapchain is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_swapchain 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) #define VK_KHR_SWAPCHAIN_SPEC_VERSION 70 @@ -7515,6 +7633,7 @@ typedef enum VkSwapchainCreateFlagBitsKHR { VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 0x00000001, VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 0x00000002, VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR = 0x00000004, + VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT = 0x00000008, VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF } VkSwapchainCreateFlagBitsKHR; typedef VkFlags VkSwapchainCreateFlagsKHR; @@ -7665,6 +7784,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR( #endif +// VK_KHR_display is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_display 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) @@ -7790,6 +7910,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( #endif +// VK_KHR_display_swapchain is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_display_swapchain 1 #define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 10 #define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" @@ -7813,23 +7934,852 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( #endif +// VK_KHR_sampler_mirror_clamp_to_edge is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_sampler_mirror_clamp_to_edge 1 #define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 3 #define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge" -#define VK_KHR_dynamic_rendering 1 -#define VK_KHR_DYNAMIC_RENDERING_SPEC_VERSION 1 -#define VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME "VK_KHR_dynamic_rendering" -typedef VkRenderingFlags VkRenderingFlagsKHR; +// VK_KHR_video_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_queue 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR) +#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 8 +#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue" + +typedef enum VkQueryResultStatusKHR { + VK_QUERY_RESULT_STATUS_ERROR_KHR = -1, + VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0, + VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1, + VK_QUERY_RESULT_STATUS_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_KHR = -1000299000, + VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkQueryResultStatusKHR; + +typedef enum VkVideoCodecOperationFlagBitsKHR { + VK_VIDEO_CODEC_OPERATION_NONE_KHR = 0, + VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR = 0x00010000, + VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR = 0x00020000, + VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR = 0x00000001, + VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR = 0x00000002, + VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodecOperationFlagBitsKHR; +typedef VkFlags VkVideoCodecOperationFlagsKHR; + +typedef enum VkVideoChromaSubsamplingFlagBitsKHR { + VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR = 0, + VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001, + VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002, + VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004, + VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008, + VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoChromaSubsamplingFlagBitsKHR; +typedef VkFlags VkVideoChromaSubsamplingFlagsKHR; + +typedef enum VkVideoComponentBitDepthFlagBitsKHR { + VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0, + VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001, + VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004, + VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010, + VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoComponentBitDepthFlagBitsKHR; +typedef VkFlags VkVideoComponentBitDepthFlagsKHR; + +typedef enum VkVideoCapabilityFlagBitsKHR { + VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002, + VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCapabilityFlagBitsKHR; +typedef VkFlags VkVideoCapabilityFlagsKHR; + +typedef enum VkVideoSessionCreateFlagBitsKHR { + VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_SESSION_CREATE_ALLOW_ENCODE_PARAMETER_OPTIMIZATIONS_BIT_KHR = 0x00000002, + VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR = 0x00000004, + VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoSessionCreateFlagBitsKHR; +typedef VkFlags VkVideoSessionCreateFlagsKHR; +typedef VkFlags VkVideoSessionParametersCreateFlagsKHR; +typedef VkFlags VkVideoBeginCodingFlagsKHR; +typedef VkFlags VkVideoEndCodingFlagsKHR; + +typedef enum VkVideoCodingControlFlagBitsKHR { + VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001, + VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR = 0x00000002, + VK_VIDEO_CODING_CONTROL_ENCODE_QUALITY_LEVEL_BIT_KHR = 0x00000004, + VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodingControlFlagBitsKHR; +typedef VkFlags VkVideoCodingControlFlagsKHR; +typedef struct VkQueueFamilyQueryResultStatusPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 queryResultStatusSupport; +} VkQueueFamilyQueryResultStatusPropertiesKHR; -typedef VkRenderingFlagBits VkRenderingFlagBitsKHR; +typedef struct VkQueueFamilyVideoPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCodecOperationFlagsKHR videoCodecOperations; +} VkQueueFamilyVideoPropertiesKHR; -typedef VkRenderingInfo VkRenderingInfoKHR; +typedef struct VkVideoProfileInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodecOperationFlagBitsKHR videoCodecOperation; + VkVideoChromaSubsamplingFlagsKHR chromaSubsampling; + VkVideoComponentBitDepthFlagsKHR lumaBitDepth; + VkVideoComponentBitDepthFlagsKHR chromaBitDepth; +} VkVideoProfileInfoKHR; -typedef VkRenderingAttachmentInfo VkRenderingAttachmentInfoKHR; +typedef struct VkVideoProfileListInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t profileCount; + const VkVideoProfileInfoKHR* pProfiles; +} VkVideoProfileListInfoKHR; -typedef VkPipelineRenderingCreateInfo VkPipelineRenderingCreateInfoKHR; +typedef struct VkVideoCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCapabilityFlagsKHR flags; + VkDeviceSize minBitstreamBufferOffsetAlignment; + VkDeviceSize minBitstreamBufferSizeAlignment; + VkExtent2D pictureAccessGranularity; + VkExtent2D minCodedExtent; + VkExtent2D maxCodedExtent; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + VkExtensionProperties stdHeaderVersion; +} VkVideoCapabilitiesKHR; + +typedef struct VkPhysicalDeviceVideoFormatInfoKHR { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags imageUsage; +} VkPhysicalDeviceVideoFormatInfoKHR; + +typedef struct VkVideoFormatPropertiesKHR { + VkStructureType sType; + void* pNext; + VkFormat format; + VkComponentMapping componentMapping; + VkImageCreateFlags imageCreateFlags; + VkImageType imageType; + VkImageTiling imageTiling; + VkImageUsageFlags imageUsageFlags; +} VkVideoFormatPropertiesKHR; + +typedef struct VkVideoPictureResourceInfoKHR { + VkStructureType sType; + const void* pNext; + VkOffset2D codedOffset; + VkExtent2D codedExtent; + uint32_t baseArrayLayer; + VkImageView imageViewBinding; +} VkVideoPictureResourceInfoKHR; + +typedef struct VkVideoReferenceSlotInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t slotIndex; + const VkVideoPictureResourceInfoKHR* pPictureResource; +} VkVideoReferenceSlotInfoKHR; + +typedef struct VkVideoSessionMemoryRequirementsKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryBindIndex; + VkMemoryRequirements memoryRequirements; +} VkVideoSessionMemoryRequirementsKHR; + +typedef struct VkBindVideoSessionMemoryInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t memoryBindIndex; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkDeviceSize memorySize; +} VkBindVideoSessionMemoryInfoKHR; + +typedef struct VkVideoSessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t queueFamilyIndex; + VkVideoSessionCreateFlagsKHR flags; + const VkVideoProfileInfoKHR* pVideoProfile; + VkFormat pictureFormat; + VkExtent2D maxCodedExtent; + VkFormat referencePictureFormat; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + const VkExtensionProperties* pStdHeaderVersion; +} VkVideoSessionCreateInfoKHR; + +typedef struct VkVideoSessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoSessionParametersCreateFlagsKHR flags; + VkVideoSessionParametersKHR videoSessionParametersTemplate; + VkVideoSessionKHR videoSession; +} VkVideoSessionParametersCreateInfoKHR; + +typedef struct VkVideoSessionParametersUpdateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t updateSequenceCount; +} VkVideoSessionParametersUpdateInfoKHR; + +typedef struct VkVideoBeginCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoBeginCodingFlagsKHR flags; + VkVideoSessionKHR videoSession; + VkVideoSessionParametersKHR videoSessionParameters; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoBeginCodingInfoKHR; + +typedef struct VkVideoEndCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEndCodingFlagsKHR flags; +} VkVideoEndCodingInfoKHR; + +typedef struct VkVideoCodingControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodingControlFlagsKHR flags; +} VkVideoCodingControlInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileInfoKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pMemoryRequirementsCount, VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); +typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t bindSessionMemoryInfoCount, const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters); +typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo); +typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + const VkVideoProfileInfoKHR* pVideoProfile, + VkVideoCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, + uint32_t* pVideoFormatPropertyCount, + VkVideoFormatPropertiesKHR* pVideoFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR( + VkDevice device, + const VkVideoSessionCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionKHR* pVideoSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t* pMemoryRequirementsCount, + VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t bindSessionMemoryInfoCount, + const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR( + VkDevice device, + const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionParametersKHR* pVideoSessionParameters); + +VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoBeginCodingInfoKHR* pBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoEndCodingInfoKHR* pEndCodingInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoCodingControlInfoKHR* pCodingControlInfo); +#endif + + +// VK_KHR_video_decode_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_queue 1 +#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 8 +#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue" + +typedef enum VkVideoDecodeCapabilityFlagBitsKHR { + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeCapabilityFlagBitsKHR; +typedef VkFlags VkVideoDecodeCapabilityFlagsKHR; + +typedef enum VkVideoDecodeUsageFlagBitsKHR { + VK_VIDEO_DECODE_USAGE_DEFAULT_KHR = 0, + VK_VIDEO_DECODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_USAGE_OFFLINE_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_USAGE_STREAMING_BIT_KHR = 0x00000004, + VK_VIDEO_DECODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeUsageFlagBitsKHR; +typedef VkFlags VkVideoDecodeUsageFlagsKHR; +typedef VkFlags VkVideoDecodeFlagsKHR; +typedef struct VkVideoDecodeCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoDecodeCapabilityFlagsKHR flags; +} VkVideoDecodeCapabilitiesKHR; + +typedef struct VkVideoDecodeUsageInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeUsageFlagsKHR videoUsageHints; +} VkVideoDecodeUsageInfoKHR; + +typedef struct VkVideoDecodeInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeFlagsKHR flags; + VkBuffer srcBuffer; + VkDeviceSize srcBufferOffset; + VkDeviceSize srcBufferRange; + VkVideoPictureResourceInfoKHR dstPictureResource; + const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoDecodeInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pDecodeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR( + VkCommandBuffer commandBuffer, + const VkVideoDecodeInfoKHR* pDecodeInfo); +#endif + + +// VK_KHR_video_encode_h264 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_h264 1 +#include "../vk_video/vulkan_video_codec_h264std.h" +#include "../vk_video/vulkan_video_codec_h264std_encode.h" +#define VK_KHR_VIDEO_ENCODE_H264_SPEC_VERSION 14 +#define VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_KHR_video_encode_h264" + +typedef enum VkVideoEncodeH264CapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H264_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H264_CAPABILITY_PER_SLICE_CONSTANT_QP_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H264_CAPABILITY_GENERATE_PREFIX_NALU_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264CapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264CapabilityFlagsKHR; + +typedef enum VkVideoEncodeH264StdFlagBitsKHR { + VK_VIDEO_ENCODE_H264_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_STD_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_FLAG_SET_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_STD_SCALING_MATRIX_PRESENT_FLAG_SET_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_STD_CHROMA_QP_INDEX_OFFSET_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_STD_SECOND_CHROMA_QP_INDEX_OFFSET_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_STD_PIC_INIT_QP_MINUS26_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_PRED_FLAG_SET_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_EXPLICIT_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_IMPLICIT_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H264_STD_TRANSFORM_8X8_MODE_FLAG_SET_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H264_STD_DIRECT_SPATIAL_MV_PRED_FLAG_UNSET_BIT_KHR = 0x00000400, + VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_UNSET_BIT_KHR = 0x00000800, + VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_SET_BIT_KHR = 0x00001000, + VK_VIDEO_ENCODE_H264_STD_DIRECT_8X8_INFERENCE_FLAG_UNSET_BIT_KHR = 0x00002000, + VK_VIDEO_ENCODE_H264_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_KHR = 0x00004000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_DISABLED_BIT_KHR = 0x00008000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_ENABLED_BIT_KHR = 0x00010000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_PARTIAL_BIT_KHR = 0x00020000, + VK_VIDEO_ENCODE_H264_STD_SLICE_QP_DELTA_BIT_KHR = 0x00080000, + VK_VIDEO_ENCODE_H264_STD_DIFFERENT_SLICE_QP_DELTA_BIT_KHR = 0x00100000, + VK_VIDEO_ENCODE_H264_STD_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264StdFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264StdFlagsKHR; + +typedef enum VkVideoEncodeH264RateControlFlagBitsKHR { + VK_VIDEO_ENCODE_H264_RATE_CONTROL_ATTEMPT_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REGULAR_GOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REFERENCE_PATTERN_DYADIC_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_TEMPORAL_LAYER_PATTERN_DYADIC_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264RateControlFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264RateControlFlagsKHR; +typedef struct VkVideoEncodeH264CapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH264CapabilityFlagsKHR flags; + StdVideoH264LevelIdc maxLevelIdc; + uint32_t maxSliceCount; + uint32_t maxPPictureL0ReferenceCount; + uint32_t maxBPictureL0ReferenceCount; + uint32_t maxL1ReferenceCount; + uint32_t maxTemporalLayerCount; + VkBool32 expectDyadicTemporalLayerPattern; + int32_t minQp; + int32_t maxQp; + VkBool32 prefersGopRemainingFrames; + VkBool32 requiresGopRemainingFrames; + VkVideoEncodeH264StdFlagsKHR stdSyntaxFlags; +} VkVideoEncodeH264CapabilitiesKHR; + +typedef struct VkVideoEncodeH264QpKHR { + int32_t qpI; + int32_t qpP; + int32_t qpB; +} VkVideoEncodeH264QpKHR; + +typedef struct VkVideoEncodeH264QualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH264RateControlFlagsKHR preferredRateControlFlags; + uint32_t preferredGopFrameCount; + uint32_t preferredIdrPeriod; + uint32_t preferredConsecutiveBFrameCount; + uint32_t preferredTemporalLayerCount; + VkVideoEncodeH264QpKHR preferredConstantQp; + uint32_t preferredMaxL0ReferenceCount; + uint32_t preferredMaxL1ReferenceCount; + VkBool32 preferredStdEntropyCodingModeFlag; +} VkVideoEncodeH264QualityLevelPropertiesKHR; + +typedef struct VkVideoEncodeH264SessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMaxLevelIdc; + StdVideoH264LevelIdc maxLevelIdc; +} VkVideoEncodeH264SessionCreateInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdSPSCount; + const StdVideoH264SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH264PictureParameterSet* pStdPPSs; +} VkVideoEncodeH264SessionParametersAddInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoEncodeH264SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoEncodeH264SessionParametersCreateInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 writeStdSPS; + VkBool32 writeStdPPS; + uint32_t stdSPSId; + uint32_t stdPPSId; +} VkVideoEncodeH264SessionParametersGetInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasStdSPSOverrides; + VkBool32 hasStdPPSOverrides; +} VkVideoEncodeH264SessionParametersFeedbackInfoKHR; + +typedef struct VkVideoEncodeH264NaluSliceInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t constantQp; + const StdVideoEncodeH264SliceHeader* pStdSliceHeader; +} VkVideoEncodeH264NaluSliceInfoKHR; + +typedef struct VkVideoEncodeH264PictureInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t naluSliceEntryCount; + const VkVideoEncodeH264NaluSliceInfoKHR* pNaluSliceEntries; + const StdVideoEncodeH264PictureInfo* pStdPictureInfo; + VkBool32 generatePrefixNalu; +} VkVideoEncodeH264PictureInfoKHR; + +typedef struct VkVideoEncodeH264DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoEncodeH264ReferenceInfo* pStdReferenceInfo; +} VkVideoEncodeH264DpbSlotInfoKHR; + +typedef struct VkVideoEncodeH264ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH264ProfileIdc stdProfileIdc; +} VkVideoEncodeH264ProfileInfoKHR; + +typedef struct VkVideoEncodeH264RateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeH264RateControlFlagsKHR flags; + uint32_t gopFrameCount; + uint32_t idrPeriod; + uint32_t consecutiveBFrameCount; + uint32_t temporalLayerCount; +} VkVideoEncodeH264RateControlInfoKHR; + +typedef struct VkVideoEncodeH264FrameSizeKHR { + uint32_t frameISize; + uint32_t framePSize; + uint32_t frameBSize; +} VkVideoEncodeH264FrameSizeKHR; + +typedef struct VkVideoEncodeH264RateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMinQp; + VkVideoEncodeH264QpKHR minQp; + VkBool32 useMaxQp; + VkVideoEncodeH264QpKHR maxQp; + VkBool32 useMaxFrameSize; + VkVideoEncodeH264FrameSizeKHR maxFrameSize; +} VkVideoEncodeH264RateControlLayerInfoKHR; + +typedef struct VkVideoEncodeH264GopRemainingFrameInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useGopRemainingFrames; + uint32_t gopRemainingI; + uint32_t gopRemainingP; + uint32_t gopRemainingB; +} VkVideoEncodeH264GopRemainingFrameInfoKHR; + + + +// VK_KHR_video_encode_h265 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_h265 1 +#include "../vk_video/vulkan_video_codec_h265std.h" +#include "../vk_video/vulkan_video_codec_h265std_encode.h" +#define VK_KHR_VIDEO_ENCODE_H265_SPEC_VERSION 14 +#define VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_KHR_video_encode_h265" + +typedef enum VkVideoEncodeH265CapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_SEGMENT_TYPE_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H265_CAPABILITY_PER_SLICE_SEGMENT_CONSTANT_QP_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILES_PER_SLICE_SEGMENT_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_SEGMENTS_PER_TILE_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H265_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265CapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265CapabilityFlagsKHR; + +typedef enum VkVideoEncodeH265StdFlagBitsKHR { + VK_VIDEO_ENCODE_H265_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_STD_SAMPLE_ADAPTIVE_OFFSET_ENABLED_FLAG_SET_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_STD_SCALING_LIST_DATA_PRESENT_FLAG_SET_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_STD_PCM_ENABLED_FLAG_SET_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_STD_SPS_TEMPORAL_MVP_ENABLED_FLAG_SET_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_STD_INIT_QP_MINUS26_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H265_STD_WEIGHTED_PRED_FLAG_SET_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H265_STD_WEIGHTED_BIPRED_FLAG_SET_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H265_STD_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H265_STD_SIGN_DATA_HIDING_ENABLED_FLAG_SET_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_SET_BIT_KHR = 0x00000400, + VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_UNSET_BIT_KHR = 0x00000800, + VK_VIDEO_ENCODE_H265_STD_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_FLAG_SET_BIT_KHR = 0x00001000, + VK_VIDEO_ENCODE_H265_STD_TRANSQUANT_BYPASS_ENABLED_FLAG_SET_BIT_KHR = 0x00002000, + VK_VIDEO_ENCODE_H265_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_KHR = 0x00004000, + VK_VIDEO_ENCODE_H265_STD_ENTROPY_CODING_SYNC_ENABLED_FLAG_SET_BIT_KHR = 0x00008000, + VK_VIDEO_ENCODE_H265_STD_DEBLOCKING_FILTER_OVERRIDE_ENABLED_FLAG_SET_BIT_KHR = 0x00010000, + VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENTS_ENABLED_FLAG_SET_BIT_KHR = 0x00020000, + VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENT_FLAG_SET_BIT_KHR = 0x00040000, + VK_VIDEO_ENCODE_H265_STD_SLICE_QP_DELTA_BIT_KHR = 0x00080000, + VK_VIDEO_ENCODE_H265_STD_DIFFERENT_SLICE_QP_DELTA_BIT_KHR = 0x00100000, + VK_VIDEO_ENCODE_H265_STD_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265StdFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265StdFlagsKHR; + +typedef enum VkVideoEncodeH265CtbSizeFlagBitsKHR { + VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265CtbSizeFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265CtbSizeFlagsKHR; + +typedef enum VkVideoEncodeH265TransformBlockSizeFlagBitsKHR { + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265TransformBlockSizeFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265TransformBlockSizeFlagsKHR; + +typedef enum VkVideoEncodeH265RateControlFlagBitsKHR { + VK_VIDEO_ENCODE_H265_RATE_CONTROL_ATTEMPT_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REGULAR_GOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_DYADIC_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_TEMPORAL_SUB_LAYER_PATTERN_DYADIC_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265RateControlFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265RateControlFlagsKHR; +typedef struct VkVideoEncodeH265CapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH265CapabilityFlagsKHR flags; + StdVideoH265LevelIdc maxLevelIdc; + uint32_t maxSliceSegmentCount; + VkExtent2D maxTiles; + VkVideoEncodeH265CtbSizeFlagsKHR ctbSizes; + VkVideoEncodeH265TransformBlockSizeFlagsKHR transformBlockSizes; + uint32_t maxPPictureL0ReferenceCount; + uint32_t maxBPictureL0ReferenceCount; + uint32_t maxL1ReferenceCount; + uint32_t maxSubLayerCount; + VkBool32 expectDyadicTemporalSubLayerPattern; + int32_t minQp; + int32_t maxQp; + VkBool32 prefersGopRemainingFrames; + VkBool32 requiresGopRemainingFrames; + VkVideoEncodeH265StdFlagsKHR stdSyntaxFlags; +} VkVideoEncodeH265CapabilitiesKHR; + +typedef struct VkVideoEncodeH265SessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMaxLevelIdc; + StdVideoH265LevelIdc maxLevelIdc; +} VkVideoEncodeH265SessionCreateInfoKHR; + +typedef struct VkVideoEncodeH265QpKHR { + int32_t qpI; + int32_t qpP; + int32_t qpB; +} VkVideoEncodeH265QpKHR; + +typedef struct VkVideoEncodeH265QualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH265RateControlFlagsKHR preferredRateControlFlags; + uint32_t preferredGopFrameCount; + uint32_t preferredIdrPeriod; + uint32_t preferredConsecutiveBFrameCount; + uint32_t preferredSubLayerCount; + VkVideoEncodeH265QpKHR preferredConstantQp; + uint32_t preferredMaxL0ReferenceCount; + uint32_t preferredMaxL1ReferenceCount; +} VkVideoEncodeH265QualityLevelPropertiesKHR; + +typedef struct VkVideoEncodeH265SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdVPSCount; + const StdVideoH265VideoParameterSet* pStdVPSs; + uint32_t stdSPSCount; + const StdVideoH265SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH265PictureParameterSet* pStdPPSs; +} VkVideoEncodeH265SessionParametersAddInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdVPSCount; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoEncodeH265SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoEncodeH265SessionParametersCreateInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 writeStdVPS; + VkBool32 writeStdSPS; + VkBool32 writeStdPPS; + uint32_t stdVPSId; + uint32_t stdSPSId; + uint32_t stdPPSId; +} VkVideoEncodeH265SessionParametersGetInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasStdVPSOverrides; + VkBool32 hasStdSPSOverrides; + VkBool32 hasStdPPSOverrides; +} VkVideoEncodeH265SessionParametersFeedbackInfoKHR; + +typedef struct VkVideoEncodeH265NaluSliceSegmentInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t constantQp; + const StdVideoEncodeH265SliceSegmentHeader* pStdSliceSegmentHeader; +} VkVideoEncodeH265NaluSliceSegmentInfoKHR; + +typedef struct VkVideoEncodeH265PictureInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t naluSliceSegmentEntryCount; + const VkVideoEncodeH265NaluSliceSegmentInfoKHR* pNaluSliceSegmentEntries; + const StdVideoEncodeH265PictureInfo* pStdPictureInfo; +} VkVideoEncodeH265PictureInfoKHR; + +typedef struct VkVideoEncodeH265DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo; +} VkVideoEncodeH265DpbSlotInfoKHR; + +typedef struct VkVideoEncodeH265ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH265ProfileIdc stdProfileIdc; +} VkVideoEncodeH265ProfileInfoKHR; + +typedef struct VkVideoEncodeH265RateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeH265RateControlFlagsKHR flags; + uint32_t gopFrameCount; + uint32_t idrPeriod; + uint32_t consecutiveBFrameCount; + uint32_t subLayerCount; +} VkVideoEncodeH265RateControlInfoKHR; + +typedef struct VkVideoEncodeH265FrameSizeKHR { + uint32_t frameISize; + uint32_t framePSize; + uint32_t frameBSize; +} VkVideoEncodeH265FrameSizeKHR; + +typedef struct VkVideoEncodeH265RateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMinQp; + VkVideoEncodeH265QpKHR minQp; + VkBool32 useMaxQp; + VkVideoEncodeH265QpKHR maxQp; + VkBool32 useMaxFrameSize; + VkVideoEncodeH265FrameSizeKHR maxFrameSize; +} VkVideoEncodeH265RateControlLayerInfoKHR; + +typedef struct VkVideoEncodeH265GopRemainingFrameInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useGopRemainingFrames; + uint32_t gopRemainingI; + uint32_t gopRemainingP; + uint32_t gopRemainingB; +} VkVideoEncodeH265GopRemainingFrameInfoKHR; + + + +// VK_KHR_video_decode_h264 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_h264 1 +#include "../vk_video/vulkan_video_codec_h264std_decode.h" +#define VK_KHR_VIDEO_DECODE_H264_SPEC_VERSION 9 +#define VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME "VK_KHR_video_decode_h264" + +typedef enum VkVideoDecodeH264PictureLayoutFlagBitsKHR { + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR = 0, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeH264PictureLayoutFlagBitsKHR; +typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsKHR; +typedef struct VkVideoDecodeH264ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH264ProfileIdc stdProfileIdc; + VkVideoDecodeH264PictureLayoutFlagBitsKHR pictureLayout; +} VkVideoDecodeH264ProfileInfoKHR; + +typedef struct VkVideoDecodeH264CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH264LevelIdc maxLevelIdc; + VkOffset2D fieldOffsetGranularity; +} VkVideoDecodeH264CapabilitiesKHR; + +typedef struct VkVideoDecodeH264SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdSPSCount; + const StdVideoH264SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH264PictureParameterSet* pStdPPSs; +} VkVideoDecodeH264SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH264SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH264SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH264SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH264PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264PictureInfo* pStdPictureInfo; + uint32_t sliceCount; + const uint32_t* pSliceOffsets; +} VkVideoDecodeH264PictureInfoKHR; + +typedef struct VkVideoDecodeH264DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH264DpbSlotInfoKHR; + + + +// VK_KHR_dynamic_rendering is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_dynamic_rendering 1 +#define VK_KHR_DYNAMIC_RENDERING_SPEC_VERSION 1 +#define VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME "VK_KHR_dynamic_rendering" +typedef VkRenderingFlags VkRenderingFlagsKHR; + +typedef VkRenderingFlagBits VkRenderingFlagBitsKHR; + +typedef VkRenderingInfo VkRenderingInfoKHR; + +typedef VkRenderingAttachmentInfo VkRenderingAttachmentInfoKHR; + +typedef VkPipelineRenderingCreateInfo VkPipelineRenderingCreateInfoKHR; typedef VkPhysicalDeviceDynamicRenderingFeatures VkPhysicalDeviceDynamicRenderingFeaturesKHR; @@ -7880,6 +8830,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderingKHR( #endif +// VK_KHR_multiview is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_multiview 1 #define VK_KHR_MULTIVIEW_SPEC_VERSION 1 #define VK_KHR_MULTIVIEW_EXTENSION_NAME "VK_KHR_multiview" @@ -7891,6 +8842,7 @@ typedef VkPhysicalDeviceMultiviewProperties VkPhysicalDeviceMultiviewPropertiesK +// VK_KHR_get_physical_device_properties2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_get_physical_device_properties2 1 #define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 2 #define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2" @@ -7956,6 +8908,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR( #endif +// VK_KHR_device_group is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_device_group 1 #define VK_KHR_DEVICE_GROUP_SPEC_VERSION 4 #define VK_KHR_DEVICE_GROUP_EXTENSION_NAME "VK_KHR_device_group" @@ -8008,11 +8961,13 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBaseKHR( #endif +// VK_KHR_shader_draw_parameters is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_draw_parameters 1 #define VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION 1 #define VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME "VK_KHR_shader_draw_parameters" +// VK_KHR_maintenance1 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_maintenance1 1 #define VK_KHR_MAINTENANCE_1_SPEC_VERSION 2 #define VK_KHR_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_maintenance1" @@ -8030,6 +8985,7 @@ VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR( #endif +// VK_KHR_device_group_creation is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_device_group_creation 1 #define VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION 1 #define VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME "VK_KHR_device_group_creation" @@ -8048,6 +9004,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHR( #endif +// VK_KHR_external_memory_capabilities is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_memory_capabilities 1 #define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_memory_capabilities" @@ -8082,6 +9039,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferPropertiesKHR( #endif +// VK_KHR_external_memory is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_memory 1 #define VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME "VK_KHR_external_memory" @@ -8094,6 +9052,7 @@ typedef VkExportMemoryAllocateInfo VkExportMemoryAllocateInfoKHR; +// VK_KHR_external_memory_fd is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_memory_fd 1 #define VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME "VK_KHR_external_memory_fd" @@ -8134,6 +9093,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR( #endif +// VK_KHR_external_semaphore_capabilities is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_semaphore_capabilities 1 #define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_semaphore_capabilities" @@ -8159,6 +9119,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphorePropertiesKHR( #endif +// VK_KHR_external_semaphore is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_semaphore 1 #define VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_KHR_external_semaphore" @@ -8170,6 +9131,7 @@ typedef VkExportSemaphoreCreateInfo VkExportSemaphoreCreateInfoKHR; +// VK_KHR_external_semaphore_fd is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_semaphore_fd 1 #define VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME "VK_KHR_external_semaphore_fd" @@ -8204,6 +9166,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR( #endif +// VK_KHR_push_descriptor is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_push_descriptor 1 #define VK_KHR_PUSH_DESCRIPTOR_SPEC_VERSION 2 #define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME "VK_KHR_push_descriptor" @@ -8234,6 +9197,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( #endif +// VK_KHR_shader_float16_int8 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_float16_int8 1 #define VK_KHR_SHADER_FLOAT16_INT8_SPEC_VERSION 1 #define VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME "VK_KHR_shader_float16_int8" @@ -8243,6 +9207,7 @@ typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceFloat16Int8Fea +// VK_KHR_16bit_storage is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_16bit_storage 1 #define VK_KHR_16BIT_STORAGE_SPEC_VERSION 1 #define VK_KHR_16BIT_STORAGE_EXTENSION_NAME "VK_KHR_16bit_storage" @@ -8250,6 +9215,7 @@ typedef VkPhysicalDevice16BitStorageFeatures VkPhysicalDevice16BitStorageFeature +// VK_KHR_incremental_present is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_incremental_present 1 #define VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION 2 #define VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME "VK_KHR_incremental_present" @@ -8273,6 +9239,7 @@ typedef struct VkPresentRegionsKHR { +// VK_KHR_descriptor_update_template is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_descriptor_update_template 1 typedef VkDescriptorUpdateTemplate VkDescriptorUpdateTemplateKHR; @@ -8310,6 +9277,7 @@ VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateKHR( #endif +// VK_KHR_imageless_framebuffer is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_imageless_framebuffer 1 #define VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION 1 #define VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME "VK_KHR_imageless_framebuffer" @@ -8323,6 +9291,7 @@ typedef VkRenderPassAttachmentBeginInfo VkRenderPassAttachmentBeginInfoKHR; +// VK_KHR_create_renderpass2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_create_renderpass2 1 #define VK_KHR_CREATE_RENDERPASS_2_SPEC_VERSION 1 #define VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME "VK_KHR_create_renderpass2" @@ -8368,6 +9337,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR( #endif +// VK_KHR_shared_presentable_image is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shared_presentable_image 1 #define VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION 1 #define VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME "VK_KHR_shared_presentable_image" @@ -8386,6 +9356,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainStatusKHR( #endif +// VK_KHR_external_fence_capabilities is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_fence_capabilities 1 #define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_fence_capabilities" @@ -8411,6 +9382,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFencePropertiesKHR( #endif +// VK_KHR_external_fence is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_fence 1 #define VK_KHR_EXTERNAL_FENCE_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME "VK_KHR_external_fence" @@ -8422,6 +9394,7 @@ typedef VkExportFenceCreateInfo VkExportFenceCreateInfoKHR; +// VK_KHR_external_fence_fd is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_fence_fd 1 #define VK_KHR_EXTERNAL_FENCE_FD_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME "VK_KHR_external_fence_fd" @@ -8456,6 +9429,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceFdKHR( #endif +// VK_KHR_performance_query is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_performance_query 1 #define VK_KHR_PERFORMANCE_QUERY_SPEC_VERSION 1 #define VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME "VK_KHR_performance_query" @@ -8596,6 +9570,7 @@ VKAPI_ATTR void VKAPI_CALL vkReleaseProfilingLockKHR( #endif +// VK_KHR_maintenance2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_maintenance2 1 #define VK_KHR_MAINTENANCE_2_SPEC_VERSION 1 #define VK_KHR_MAINTENANCE_2_EXTENSION_NAME "VK_KHR_maintenance2" @@ -8617,6 +9592,7 @@ typedef VkPipelineTessellationDomainOriginStateCreateInfo VkPipelineTessellation +// VK_KHR_get_surface_capabilities2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_get_surface_capabilities2 1 #define VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION 1 #define VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME "VK_KHR_get_surface_capabilities2" @@ -8655,6 +9631,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR( #endif +// VK_KHR_variable_pointers is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_variable_pointers 1 #define VK_KHR_VARIABLE_POINTERS_SPEC_VERSION 1 #define VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME "VK_KHR_variable_pointers" @@ -8664,6 +9641,7 @@ typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointer +// VK_KHR_get_display_properties2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_get_display_properties2 1 #define VK_KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION 1 #define VK_KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_display_properties2" @@ -8727,6 +9705,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilities2KHR( #endif +// VK_KHR_dedicated_allocation is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_dedicated_allocation 1 #define VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION 3 #define VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_KHR_dedicated_allocation" @@ -8736,16 +9715,19 @@ typedef VkMemoryDedicatedAllocateInfo VkMemoryDedicatedAllocateInfoKHR; +// VK_KHR_storage_buffer_storage_class is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_storage_buffer_storage_class 1 #define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION 1 #define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME "VK_KHR_storage_buffer_storage_class" +// VK_KHR_relaxed_block_layout is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_relaxed_block_layout 1 #define VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION 1 #define VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME "VK_KHR_relaxed_block_layout" +// VK_KHR_get_memory_requirements2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_get_memory_requirements2 1 #define VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION 1 #define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME "VK_KHR_get_memory_requirements2" @@ -8782,6 +9764,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2KHR( #endif +// VK_KHR_image_format_list is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_image_format_list 1 #define VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION 1 #define VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME "VK_KHR_image_format_list" @@ -8789,6 +9772,7 @@ typedef VkImageFormatListCreateInfo VkImageFormatListCreateInfoKHR; +// VK_KHR_sampler_ycbcr_conversion is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_sampler_ycbcr_conversion 1 typedef VkSamplerYcbcrConversion VkSamplerYcbcrConversionKHR; @@ -8829,6 +9813,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversionKHR( #endif +// VK_KHR_bind_memory2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_bind_memory2 1 #define VK_KHR_BIND_MEMORY_2_SPEC_VERSION 1 #define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME "VK_KHR_bind_memory2" @@ -8852,6 +9837,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2KHR( #endif +// VK_KHR_maintenance3 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_maintenance3 1 #define VK_KHR_MAINTENANCE_3_SPEC_VERSION 1 #define VK_KHR_MAINTENANCE_3_EXTENSION_NAME "VK_KHR_maintenance3" @@ -8871,6 +9857,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupportKHR( #endif +// VK_KHR_draw_indirect_count is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_draw_indirect_count 1 #define VK_KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION 1 #define VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_KHR_draw_indirect_count" @@ -8898,6 +9885,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR( #endif +// VK_KHR_shader_subgroup_extended_types is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_subgroup_extended_types 1 #define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION 1 #define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME "VK_KHR_shader_subgroup_extended_types" @@ -8905,6 +9893,7 @@ typedef VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures VkPhysicalDeviceShad +// VK_KHR_8bit_storage is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_8bit_storage 1 #define VK_KHR_8BIT_STORAGE_SPEC_VERSION 1 #define VK_KHR_8BIT_STORAGE_EXTENSION_NAME "VK_KHR_8bit_storage" @@ -8912,6 +9901,7 @@ typedef VkPhysicalDevice8BitStorageFeatures VkPhysicalDevice8BitStorageFeaturesK +// VK_KHR_shader_atomic_int64 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_atomic_int64 1 #define VK_KHR_SHADER_ATOMIC_INT64_SPEC_VERSION 1 #define VK_KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME "VK_KHR_shader_atomic_int64" @@ -8919,6 +9909,7 @@ typedef VkPhysicalDeviceShaderAtomicInt64Features VkPhysicalDeviceShaderAtomicIn +// VK_KHR_shader_clock is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_clock 1 #define VK_KHR_SHADER_CLOCK_SPEC_VERSION 1 #define VK_KHR_SHADER_CLOCK_EXTENSION_NAME "VK_KHR_shader_clock" @@ -8931,6 +9922,60 @@ typedef struct VkPhysicalDeviceShaderClockFeaturesKHR { +// VK_KHR_video_decode_h265 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_h265 1 +#include "../vk_video/vulkan_video_codec_h265std_decode.h" +#define VK_KHR_VIDEO_DECODE_H265_SPEC_VERSION 8 +#define VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME "VK_KHR_video_decode_h265" +typedef struct VkVideoDecodeH265ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH265ProfileIdc stdProfileIdc; +} VkVideoDecodeH265ProfileInfoKHR; + +typedef struct VkVideoDecodeH265CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH265LevelIdc maxLevelIdc; +} VkVideoDecodeH265CapabilitiesKHR; + +typedef struct VkVideoDecodeH265SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdVPSCount; + const StdVideoH265VideoParameterSet* pStdVPSs; + uint32_t stdSPSCount; + const StdVideoH265SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH265PictureParameterSet* pStdPPSs; +} VkVideoDecodeH265SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH265SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdVPSCount; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH265SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH265SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH265PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265PictureInfo* pStdPictureInfo; + uint32_t sliceSegmentCount; + const uint32_t* pSliceSegmentOffsets; +} VkVideoDecodeH265PictureInfoKHR; + +typedef struct VkVideoDecodeH265DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH265DpbSlotInfoKHR; + + + +// VK_KHR_global_priority is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_global_priority 1 #define VK_MAX_GLOBAL_PRIORITY_SIZE_KHR 16U #define VK_KHR_GLOBAL_PRIORITY_SPEC_VERSION 1 @@ -8968,6 +10013,7 @@ typedef struct VkQueueFamilyGlobalPriorityPropertiesKHR { +// VK_KHR_driver_properties is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_driver_properties 1 #define VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION 1 #define VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME "VK_KHR_driver_properties" @@ -8981,6 +10027,7 @@ typedef VkPhysicalDeviceDriverProperties VkPhysicalDeviceDriverPropertiesKHR; +// VK_KHR_shader_float_controls is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_float_controls 1 #define VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION 4 #define VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME "VK_KHR_shader_float_controls" @@ -8990,6 +10037,7 @@ typedef VkPhysicalDeviceFloatControlsProperties VkPhysicalDeviceFloatControlsPro +// VK_KHR_depth_stencil_resolve is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_depth_stencil_resolve 1 #define VK_KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION 1 #define VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME "VK_KHR_depth_stencil_resolve" @@ -9003,11 +10051,13 @@ typedef VkPhysicalDeviceDepthStencilResolveProperties VkPhysicalDeviceDepthStenc +// VK_KHR_swapchain_mutable_format is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_swapchain_mutable_format 1 #define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION 1 #define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME "VK_KHR_swapchain_mutable_format" +// VK_KHR_timeline_semaphore is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_timeline_semaphore 1 #define VK_KHR_TIMELINE_SEMAPHORE_SPEC_VERSION 2 #define VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME "VK_KHR_timeline_semaphore" @@ -9050,6 +10100,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphoreKHR( #endif +// VK_KHR_vulkan_memory_model is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_vulkan_memory_model 1 #define VK_KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION 3 #define VK_KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME "VK_KHR_vulkan_memory_model" @@ -9057,6 +10108,7 @@ typedef VkPhysicalDeviceVulkanMemoryModelFeatures VkPhysicalDeviceVulkanMemoryMo +// VK_KHR_shader_terminate_invocation is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_terminate_invocation 1 #define VK_KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION 1 #define VK_KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME "VK_KHR_shader_terminate_invocation" @@ -9064,6 +10116,7 @@ typedef VkPhysicalDeviceShaderTerminateInvocationFeatures VkPhysicalDeviceShader +// VK_KHR_fragment_shading_rate is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_fragment_shading_rate 1 #define VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION 2 #define VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME "VK_KHR_fragment_shading_rate" @@ -9143,11 +10196,13 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetFragmentShadingRateKHR( #endif +// VK_KHR_spirv_1_4 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_spirv_1_4 1 #define VK_KHR_SPIRV_1_4_SPEC_VERSION 1 #define VK_KHR_SPIRV_1_4_EXTENSION_NAME "VK_KHR_spirv_1_4" +// VK_KHR_surface_protected_capabilities is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_surface_protected_capabilities 1 #define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION 1 #define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME "VK_KHR_surface_protected_capabilities" @@ -9159,6 +10214,7 @@ typedef struct VkSurfaceProtectedCapabilitiesKHR { +// VK_KHR_separate_depth_stencil_layouts is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_separate_depth_stencil_layouts 1 #define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION 1 #define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME "VK_KHR_separate_depth_stencil_layouts" @@ -9170,6 +10226,7 @@ typedef VkAttachmentDescriptionStencilLayout VkAttachmentDescriptionStencilLayou +// VK_KHR_present_wait is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_present_wait 1 #define VK_KHR_PRESENT_WAIT_SPEC_VERSION 1 #define VK_KHR_PRESENT_WAIT_EXTENSION_NAME "VK_KHR_present_wait" @@ -9190,6 +10247,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkWaitForPresentKHR( #endif +// VK_KHR_uniform_buffer_standard_layout is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_uniform_buffer_standard_layout 1 #define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION 1 #define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME "VK_KHR_uniform_buffer_standard_layout" @@ -9197,6 +10255,7 @@ typedef VkPhysicalDeviceUniformBufferStandardLayoutFeatures VkPhysicalDeviceUnif +// VK_KHR_buffer_device_address is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_buffer_device_address 1 #define VK_KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 1 #define VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_KHR_buffer_device_address" @@ -9229,6 +10288,7 @@ VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddressKHR( #endif +// VK_KHR_deferred_host_operations is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_deferred_host_operations 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeferredOperationKHR) #define VK_KHR_DEFERRED_HOST_OPERATIONS_SPEC_VERSION 4 @@ -9264,6 +10324,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkDeferredOperationJoinKHR( #endif +// VK_KHR_pipeline_executable_properties is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_pipeline_executable_properties 1 #define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION 1 #define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME "VK_KHR_pipeline_executable_properties" @@ -9354,6 +10415,43 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR #endif +// VK_KHR_map_memory2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_map_memory2 1 +#define VK_KHR_MAP_MEMORY_2_SPEC_VERSION 1 +#define VK_KHR_MAP_MEMORY_2_EXTENSION_NAME "VK_KHR_map_memory2" +typedef VkFlags VkMemoryUnmapFlagsKHR; +typedef struct VkMemoryMapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryMapFlags flags; + VkDeviceMemory memory; + VkDeviceSize offset; + VkDeviceSize size; +} VkMemoryMapInfoKHR; + +typedef struct VkMemoryUnmapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryUnmapFlagsKHR flags; + VkDeviceMemory memory; +} VkMemoryUnmapInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkMapMemory2KHR)(VkDevice device, const VkMemoryMapInfoKHR* pMemoryMapInfo, void** ppData); +typedef VkResult (VKAPI_PTR *PFN_vkUnmapMemory2KHR)(VkDevice device, const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory2KHR( + VkDevice device, + const VkMemoryMapInfoKHR* pMemoryMapInfo, + void** ppData); + +VKAPI_ATTR VkResult VKAPI_CALL vkUnmapMemory2KHR( + VkDevice device, + const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); +#endif + + +// VK_KHR_shader_integer_dot_product is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_integer_dot_product 1 #define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION 1 #define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME "VK_KHR_shader_integer_dot_product" @@ -9363,6 +10461,7 @@ typedef VkPhysicalDeviceShaderIntegerDotProductProperties VkPhysicalDeviceShader +// VK_KHR_pipeline_library is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_pipeline_library 1 #define VK_KHR_PIPELINE_LIBRARY_SPEC_VERSION 1 #define VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME "VK_KHR_pipeline_library" @@ -9375,11 +10474,13 @@ typedef struct VkPipelineLibraryCreateInfoKHR { +// VK_KHR_shader_non_semantic_info is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_non_semantic_info 1 #define VK_KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION 1 #define VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME "VK_KHR_shader_non_semantic_info" +// VK_KHR_present_id is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_present_id 1 #define VK_KHR_PRESENT_ID_SPEC_VERSION 1 #define VK_KHR_PRESENT_ID_EXTENSION_NAME "VK_KHR_present_id" @@ -9398,28 +10499,202 @@ typedef struct VkPhysicalDevicePresentIdFeaturesKHR { -#define VK_KHR_synchronization2 1 -#define VK_KHR_SYNCHRONIZATION_2_SPEC_VERSION 1 -#define VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME "VK_KHR_synchronization2" -typedef VkPipelineStageFlags2 VkPipelineStageFlags2KHR; +// VK_KHR_video_encode_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_queue 1 +#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 12 +#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue" + +typedef enum VkVideoEncodeTuningModeKHR { + VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_TUNING_MODE_HIGH_QUALITY_KHR = 1, + VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR = 2, + VK_VIDEO_ENCODE_TUNING_MODE_ULTRA_LOW_LATENCY_KHR = 3, + VK_VIDEO_ENCODE_TUNING_MODE_LOSSLESS_KHR = 4, + VK_VIDEO_ENCODE_TUNING_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeTuningModeKHR; +typedef VkFlags VkVideoEncodeFlagsKHR; + +typedef enum VkVideoEncodeCapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_CAPABILITY_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_DETECTION_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeCapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeCapabilityFlagsKHR; + +typedef enum VkVideoEncodeRateControlModeFlagBitsKHR { + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeRateControlModeFlagBitsKHR; +typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR; + +typedef enum VkVideoEncodeFeedbackFlagBitsKHR { + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BUFFER_OFFSET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BYTES_WRITTEN_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_HAS_OVERRIDES_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_FEEDBACK_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeFeedbackFlagBitsKHR; +typedef VkFlags VkVideoEncodeFeedbackFlagsKHR; + +typedef enum VkVideoEncodeUsageFlagBitsKHR { + VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_USAGE_RECORDING_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_USAGE_CONFERENCING_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeUsageFlagBitsKHR; +typedef VkFlags VkVideoEncodeUsageFlagsKHR; + +typedef enum VkVideoEncodeContentFlagBitsKHR { + VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_CONTENT_CAMERA_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_CONTENT_DESKTOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_CONTENT_RENDERED_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_CONTENT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeContentFlagBitsKHR; +typedef VkFlags VkVideoEncodeContentFlagsKHR; +typedef VkFlags VkVideoEncodeRateControlFlagsKHR; +typedef struct VkVideoEncodeInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeFlagsKHR flags; + VkBuffer dstBuffer; + VkDeviceSize dstBufferOffset; + VkDeviceSize dstBufferRange; + VkVideoPictureResourceInfoKHR srcPictureResource; + const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; + uint32_t precedingExternallyEncodedBytes; +} VkVideoEncodeInfoKHR; + +typedef struct VkVideoEncodeCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeCapabilityFlagsKHR flags; + VkVideoEncodeRateControlModeFlagsKHR rateControlModes; + uint32_t maxRateControlLayers; + uint64_t maxBitrate; + uint32_t maxQualityLevels; + VkExtent2D encodeInputPictureGranularity; + VkVideoEncodeFeedbackFlagsKHR supportedEncodeFeedbackFlags; +} VkVideoEncodeCapabilitiesKHR; + +typedef struct VkQueryPoolVideoEncodeFeedbackCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeFeedbackFlagsKHR encodeFeedbackFlags; +} VkQueryPoolVideoEncodeFeedbackCreateInfoKHR; -typedef VkPipelineStageFlagBits2 VkPipelineStageFlagBits2KHR; +typedef struct VkVideoEncodeUsageInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeUsageFlagsKHR videoUsageHints; + VkVideoEncodeContentFlagsKHR videoContentHints; + VkVideoEncodeTuningModeKHR tuningMode; +} VkVideoEncodeUsageInfoKHR; -typedef VkAccessFlags2 VkAccessFlags2KHR; +typedef struct VkVideoEncodeRateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + uint64_t averageBitrate; + uint64_t maxBitrate; + uint32_t frameRateNumerator; + uint32_t frameRateDenominator; +} VkVideoEncodeRateControlLayerInfoKHR; -typedef VkAccessFlagBits2 VkAccessFlagBits2KHR; +typedef struct VkVideoEncodeRateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeRateControlFlagsKHR flags; + VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode; + uint32_t layerCount; + const VkVideoEncodeRateControlLayerInfoKHR* pLayers; + uint32_t virtualBufferSizeInMs; + uint32_t initialVirtualBufferSizeInMs; +} VkVideoEncodeRateControlInfoKHR; + +typedef struct VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR { + VkStructureType sType; + const void* pNext; + const VkVideoProfileInfoKHR* pVideoProfile; + uint32_t qualityLevel; +} VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR; -typedef VkSubmitFlagBits VkSubmitFlagBitsKHR; +typedef struct VkVideoEncodeQualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeRateControlModeFlagBitsKHR preferredRateControlMode; + uint32_t preferredRateControlLayerCount; +} VkVideoEncodeQualityLevelPropertiesKHR; -typedef VkSubmitFlags VkSubmitFlagsKHR; +typedef struct VkVideoEncodeQualityLevelInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t qualityLevel; +} VkVideoEncodeQualityLevelInfoKHR; -typedef VkMemoryBarrier2 VkMemoryBarrier2KHR; +typedef struct VkVideoEncodeSessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoSessionParametersKHR videoSessionParameters; +} VkVideoEncodeSessionParametersGetInfoKHR; -typedef VkBufferMemoryBarrier2 VkBufferMemoryBarrier2KHR; +typedef struct VkVideoEncodeSessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasOverrides; +} VkVideoEncodeSessionParametersFeedbackInfoKHR; -typedef VkImageMemoryBarrier2 VkImageMemoryBarrier2KHR; +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR* pQualityLevelInfo, VkVideoEncodeQualityLevelPropertiesKHR* pQualityLevelProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetEncodedVideoSessionParametersKHR)(VkDevice device, const VkVideoEncodeSessionParametersGetInfoKHR* pVideoSessionParametersInfo, VkVideoEncodeSessionParametersFeedbackInfoKHR* pFeedbackInfo, size_t* pDataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo); -typedef VkDependencyInfo VkDependencyInfoKHR; +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR* pQualityLevelInfo, + VkVideoEncodeQualityLevelPropertiesKHR* pQualityLevelProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetEncodedVideoSessionParametersKHR( + VkDevice device, + const VkVideoEncodeSessionParametersGetInfoKHR* pVideoSessionParametersInfo, + VkVideoEncodeSessionParametersFeedbackInfoKHR* pFeedbackInfo, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR( + VkCommandBuffer commandBuffer, + const VkVideoEncodeInfoKHR* pEncodeInfo); +#endif + + +// VK_KHR_synchronization2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_synchronization2 1 +#define VK_KHR_SYNCHRONIZATION_2_SPEC_VERSION 1 +#define VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME "VK_KHR_synchronization2" +typedef VkPipelineStageFlags2 VkPipelineStageFlags2KHR; + +typedef VkPipelineStageFlagBits2 VkPipelineStageFlagBits2KHR; + +typedef VkAccessFlags2 VkAccessFlags2KHR; + +typedef VkAccessFlagBits2 VkAccessFlagBits2KHR; + +typedef VkSubmitFlagBits VkSubmitFlagBitsKHR; + +typedef VkSubmitFlags VkSubmitFlagsKHR; + +typedef VkMemoryBarrier2 VkMemoryBarrier2KHR; + +typedef VkBufferMemoryBarrier2 VkBufferMemoryBarrier2KHR; + +typedef VkImageMemoryBarrier2 VkImageMemoryBarrier2KHR; + +typedef VkDependencyInfo VkDependencyInfoKHR; typedef VkSubmitInfo2 VkSubmitInfo2KHR; @@ -9498,6 +10773,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointData2NV( #endif +// VK_KHR_fragment_shader_barycentric is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_fragment_shader_barycentric 1 #define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 #define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_KHR_fragment_shader_barycentric" @@ -9515,6 +10791,7 @@ typedef struct VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR { +// VK_KHR_shader_subgroup_uniform_control_flow is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_shader_subgroup_uniform_control_flow 1 #define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_SPEC_VERSION 1 #define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME "VK_KHR_shader_subgroup_uniform_control_flow" @@ -9526,6 +10803,7 @@ typedef struct VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR { +// VK_KHR_zero_initialize_workgroup_memory is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_zero_initialize_workgroup_memory 1 #define VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_SPEC_VERSION 1 #define VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_EXTENSION_NAME "VK_KHR_zero_initialize_workgroup_memory" @@ -9533,6 +10811,7 @@ typedef VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures VkPhysicalDeviceZe +// VK_KHR_workgroup_memory_explicit_layout is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_workgroup_memory_explicit_layout 1 #define VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_SPEC_VERSION 1 #define VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME "VK_KHR_workgroup_memory_explicit_layout" @@ -9547,6 +10826,7 @@ typedef struct VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR { +// VK_KHR_copy_commands2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_copy_commands2 1 #define VK_KHR_COPY_COMMANDS_2_SPEC_VERSION 1 #define VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME "VK_KHR_copy_commands2" @@ -9606,6 +10886,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage2KHR( #endif +// VK_KHR_format_feature_flags2 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_format_feature_flags2 1 #define VK_KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION 2 #define VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME "VK_KHR_format_feature_flags2" @@ -9617,6 +10898,7 @@ typedef VkFormatProperties3 VkFormatProperties3KHR; +// VK_KHR_ray_tracing_maintenance1 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_ray_tracing_maintenance1 1 #define VK_KHR_RAY_TRACING_MAINTENANCE_1_SPEC_VERSION 1 #define VK_KHR_RAY_TRACING_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_ray_tracing_maintenance1" @@ -9653,11 +10935,13 @@ VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirect2KHR( #endif +// VK_KHR_portability_enumeration is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_portability_enumeration 1 #define VK_KHR_PORTABILITY_ENUMERATION_SPEC_VERSION 1 #define VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME "VK_KHR_portability_enumeration" +// VK_KHR_maintenance4 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_maintenance4 1 #define VK_KHR_MAINTENANCE_4_SPEC_VERSION 2 #define VK_KHR_MAINTENANCE_4_EXTENSION_NAME "VK_KHR_maintenance4" @@ -9692,6 +10976,473 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirementsKHR( #endif +// VK_KHR_maintenance5 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance5 1 +#define VK_KHR_MAINTENANCE_5_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_5_EXTENSION_NAME "VK_KHR_maintenance5" +typedef VkFlags64 VkPipelineCreateFlags2KHR; + +// Flag bits for VkPipelineCreateFlagBits2KHR +typedef VkFlags64 VkPipelineCreateFlagBits2KHR; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DISABLE_OPTIMIZATION_BIT_KHR = 0x00000001ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_ALLOW_DERIVATIVES_BIT_KHR = 0x00000002ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DERIVATIVE_BIT_KHR = 0x00000004ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = 0x00000008ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DISPATCH_BASE_BIT_KHR = 0x00000010ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DEFER_COMPILE_BIT_NV = 0x00000020ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_CAPTURE_STATISTICS_BIT_KHR = 0x00000040ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR = 0x00000100ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_EARLY_RETURN_ON_FAILURE_BIT_KHR = 0x00000200ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_LINK_TIME_OPTIMIZATION_BIT_EXT = 0x00000400ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT = 0x00800000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR = 0x00000800ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR = 0x00001000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_AABBS_BIT_KHR = 0x00002000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR = 0x00004000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR = 0x00008000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR = 0x00010000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR = 0x00020000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR = 0x00080000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_INDIRECT_BINDABLE_BIT_NV = 0x00040000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_MOTION_BIT_NV = 0x00100000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00200000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00400000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT = 0x01000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x02000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x04000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_NO_PROTECTED_ACCESS_BIT_EXT = 0x08000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_PROTECTED_ACCESS_ONLY_BIT_EXT = 0x40000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV = 0x10000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DESCRIPTOR_BUFFER_BIT_EXT = 0x20000000ULL; + +typedef VkFlags64 VkBufferUsageFlags2KHR; + +// Flag bits for VkBufferUsageFlagBits2KHR +typedef VkFlags64 VkBufferUsageFlagBits2KHR; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFER_SRC_BIT_KHR = 0x00000001ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFER_DST_BIT_KHR = 0x00000002ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR = 0x00000004ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BIT_KHR = 0x00000008ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_UNIFORM_BUFFER_BIT_KHR = 0x00000010ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_STORAGE_BUFFER_BIT_KHR = 0x00000020ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_INDEX_BUFFER_BIT_KHR = 0x00000040ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VERTEX_BUFFER_BIT_KHR = 0x00000080ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_INDIRECT_BUFFER_BIT_KHR = 0x00000100ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_EXECUTION_GRAPH_SCRATCH_BIT_AMDX = 0x02000000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SHADER_BINDING_TABLE_BIT_KHR = 0x00000400ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_RAY_TRACING_BIT_NV = 0x00000400ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_DECODE_SRC_BIT_KHR = 0x00002000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_DECODE_DST_BIT_KHR = 0x00004000ULL; +#ifdef VK_ENABLE_BETA_EXTENSIONS +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_ENCODE_DST_BIT_KHR = 0x00008000ULL; +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_ENCODE_SRC_BIT_KHR = 0x00010000ULL; +#endif +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SHADER_DEVICE_ADDRESS_BIT_KHR = 0x00020000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR = 0x00080000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR = 0x00100000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT = 0x00200000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00400000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT = 0x04000000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT = 0x00800000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_MICROMAP_STORAGE_BIT_EXT = 0x01000000ULL; + +typedef struct VkPhysicalDeviceMaintenance5FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 maintenance5; +} VkPhysicalDeviceMaintenance5FeaturesKHR; + +typedef struct VkPhysicalDeviceMaintenance5PropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 earlyFragmentMultisampleCoverageAfterSampleCounting; + VkBool32 earlyFragmentSampleMaskTestBeforeSampleCounting; + VkBool32 depthStencilSwizzleOneSupport; + VkBool32 polygonModePointSize; + VkBool32 nonStrictSinglePixelWideLinesUseParallelogram; + VkBool32 nonStrictWideLinesUseParallelogram; +} VkPhysicalDeviceMaintenance5PropertiesKHR; + +typedef struct VkRenderingAreaInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t viewMask; + uint32_t colorAttachmentCount; + const VkFormat* pColorAttachmentFormats; + VkFormat depthAttachmentFormat; + VkFormat stencilAttachmentFormat; +} VkRenderingAreaInfoKHR; + +typedef struct VkImageSubresource2KHR { + VkStructureType sType; + void* pNext; + VkImageSubresource imageSubresource; +} VkImageSubresource2KHR; + +typedef struct VkDeviceImageSubresourceInfoKHR { + VkStructureType sType; + const void* pNext; + const VkImageCreateInfo* pCreateInfo; + const VkImageSubresource2KHR* pSubresource; +} VkDeviceImageSubresourceInfoKHR; + +typedef struct VkSubresourceLayout2KHR { + VkStructureType sType; + void* pNext; + VkSubresourceLayout subresourceLayout; +} VkSubresourceLayout2KHR; + +typedef struct VkPipelineCreateFlags2CreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags2KHR flags; +} VkPipelineCreateFlags2CreateInfoKHR; + +typedef struct VkBufferUsageFlags2CreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBufferUsageFlags2KHR usage; +} VkBufferUsageFlags2CreateInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer2KHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, VkIndexType indexType); +typedef void (VKAPI_PTR *PFN_vkGetRenderingAreaGranularityKHR)(VkDevice device, const VkRenderingAreaInfoKHR* pRenderingAreaInfo, VkExtent2D* pGranularity); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageSubresourceLayoutKHR)(VkDevice device, const VkDeviceImageSubresourceInfoKHR* pInfo, VkSubresourceLayout2KHR* pLayout); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2KHR)(VkDevice device, VkImage image, const VkImageSubresource2KHR* pSubresource, VkSubresourceLayout2KHR* pLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer2KHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkDeviceSize size, + VkIndexType indexType); + +VKAPI_ATTR void VKAPI_CALL vkGetRenderingAreaGranularityKHR( + VkDevice device, + const VkRenderingAreaInfoKHR* pRenderingAreaInfo, + VkExtent2D* pGranularity); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSubresourceLayoutKHR( + VkDevice device, + const VkDeviceImageSubresourceInfoKHR* pInfo, + VkSubresourceLayout2KHR* pLayout); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2KHR( + VkDevice device, + VkImage image, + const VkImageSubresource2KHR* pSubresource, + VkSubresourceLayout2KHR* pLayout); +#endif + + +// VK_KHR_ray_tracing_position_fetch is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_ray_tracing_position_fetch 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME "VK_KHR_ray_tracing_position_fetch" +typedef struct VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingPositionFetch; +} VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR; + + + +// VK_KHR_cooperative_matrix is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_cooperative_matrix 1 +#define VK_KHR_COOPERATIVE_MATRIX_SPEC_VERSION 2 +#define VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME "VK_KHR_cooperative_matrix" + +typedef enum VkComponentTypeKHR { + VK_COMPONENT_TYPE_FLOAT16_KHR = 0, + VK_COMPONENT_TYPE_FLOAT32_KHR = 1, + VK_COMPONENT_TYPE_FLOAT64_KHR = 2, + VK_COMPONENT_TYPE_SINT8_KHR = 3, + VK_COMPONENT_TYPE_SINT16_KHR = 4, + VK_COMPONENT_TYPE_SINT32_KHR = 5, + VK_COMPONENT_TYPE_SINT64_KHR = 6, + VK_COMPONENT_TYPE_UINT8_KHR = 7, + VK_COMPONENT_TYPE_UINT16_KHR = 8, + VK_COMPONENT_TYPE_UINT32_KHR = 9, + VK_COMPONENT_TYPE_UINT64_KHR = 10, + VK_COMPONENT_TYPE_FLOAT16_NV = VK_COMPONENT_TYPE_FLOAT16_KHR, + VK_COMPONENT_TYPE_FLOAT32_NV = VK_COMPONENT_TYPE_FLOAT32_KHR, + VK_COMPONENT_TYPE_FLOAT64_NV = VK_COMPONENT_TYPE_FLOAT64_KHR, + VK_COMPONENT_TYPE_SINT8_NV = VK_COMPONENT_TYPE_SINT8_KHR, + VK_COMPONENT_TYPE_SINT16_NV = VK_COMPONENT_TYPE_SINT16_KHR, + VK_COMPONENT_TYPE_SINT32_NV = VK_COMPONENT_TYPE_SINT32_KHR, + VK_COMPONENT_TYPE_SINT64_NV = VK_COMPONENT_TYPE_SINT64_KHR, + VK_COMPONENT_TYPE_UINT8_NV = VK_COMPONENT_TYPE_UINT8_KHR, + VK_COMPONENT_TYPE_UINT16_NV = VK_COMPONENT_TYPE_UINT16_KHR, + VK_COMPONENT_TYPE_UINT32_NV = VK_COMPONENT_TYPE_UINT32_KHR, + VK_COMPONENT_TYPE_UINT64_NV = VK_COMPONENT_TYPE_UINT64_KHR, + VK_COMPONENT_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkComponentTypeKHR; + +typedef enum VkScopeKHR { + VK_SCOPE_DEVICE_KHR = 1, + VK_SCOPE_WORKGROUP_KHR = 2, + VK_SCOPE_SUBGROUP_KHR = 3, + VK_SCOPE_QUEUE_FAMILY_KHR = 5, + VK_SCOPE_DEVICE_NV = VK_SCOPE_DEVICE_KHR, + VK_SCOPE_WORKGROUP_NV = VK_SCOPE_WORKGROUP_KHR, + VK_SCOPE_SUBGROUP_NV = VK_SCOPE_SUBGROUP_KHR, + VK_SCOPE_QUEUE_FAMILY_NV = VK_SCOPE_QUEUE_FAMILY_KHR, + VK_SCOPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkScopeKHR; +typedef struct VkCooperativeMatrixPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t MSize; + uint32_t NSize; + uint32_t KSize; + VkComponentTypeKHR AType; + VkComponentTypeKHR BType; + VkComponentTypeKHR CType; + VkComponentTypeKHR ResultType; + VkBool32 saturatingAccumulation; + VkScopeKHR scope; +} VkCooperativeMatrixPropertiesKHR; + +typedef struct VkPhysicalDeviceCooperativeMatrixFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 cooperativeMatrix; + VkBool32 cooperativeMatrixRobustBufferAccess; +} VkPhysicalDeviceCooperativeMatrixFeaturesKHR; + +typedef struct VkPhysicalDeviceCooperativeMatrixPropertiesKHR { + VkStructureType sType; + void* pNext; + VkShaderStageFlags cooperativeMatrixSupportedStages; +} VkPhysicalDeviceCooperativeMatrixPropertiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesKHR* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkCooperativeMatrixPropertiesKHR* pProperties); +#endif + + +// VK_KHR_video_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_maintenance1 1 +#define VK_KHR_VIDEO_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_KHR_VIDEO_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_video_maintenance1" +typedef struct VkPhysicalDeviceVideoMaintenance1FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 videoMaintenance1; +} VkPhysicalDeviceVideoMaintenance1FeaturesKHR; + +typedef struct VkVideoInlineQueryInfoKHR { + VkStructureType sType; + const void* pNext; + VkQueryPool queryPool; + uint32_t firstQuery; + uint32_t queryCount; +} VkVideoInlineQueryInfoKHR; + + + +// VK_KHR_vertex_attribute_divisor is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_vertex_attribute_divisor 1 +#define VK_KHR_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION 1 +#define VK_KHR_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME "VK_KHR_vertex_attribute_divisor" +typedef struct VkPhysicalDeviceVertexAttributeDivisorPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t maxVertexAttribDivisor; + VkBool32 supportsNonZeroFirstInstance; +} VkPhysicalDeviceVertexAttributeDivisorPropertiesKHR; + +typedef struct VkVertexInputBindingDivisorDescriptionKHR { + uint32_t binding; + uint32_t divisor; +} VkVertexInputBindingDivisorDescriptionKHR; + +typedef struct VkPipelineVertexInputDivisorStateCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t vertexBindingDivisorCount; + const VkVertexInputBindingDivisorDescriptionKHR* pVertexBindingDivisors; +} VkPipelineVertexInputDivisorStateCreateInfoKHR; + +typedef struct VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 vertexAttributeInstanceRateDivisor; + VkBool32 vertexAttributeInstanceRateZeroDivisor; +} VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR; + + + +// VK_KHR_calibrated_timestamps is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_calibrated_timestamps 1 +#define VK_KHR_CALIBRATED_TIMESTAMPS_SPEC_VERSION 1 +#define VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME "VK_KHR_calibrated_timestamps" + +typedef enum VkTimeDomainKHR { + VK_TIME_DOMAIN_DEVICE_KHR = 0, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR = 1, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR = 2, + VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR = 3, + VK_TIME_DOMAIN_DEVICE_EXT = VK_TIME_DOMAIN_DEVICE_KHR, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT = VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT = VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR, + VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR, + VK_TIME_DOMAIN_MAX_ENUM_KHR = 0x7FFFFFFF +} VkTimeDomainKHR; +typedef struct VkCalibratedTimestampInfoKHR { + VkStructureType sType; + const void* pNext; + VkTimeDomainKHR timeDomain; +} VkCalibratedTimestampInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainKHR* pTimeDomains); +typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsKHR)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pTimeDomainCount, + VkTimeDomainKHR* pTimeDomains); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsKHR( + VkDevice device, + uint32_t timestampCount, + const VkCalibratedTimestampInfoKHR* pTimestampInfos, + uint64_t* pTimestamps, + uint64_t* pMaxDeviation); +#endif + + +// VK_KHR_maintenance6 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance6 1 +#define VK_KHR_MAINTENANCE_6_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_6_EXTENSION_NAME "VK_KHR_maintenance6" +typedef struct VkPhysicalDeviceMaintenance6FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 maintenance6; +} VkPhysicalDeviceMaintenance6FeaturesKHR; + +typedef struct VkPhysicalDeviceMaintenance6PropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 blockTexelViewCompatibleMultipleLayers; + uint32_t maxCombinedImageSamplerDescriptorCount; + VkBool32 fragmentShadingRateClampCombinerInputs; +} VkPhysicalDeviceMaintenance6PropertiesKHR; + +typedef struct VkBindMemoryStatusKHR { + VkStructureType sType; + const void* pNext; + VkResult* pResult; +} VkBindMemoryStatusKHR; + +typedef struct VkBindDescriptorSetsInfoKHR { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t firstSet; + uint32_t descriptorSetCount; + const VkDescriptorSet* pDescriptorSets; + uint32_t dynamicOffsetCount; + const uint32_t* pDynamicOffsets; +} VkBindDescriptorSetsInfoKHR; + +typedef struct VkPushConstantsInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipelineLayout layout; + VkShaderStageFlags stageFlags; + uint32_t offset; + uint32_t size; + const void* pValues; +} VkPushConstantsInfoKHR; + +typedef struct VkPushDescriptorSetInfoKHR { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t set; + uint32_t descriptorWriteCount; + const VkWriteDescriptorSet* pDescriptorWrites; +} VkPushDescriptorSetInfoKHR; + +typedef struct VkPushDescriptorSetWithTemplateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDescriptorUpdateTemplate descriptorUpdateTemplate; + VkPipelineLayout layout; + uint32_t set; + const void* pData; +} VkPushDescriptorSetWithTemplateInfoKHR; + +typedef struct VkSetDescriptorBufferOffsetsInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t firstSet; + uint32_t setCount; + const uint32_t* pBufferIndices; + const VkDeviceSize* pOffsets; +} VkSetDescriptorBufferOffsetsInfoEXT; + +typedef struct VkBindDescriptorBufferEmbeddedSamplersInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t set; +} VkBindDescriptorBufferEmbeddedSamplersInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets2KHR)(VkCommandBuffer commandBuffer, const VkBindDescriptorSetsInfoKHR* pBindDescriptorSetsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushConstants2KHR)(VkCommandBuffer commandBuffer, const VkPushConstantsInfoKHR* pPushConstantsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSet2KHR)(VkCommandBuffer commandBuffer, const VkPushDescriptorSetInfoKHR* pPushDescriptorSetInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplate2KHR)(VkCommandBuffer commandBuffer, const VkPushDescriptorSetWithTemplateInfoKHR* pPushDescriptorSetWithTemplateInfo); +typedef void (VKAPI_PTR *PFN_vkCmdSetDescriptorBufferOffsets2EXT)(VkCommandBuffer commandBuffer, const VkSetDescriptorBufferOffsetsInfoEXT* pSetDescriptorBufferOffsetsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT)(VkCommandBuffer commandBuffer, const VkBindDescriptorBufferEmbeddedSamplersInfoEXT* pBindDescriptorBufferEmbeddedSamplersInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets2KHR( + VkCommandBuffer commandBuffer, + const VkBindDescriptorSetsInfoKHR* pBindDescriptorSetsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants2KHR( + VkCommandBuffer commandBuffer, + const VkPushConstantsInfoKHR* pPushConstantsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSet2KHR( + VkCommandBuffer commandBuffer, + const VkPushDescriptorSetInfoKHR* pPushDescriptorSetInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplate2KHR( + VkCommandBuffer commandBuffer, + const VkPushDescriptorSetWithTemplateInfoKHR* pPushDescriptorSetWithTemplateInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDescriptorBufferOffsets2EXT( + VkCommandBuffer commandBuffer, + const VkSetDescriptorBufferOffsetsInfoEXT* pSetDescriptorBufferOffsetsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBufferEmbeddedSamplers2EXT( + VkCommandBuffer commandBuffer, + const VkBindDescriptorBufferEmbeddedSamplersInfoEXT* pBindDescriptorBufferEmbeddedSamplersInfo); +#endif + + +// VK_EXT_debug_report is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_debug_report 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) #define VK_EXT_DEBUG_REPORT_SPEC_VERSION 10 @@ -9736,6 +11487,8 @@ typedef enum VkDebugReportObjectTypeEXT { VK_DEBUG_REPORT_OBJECT_TYPE_CU_FUNCTION_NVX_EXT = 1000029001, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT = 1000150000, VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT = 1000165000, + VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_MODULE_NV_EXT = 1000307000, + VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_FUNCTION_NV_EXT = 1000307001, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA_EXT = 1000366000, VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT, @@ -9799,21 +11552,25 @@ VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( #endif +// VK_NV_glsl_shader is a preprocessor guard. Do not pass it to API calls. #define VK_NV_glsl_shader 1 #define VK_NV_GLSL_SHADER_SPEC_VERSION 1 #define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader" +// VK_EXT_depth_range_unrestricted is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_depth_range_unrestricted 1 #define VK_EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION 1 #define VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME "VK_EXT_depth_range_unrestricted" +// VK_IMG_filter_cubic is a preprocessor guard. Do not pass it to API calls. #define VK_IMG_filter_cubic 1 #define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1 #define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic" +// VK_AMD_rasterization_order is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_rasterization_order 1 #define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1 #define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order" @@ -9831,16 +11588,19 @@ typedef struct VkPipelineRasterizationStateRasterizationOrderAMD { +// VK_AMD_shader_trinary_minmax is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_trinary_minmax 1 #define VK_AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION 1 #define VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME "VK_AMD_shader_trinary_minmax" +// VK_AMD_shader_explicit_vertex_parameter is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_explicit_vertex_parameter 1 #define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION 1 #define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME "VK_AMD_shader_explicit_vertex_parameter" +// VK_EXT_debug_marker is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_debug_marker 1 #define VK_EXT_DEBUG_MARKER_SPEC_VERSION 4 #define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker" @@ -9897,11 +11657,13 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( #endif +// VK_AMD_gcn_shader is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_gcn_shader 1 #define VK_AMD_GCN_SHADER_SPEC_VERSION 1 #define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader" +// VK_NV_dedicated_allocation is a preprocessor guard. Do not pass it to API calls. #define VK_NV_dedicated_allocation 1 #define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1 #define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation" @@ -9926,6 +11688,7 @@ typedef struct VkDedicatedAllocationMemoryAllocateInfoNV { +// VK_EXT_transform_feedback is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_transform_feedback 1 #define VK_EXT_TRANSFORM_FEEDBACK_SPEC_VERSION 1 #define VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME "VK_EXT_transform_feedback" @@ -10013,6 +11776,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectByteCountEXT( #endif +// VK_NVX_binary_import is a preprocessor guard. Do not pass it to API calls. #define VK_NVX_binary_import 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCuModuleNVX) VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCuFunctionNVX) @@ -10084,6 +11848,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdCuLaunchKernelNVX( #endif +// VK_NVX_image_view_handle is a preprocessor guard. Do not pass it to API calls. #define VK_NVX_image_view_handle 1 #define VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION 2 #define VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME "VK_NVX_image_view_handle" @@ -10117,6 +11882,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetImageViewAddressNVX( #endif +// VK_AMD_draw_indirect_count is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_draw_indirect_count 1 #define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 2 #define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count" @@ -10144,21 +11910,25 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( #endif +// VK_AMD_negative_viewport_height is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_negative_viewport_height 1 #define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1 #define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height" +// VK_AMD_gpu_shader_half_float is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_gpu_shader_half_float 1 #define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 2 #define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float" +// VK_AMD_shader_ballot is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_ballot 1 #define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1 #define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot" +// VK_AMD_texture_gather_bias_lod is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_texture_gather_bias_lod 1 #define VK_AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION 1 #define VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME "VK_AMD_texture_gather_bias_lod" @@ -10170,6 +11940,7 @@ typedef struct VkTextureLODGatherFormatPropertiesAMD { +// VK_AMD_shader_info is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_info 1 #define VK_AMD_SHADER_INFO_SPEC_VERSION 1 #define VK_AMD_SHADER_INFO_EXTENSION_NAME "VK_AMD_shader_info" @@ -10211,11 +11982,13 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderInfoAMD( #endif +// VK_AMD_shader_image_load_store_lod is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_image_load_store_lod 1 #define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION 1 #define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME "VK_AMD_shader_image_load_store_lod" +// VK_NV_corner_sampled_image is a preprocessor guard. Do not pass it to API calls. #define VK_NV_corner_sampled_image 1 #define VK_NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION 2 #define VK_NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME "VK_NV_corner_sampled_image" @@ -10227,11 +12000,13 @@ typedef struct VkPhysicalDeviceCornerSampledImageFeaturesNV { +// VK_IMG_format_pvrtc is a preprocessor guard. Do not pass it to API calls. #define VK_IMG_format_pvrtc 1 #define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1 #define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc" +// VK_NV_external_memory_capabilities is a preprocessor guard. Do not pass it to API calls. #define VK_NV_external_memory_capabilities 1 #define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 #define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities" @@ -10274,6 +12049,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesN #endif +// VK_NV_external_memory is a preprocessor guard. Do not pass it to API calls. #define VK_NV_external_memory 1 #define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1 #define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory" @@ -10291,8 +12067,9 @@ typedef struct VkExportMemoryAllocateInfoNV { +// VK_EXT_validation_flags is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_validation_flags 1 -#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 2 +#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 3 #define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags" typedef enum VkValidationCheckEXT { @@ -10309,16 +12086,19 @@ typedef struct VkValidationFlagsEXT { +// VK_EXT_shader_subgroup_ballot is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_subgroup_ballot 1 #define VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION 1 #define VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME "VK_EXT_shader_subgroup_ballot" +// VK_EXT_shader_subgroup_vote is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_subgroup_vote 1 #define VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION 1 #define VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME "VK_EXT_shader_subgroup_vote" +// VK_EXT_texture_compression_astc_hdr is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_texture_compression_astc_hdr 1 #define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION 1 #define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME "VK_EXT_texture_compression_astc_hdr" @@ -10326,6 +12106,7 @@ typedef VkPhysicalDeviceTextureCompressionASTCHDRFeatures VkPhysicalDeviceTextur +// VK_EXT_astc_decode_mode is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_astc_decode_mode 1 #define VK_EXT_ASTC_DECODE_MODE_SPEC_VERSION 1 #define VK_EXT_ASTC_DECODE_MODE_EXTENSION_NAME "VK_EXT_astc_decode_mode" @@ -10343,6 +12124,7 @@ typedef struct VkPhysicalDeviceASTCDecodeFeaturesEXT { +// VK_EXT_pipeline_robustness is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_pipeline_robustness 1 #define VK_EXT_PIPELINE_ROBUSTNESS_SPEC_VERSION 1 #define VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME "VK_EXT_pipeline_robustness" @@ -10388,6 +12170,7 @@ typedef struct VkPipelineRobustnessCreateInfoEXT { +// VK_EXT_conditional_rendering is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_conditional_rendering 1 #define VK_EXT_CONDITIONAL_RENDERING_SPEC_VERSION 2 #define VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME "VK_EXT_conditional_rendering" @@ -10431,6 +12214,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdEndConditionalRenderingEXT( #endif +// VK_NV_clip_space_w_scaling is a preprocessor guard. Do not pass it to API calls. #define VK_NV_clip_space_w_scaling 1 #define VK_NV_CLIP_SPACE_W_SCALING_SPEC_VERSION 1 #define VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME "VK_NV_clip_space_w_scaling" @@ -10458,6 +12242,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingNV( #endif +// VK_EXT_direct_mode_display is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_direct_mode_display 1 #define VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION 1 #define VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME "VK_EXT_direct_mode_display" @@ -10470,6 +12255,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT( #endif +// VK_EXT_display_surface_counter is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_display_surface_counter 1 #define VK_EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION 1 #define VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME "VK_EXT_display_surface_counter" @@ -10506,6 +12292,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT( #endif +// VK_EXT_display_control is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_display_control 1 #define VK_EXT_DISPLAY_CONTROL_SPEC_VERSION 1 #define VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME "VK_EXT_display_control" @@ -10582,6 +12369,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainCounterEXT( #endif +// VK_GOOGLE_display_timing is a preprocessor guard. Do not pass it to API calls. #define VK_GOOGLE_display_timing 1 #define VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION 1 #define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing" @@ -10626,16 +12414,19 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE( #endif +// VK_NV_sample_mask_override_coverage is a preprocessor guard. Do not pass it to API calls. #define VK_NV_sample_mask_override_coverage 1 #define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION 1 #define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME "VK_NV_sample_mask_override_coverage" +// VK_NV_geometry_shader_passthrough is a preprocessor guard. Do not pass it to API calls. #define VK_NV_geometry_shader_passthrough 1 #define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION 1 #define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME "VK_NV_geometry_shader_passthrough" +// VK_NV_viewport_array2 is a preprocessor guard. Do not pass it to API calls. #define VK_NV_viewport_array2 1 #define VK_NV_VIEWPORT_ARRAY_2_SPEC_VERSION 1 #define VK_NV_VIEWPORT_ARRAY_2_EXTENSION_NAME "VK_NV_viewport_array2" @@ -10643,6 +12434,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE( #define VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME VK_NV_VIEWPORT_ARRAY_2_EXTENSION_NAME +// VK_NVX_multiview_per_view_attributes is a preprocessor guard. Do not pass it to API calls. #define VK_NVX_multiview_per_view_attributes 1 #define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION 1 #define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME "VK_NVX_multiview_per_view_attributes" @@ -10654,6 +12446,7 @@ typedef struct VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX { +// VK_NV_viewport_swizzle is a preprocessor guard. Do not pass it to API calls. #define VK_NV_viewport_swizzle 1 #define VK_NV_VIEWPORT_SWIZZLE_SPEC_VERSION 1 #define VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME "VK_NV_viewport_swizzle" @@ -10687,8 +12480,9 @@ typedef struct VkPipelineViewportSwizzleStateCreateInfoNV { +// VK_EXT_discard_rectangles is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_discard_rectangles 1 -#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1 +#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 2 #define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" typedef enum VkDiscardRectangleModeEXT { @@ -10713,6 +12507,8 @@ typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { } VkPipelineDiscardRectangleStateCreateInfoEXT; typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 discardRectangleEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleModeEXT)(VkCommandBuffer commandBuffer, VkDiscardRectangleModeEXT discardRectangleMode); #ifndef VK_NO_PROTOTYPES VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( @@ -10720,9 +12516,18 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 discardRectangleEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleModeEXT( + VkCommandBuffer commandBuffer, + VkDiscardRectangleModeEXT discardRectangleMode); #endif +// VK_EXT_conservative_rasterization is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_conservative_rasterization 1 #define VK_EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION 1 #define VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME "VK_EXT_conservative_rasterization" @@ -10758,6 +12563,7 @@ typedef struct VkPipelineRasterizationConservativeStateCreateInfoEXT { +// VK_EXT_depth_clip_enable is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_depth_clip_enable 1 #define VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION 1 #define VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME "VK_EXT_depth_clip_enable" @@ -10777,11 +12583,13 @@ typedef struct VkPipelineRasterizationDepthClipStateCreateInfoEXT { +// VK_EXT_swapchain_colorspace is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_swapchain_colorspace 1 #define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 4 #define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace" +// VK_EXT_hdr_metadata is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_hdr_metadata 1 #define VK_EXT_HDR_METADATA_SPEC_VERSION 2 #define VK_EXT_HDR_METADATA_EXTENSION_NAME "VK_EXT_hdr_metadata" @@ -10814,17 +12622,32 @@ VKAPI_ATTR void VKAPI_CALL vkSetHdrMetadataEXT( #endif +// VK_IMG_relaxed_line_rasterization is a preprocessor guard. Do not pass it to API calls. +#define VK_IMG_relaxed_line_rasterization 1 +#define VK_IMG_RELAXED_LINE_RASTERIZATION_SPEC_VERSION 1 +#define VK_IMG_RELAXED_LINE_RASTERIZATION_EXTENSION_NAME "VK_IMG_relaxed_line_rasterization" +typedef struct VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG { + VkStructureType sType; + void* pNext; + VkBool32 relaxedLineRasterization; +} VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG; + + + +// VK_EXT_external_memory_dma_buf is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_external_memory_dma_buf 1 #define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION 1 #define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME "VK_EXT_external_memory_dma_buf" +// VK_EXT_queue_family_foreign is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_queue_family_foreign 1 #define VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION 1 #define VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME "VK_EXT_queue_family_foreign" #define VK_QUEUE_FAMILY_FOREIGN_EXT (~2U) +// VK_EXT_debug_utils is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_debug_utils 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugUtilsMessengerEXT) #define VK_EXT_DEBUG_UTILS_SPEC_VERSION 2 @@ -10843,6 +12666,7 @@ typedef enum VkDebugUtilsMessageTypeFlagBitsEXT { VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT = 0x00000001, VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT = 0x00000002, VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT = 0x00000004, + VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT = 0x00000008, VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF } VkDebugUtilsMessageTypeFlagBitsEXT; typedef VkFlags VkDebugUtilsMessageTypeFlagsEXT; @@ -10966,6 +12790,7 @@ VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT( #endif +// VK_EXT_sampler_filter_minmax is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_sampler_filter_minmax 1 #define VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION 2 #define VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME "VK_EXT_sampler_filter_minmax" @@ -10977,21 +12802,25 @@ typedef VkPhysicalDeviceSamplerFilterMinmaxProperties VkPhysicalDeviceSamplerFil +// VK_AMD_gpu_shader_int16 is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_gpu_shader_int16 1 #define VK_AMD_GPU_SHADER_INT16_SPEC_VERSION 2 #define VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME "VK_AMD_gpu_shader_int16" +// VK_AMD_mixed_attachment_samples is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_mixed_attachment_samples 1 #define VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION 1 #define VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME "VK_AMD_mixed_attachment_samples" +// VK_AMD_shader_fragment_mask is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_fragment_mask 1 #define VK_AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION 1 #define VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME "VK_AMD_shader_fragment_mask" +// VK_EXT_inline_uniform_block is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_inline_uniform_block 1 #define VK_EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION 1 #define VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME "VK_EXT_inline_uniform_block" @@ -11005,11 +12834,13 @@ typedef VkDescriptorPoolInlineUniformBlockCreateInfo VkDescriptorPoolInlineUnifo +// VK_EXT_shader_stencil_export is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_stencil_export 1 #define VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION 1 #define VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME "VK_EXT_shader_stencil_export" +// VK_EXT_sample_locations is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_sample_locations 1 #define VK_EXT_SAMPLE_LOCATIONS_SPEC_VERSION 1 #define VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME "VK_EXT_sample_locations" @@ -11084,6 +12915,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT( #endif +// VK_EXT_blend_operation_advanced is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_blend_operation_advanced 1 #define VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION 2 #define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME "VK_EXT_blend_operation_advanced" @@ -11121,6 +12953,7 @@ typedef struct VkPipelineColorBlendAdvancedStateCreateInfoEXT { +// VK_NV_fragment_coverage_to_color is a preprocessor guard. Do not pass it to API calls. #define VK_NV_fragment_coverage_to_color 1 #define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION 1 #define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME "VK_NV_fragment_coverage_to_color" @@ -11135,6 +12968,7 @@ typedef struct VkPipelineCoverageToColorStateCreateInfoNV { +// VK_NV_framebuffer_mixed_samples is a preprocessor guard. Do not pass it to API calls. #define VK_NV_framebuffer_mixed_samples 1 #define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION 1 #define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME "VK_NV_framebuffer_mixed_samples" @@ -11159,11 +12993,13 @@ typedef struct VkPipelineCoverageModulationStateCreateInfoNV { +// VK_NV_fill_rectangle is a preprocessor guard. Do not pass it to API calls. #define VK_NV_fill_rectangle 1 #define VK_NV_FILL_RECTANGLE_SPEC_VERSION 1 #define VK_NV_FILL_RECTANGLE_EXTENSION_NAME "VK_NV_fill_rectangle" +// VK_NV_shader_sm_builtins is a preprocessor guard. Do not pass it to API calls. #define VK_NV_shader_sm_builtins 1 #define VK_NV_SHADER_SM_BUILTINS_SPEC_VERSION 1 #define VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME "VK_NV_shader_sm_builtins" @@ -11182,11 +13018,13 @@ typedef struct VkPhysicalDeviceShaderSMBuiltinsFeaturesNV { +// VK_EXT_post_depth_coverage is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_post_depth_coverage 1 #define VK_EXT_POST_DEPTH_COVERAGE_SPEC_VERSION 1 #define VK_EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME "VK_EXT_post_depth_coverage" +// VK_EXT_image_drm_format_modifier is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_drm_format_modifier 1 #define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION 2 #define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME "VK_EXT_image_drm_format_modifier" @@ -11256,6 +13094,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetImageDrmFormatModifierPropertiesEXT( #endif +// VK_EXT_validation_cache is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_validation_cache 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT) #define VK_EXT_VALIDATION_CACHE_SPEC_VERSION 1 @@ -11311,6 +13150,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetValidationCacheDataEXT( #endif +// VK_EXT_descriptor_indexing is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_descriptor_indexing 1 #define VK_EXT_DESCRIPTOR_INDEXING_SPEC_VERSION 2 #define VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME "VK_EXT_descriptor_indexing" @@ -11330,11 +13170,13 @@ typedef VkDescriptorSetVariableDescriptorCountLayoutSupport VkDescriptorSetVaria +// VK_EXT_shader_viewport_index_layer is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_viewport_index_layer 1 #define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION 1 #define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME "VK_EXT_shader_viewport_index_layer" +// VK_NV_shading_rate_image is a preprocessor guard. Do not pass it to API calls. #define VK_NV_shading_rate_image 1 #define VK_NV_SHADING_RATE_IMAGE_SPEC_VERSION 3 #define VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME "VK_NV_shading_rate_image" @@ -11435,6 +13277,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetCoarseSampleOrderNV( #endif +// VK_NV_ray_tracing is a preprocessor guard. Do not pass it to API calls. #define VK_NV_ray_tracing 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureNV) #define VK_NV_RAY_TRACING_SPEC_VERSION 3 @@ -11513,6 +13356,8 @@ typedef enum VkGeometryInstanceFlagBitsKHR { VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR = 0x00000002, VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR = 0x00000004, VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR = 0x00000008, + VK_GEOMETRY_INSTANCE_FORCE_OPACITY_MICROMAP_2_STATE_EXT = 0x00000010, + VK_GEOMETRY_INSTANCE_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000020, VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR = VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR, VK_GEOMETRY_INSTANCE_TRIANGLE_CULL_DISABLE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR, VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR, @@ -11533,6 +13378,13 @@ typedef enum VkBuildAccelerationStructureFlagBitsKHR { VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR = 0x00000008, VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR = 0x00000010, VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV = 0x00000020, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_UPDATE_EXT = 0x00000040, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000080, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_DATA_UPDATE_EXT = 0x00000100, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV = 0x00000200, +#endif + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR = 0x00000800, VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR, VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR, VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR, @@ -11804,6 +13656,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCompileDeferredNV( #endif +// VK_NV_representative_fragment_test is a preprocessor guard. Do not pass it to API calls. #define VK_NV_representative_fragment_test 1 #define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION 2 #define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME "VK_NV_representative_fragment_test" @@ -11821,6 +13674,7 @@ typedef struct VkPipelineRepresentativeFragmentTestStateCreateInfoNV { +// VK_EXT_filter_cubic is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_filter_cubic 1 #define VK_EXT_FILTER_CUBIC_SPEC_VERSION 3 #define VK_EXT_FILTER_CUBIC_EXTENSION_NAME "VK_EXT_filter_cubic" @@ -11839,11 +13693,13 @@ typedef struct VkFilterCubicImageViewImageFormatPropertiesEXT { +// VK_QCOM_render_pass_shader_resolve is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_render_pass_shader_resolve 1 #define VK_QCOM_RENDER_PASS_SHADER_RESOLVE_SPEC_VERSION 4 #define VK_QCOM_RENDER_PASS_SHADER_RESOLVE_EXTENSION_NAME "VK_QCOM_render_pass_shader_resolve" +// VK_EXT_global_priority is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_global_priority 1 #define VK_EXT_GLOBAL_PRIORITY_SPEC_VERSION 2 #define VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME "VK_EXT_global_priority" @@ -11853,6 +13709,7 @@ typedef VkDeviceQueueGlobalPriorityCreateInfoKHR VkDeviceQueueGlobalPriorityCrea +// VK_EXT_external_memory_host is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_external_memory_host 1 #define VK_EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION 1 #define VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME "VK_EXT_external_memory_host" @@ -11886,6 +13743,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT( #endif +// VK_AMD_buffer_marker is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_buffer_marker 1 #define VK_AMD_BUFFER_MARKER_SPEC_VERSION 1 #define VK_AMD_BUFFER_MARKER_EXTENSION_NAME "VK_AMD_buffer_marker" @@ -11901,6 +13759,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdWriteBufferMarkerAMD( #endif +// VK_AMD_pipeline_compiler_control is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_pipeline_compiler_control 1 #define VK_AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION 1 #define VK_AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME "VK_AMD_pipeline_compiler_control" @@ -11917,41 +13776,33 @@ typedef struct VkPipelineCompilerControlCreateInfoAMD { +// VK_EXT_calibrated_timestamps is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_calibrated_timestamps 1 #define VK_EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION 2 #define VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME "VK_EXT_calibrated_timestamps" +typedef VkTimeDomainKHR VkTimeDomainEXT; -typedef enum VkTimeDomainEXT { - VK_TIME_DOMAIN_DEVICE_EXT = 0, - VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT = 1, - VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT = 2, - VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT = 3, - VK_TIME_DOMAIN_MAX_ENUM_EXT = 0x7FFFFFFF -} VkTimeDomainEXT; -typedef struct VkCalibratedTimestampInfoEXT { - VkStructureType sType; - const void* pNext; - VkTimeDomainEXT timeDomain; -} VkCalibratedTimestampInfoEXT; +typedef VkCalibratedTimestampInfoKHR VkCalibratedTimestampInfoEXT; -typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainEXT* pTimeDomains); -typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsEXT)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoEXT* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainKHR* pTimeDomains); +typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsEXT)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); #ifndef VK_NO_PROTOTYPES VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, - VkTimeDomainEXT* pTimeDomains); + VkTimeDomainKHR* pTimeDomains); VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT( VkDevice device, uint32_t timestampCount, - const VkCalibratedTimestampInfoEXT* pTimestampInfos, + const VkCalibratedTimestampInfoKHR* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); #endif +// VK_AMD_shader_core_properties is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_core_properties 1 #define VK_AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION 2 #define VK_AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_AMD_shader_core_properties" @@ -11976,6 +13827,7 @@ typedef struct VkPhysicalDeviceShaderCorePropertiesAMD { +// VK_AMD_memory_overallocation_behavior is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_memory_overallocation_behavior 1 #define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION 1 #define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME "VK_AMD_memory_overallocation_behavior" @@ -11994,6 +13846,7 @@ typedef struct VkDeviceMemoryOverallocationCreateInfoAMD { +// VK_EXT_vertex_attribute_divisor is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_vertex_attribute_divisor 1 #define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION 3 #define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME "VK_EXT_vertex_attribute_divisor" @@ -12003,27 +13856,15 @@ typedef struct VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT { uint32_t maxVertexAttribDivisor; } VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT; -typedef struct VkVertexInputBindingDivisorDescriptionEXT { - uint32_t binding; - uint32_t divisor; -} VkVertexInputBindingDivisorDescriptionEXT; +typedef VkVertexInputBindingDivisorDescriptionKHR VkVertexInputBindingDivisorDescriptionEXT; -typedef struct VkPipelineVertexInputDivisorStateCreateInfoEXT { - VkStructureType sType; - const void* pNext; - uint32_t vertexBindingDivisorCount; - const VkVertexInputBindingDivisorDescriptionEXT* pVertexBindingDivisors; -} VkPipelineVertexInputDivisorStateCreateInfoEXT; +typedef VkPipelineVertexInputDivisorStateCreateInfoKHR VkPipelineVertexInputDivisorStateCreateInfoEXT; -typedef struct VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT { - VkStructureType sType; - void* pNext; - VkBool32 vertexAttributeInstanceRateDivisor; - VkBool32 vertexAttributeInstanceRateZeroDivisor; -} VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT; +typedef VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT; +// VK_EXT_pipeline_creation_feedback is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_pipeline_creation_feedback 1 #define VK_EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION 1 #define VK_EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME "VK_EXT_pipeline_creation_feedback" @@ -12037,11 +13878,13 @@ typedef VkPipelineCreationFeedback VkPipelineCreationFeedbackEXT; +// VK_NV_shader_subgroup_partitioned is a preprocessor guard. Do not pass it to API calls. #define VK_NV_shader_subgroup_partitioned 1 #define VK_NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION 1 #define VK_NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME "VK_NV_shader_subgroup_partitioned" +// VK_NV_compute_shader_derivatives is a preprocessor guard. Do not pass it to API calls. #define VK_NV_compute_shader_derivatives 1 #define VK_NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION 1 #define VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME "VK_NV_compute_shader_derivatives" @@ -12054,6 +13897,7 @@ typedef struct VkPhysicalDeviceComputeShaderDerivativesFeaturesNV { +// VK_NV_mesh_shader is a preprocessor guard. Do not pass it to API calls. #define VK_NV_mesh_shader 1 #define VK_NV_MESH_SHADER_SPEC_VERSION 1 #define VK_NV_MESH_SHADER_EXTENSION_NAME "VK_NV_mesh_shader" @@ -12115,6 +13959,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( #endif +// VK_NV_fragment_shader_barycentric is a preprocessor guard. Do not pass it to API calls. #define VK_NV_fragment_shader_barycentric 1 #define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 #define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_NV_fragment_shader_barycentric" @@ -12122,6 +13967,7 @@ typedef VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR VkPhysicalDeviceFra +// VK_NV_shader_image_footprint is a preprocessor guard. Do not pass it to API calls. #define VK_NV_shader_image_footprint 1 #define VK_NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION 2 #define VK_NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME "VK_NV_shader_image_footprint" @@ -12133,8 +13979,9 @@ typedef struct VkPhysicalDeviceShaderImageFootprintFeaturesNV { +// VK_NV_scissor_exclusive is a preprocessor guard. Do not pass it to API calls. #define VK_NV_scissor_exclusive 1 -#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 1 +#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 2 #define VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME "VK_NV_scissor_exclusive" typedef struct VkPipelineViewportExclusiveScissorStateCreateInfoNV { VkStructureType sType; @@ -12149,9 +13996,16 @@ typedef struct VkPhysicalDeviceExclusiveScissorFeaturesNV { VkBool32 exclusiveScissor; } VkPhysicalDeviceExclusiveScissorFeaturesNV; +typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorEnableNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkBool32* pExclusiveScissorEnables); typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors); #ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorEnableNV( + VkCommandBuffer commandBuffer, + uint32_t firstExclusiveScissor, + uint32_t exclusiveScissorCount, + const VkBool32* pExclusiveScissorEnables); + VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, @@ -12160,6 +14014,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( #endif +// VK_NV_device_diagnostic_checkpoints is a preprocessor guard. Do not pass it to API calls. #define VK_NV_device_diagnostic_checkpoints 1 #define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION 2 #define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME "VK_NV_device_diagnostic_checkpoints" @@ -12191,6 +14046,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointDataNV( #endif +// VK_INTEL_shader_integer_functions2 is a preprocessor guard. Do not pass it to API calls. #define VK_INTEL_shader_integer_functions2 1 #define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_SPEC_VERSION 1 #define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_EXTENSION_NAME "VK_INTEL_shader_integer_functions2" @@ -12202,6 +14058,7 @@ typedef struct VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL { +// VK_INTEL_performance_query is a preprocessor guard. Do not pass it to API calls. #define VK_INTEL_performance_query 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPerformanceConfigurationINTEL) #define VK_INTEL_PERFORMANCE_QUERY_SPEC_VERSION 2 @@ -12340,6 +14197,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceParameterINTEL( #endif +// VK_EXT_pci_bus_info is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_pci_bus_info 1 #define VK_EXT_PCI_BUS_INFO_SPEC_VERSION 2 #define VK_EXT_PCI_BUS_INFO_EXTENSION_NAME "VK_EXT_pci_bus_info" @@ -12354,6 +14212,7 @@ typedef struct VkPhysicalDevicePCIBusInfoPropertiesEXT { +// VK_AMD_display_native_hdr is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_display_native_hdr 1 #define VK_AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION 1 #define VK_AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME "VK_AMD_display_native_hdr" @@ -12379,6 +14238,7 @@ VKAPI_ATTR void VKAPI_CALL vkSetLocalDimmingAMD( #endif +// VK_EXT_fragment_density_map is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_fragment_density_map 1 #define VK_EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION 2 #define VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME "VK_EXT_fragment_density_map" @@ -12406,6 +14266,7 @@ typedef struct VkRenderPassFragmentDensityMapCreateInfoEXT { +// VK_EXT_scalar_block_layout is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_scalar_block_layout 1 #define VK_EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION 1 #define VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME "VK_EXT_scalar_block_layout" @@ -12413,6 +14274,7 @@ typedef VkPhysicalDeviceScalarBlockLayoutFeatures VkPhysicalDeviceScalarBlockLay +// VK_GOOGLE_hlsl_functionality1 is a preprocessor guard. Do not pass it to API calls. #define VK_GOOGLE_hlsl_functionality1 1 #define VK_GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION 1 #define VK_GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME "VK_GOOGLE_hlsl_functionality1" @@ -12420,11 +14282,13 @@ typedef VkPhysicalDeviceScalarBlockLayoutFeatures VkPhysicalDeviceScalarBlockLay #define VK_GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME VK_GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME +// VK_GOOGLE_decorate_string is a preprocessor guard. Do not pass it to API calls. #define VK_GOOGLE_decorate_string 1 #define VK_GOOGLE_DECORATE_STRING_SPEC_VERSION 1 #define VK_GOOGLE_DECORATE_STRING_EXTENSION_NAME "VK_GOOGLE_decorate_string" +// VK_EXT_subgroup_size_control is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_subgroup_size_control 1 #define VK_EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION 2 #define VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME "VK_EXT_subgroup_size_control" @@ -12436,6 +14300,7 @@ typedef VkPipelineShaderStageRequiredSubgroupSizeCreateInfo VkPipelineShaderStag +// VK_AMD_shader_core_properties2 is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_shader_core_properties2 1 #define VK_AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION 1 #define VK_AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME "VK_AMD_shader_core_properties2" @@ -12453,6 +14318,7 @@ typedef struct VkPhysicalDeviceShaderCoreProperties2AMD { +// VK_AMD_device_coherent_memory is a preprocessor guard. Do not pass it to API calls. #define VK_AMD_device_coherent_memory 1 #define VK_AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION 1 #define VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME "VK_AMD_device_coherent_memory" @@ -12464,6 +14330,7 @@ typedef struct VkPhysicalDeviceCoherentMemoryFeaturesAMD { +// VK_EXT_shader_image_atomic_int64 is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_image_atomic_int64 1 #define VK_EXT_SHADER_IMAGE_ATOMIC_INT64_SPEC_VERSION 1 #define VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME "VK_EXT_shader_image_atomic_int64" @@ -12476,6 +14343,7 @@ typedef struct VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT { +// VK_EXT_memory_budget is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_memory_budget 1 #define VK_EXT_MEMORY_BUDGET_SPEC_VERSION 1 #define VK_EXT_MEMORY_BUDGET_EXTENSION_NAME "VK_EXT_memory_budget" @@ -12488,6 +14356,7 @@ typedef struct VkPhysicalDeviceMemoryBudgetPropertiesEXT { +// VK_EXT_memory_priority is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_memory_priority 1 #define VK_EXT_MEMORY_PRIORITY_SPEC_VERSION 1 #define VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME "VK_EXT_memory_priority" @@ -12505,6 +14374,7 @@ typedef struct VkMemoryPriorityAllocateInfoEXT { +// VK_NV_dedicated_allocation_image_aliasing is a preprocessor guard. Do not pass it to API calls. #define VK_NV_dedicated_allocation_image_aliasing 1 #define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION 1 #define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME "VK_NV_dedicated_allocation_image_aliasing" @@ -12516,6 +14386,7 @@ typedef struct VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV { +// VK_EXT_buffer_device_address is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_buffer_device_address 1 #define VK_EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 2 #define VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_EXT_buffer_device_address" @@ -12546,6 +14417,7 @@ VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressEXT( #endif +// VK_EXT_tooling_info is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_tooling_info 1 #define VK_EXT_TOOLING_INFO_SPEC_VERSION 1 #define VK_EXT_TOOLING_INFO_EXTENSION_NAME "VK_EXT_tooling_info" @@ -12565,6 +14437,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceToolPropertiesEXT( #endif +// VK_EXT_separate_stencil_usage is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_separate_stencil_usage 1 #define VK_EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION 1 #define VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME "VK_EXT_separate_stencil_usage" @@ -12572,8 +14445,9 @@ typedef VkImageStencilUsageCreateInfo VkImageStencilUsageCreateInfoEXT; +// VK_EXT_validation_features is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_validation_features 1 -#define VK_EXT_VALIDATION_FEATURES_SPEC_VERSION 5 +#define VK_EXT_VALIDATION_FEATURES_SPEC_VERSION 6 #define VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME "VK_EXT_validation_features" typedef enum VkValidationFeatureEnableEXT { @@ -12607,32 +14481,14 @@ typedef struct VkValidationFeaturesEXT { +// VK_NV_cooperative_matrix is a preprocessor guard. Do not pass it to API calls. #define VK_NV_cooperative_matrix 1 #define VK_NV_COOPERATIVE_MATRIX_SPEC_VERSION 1 #define VK_NV_COOPERATIVE_MATRIX_EXTENSION_NAME "VK_NV_cooperative_matrix" +typedef VkComponentTypeKHR VkComponentTypeNV; + +typedef VkScopeKHR VkScopeNV; -typedef enum VkComponentTypeNV { - VK_COMPONENT_TYPE_FLOAT16_NV = 0, - VK_COMPONENT_TYPE_FLOAT32_NV = 1, - VK_COMPONENT_TYPE_FLOAT64_NV = 2, - VK_COMPONENT_TYPE_SINT8_NV = 3, - VK_COMPONENT_TYPE_SINT16_NV = 4, - VK_COMPONENT_TYPE_SINT32_NV = 5, - VK_COMPONENT_TYPE_SINT64_NV = 6, - VK_COMPONENT_TYPE_UINT8_NV = 7, - VK_COMPONENT_TYPE_UINT16_NV = 8, - VK_COMPONENT_TYPE_UINT32_NV = 9, - VK_COMPONENT_TYPE_UINT64_NV = 10, - VK_COMPONENT_TYPE_MAX_ENUM_NV = 0x7FFFFFFF -} VkComponentTypeNV; - -typedef enum VkScopeNV { - VK_SCOPE_DEVICE_NV = 1, - VK_SCOPE_WORKGROUP_NV = 2, - VK_SCOPE_SUBGROUP_NV = 3, - VK_SCOPE_QUEUE_FAMILY_NV = 5, - VK_SCOPE_MAX_ENUM_NV = 0x7FFFFFFF -} VkScopeNV; typedef struct VkCooperativeMatrixPropertiesNV { VkStructureType sType; void* pNext; @@ -12669,6 +14525,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesNV( #endif +// VK_NV_coverage_reduction_mode is a preprocessor guard. Do not pass it to API calls. #define VK_NV_coverage_reduction_mode 1 #define VK_NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION 1 #define VK_NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME "VK_NV_coverage_reduction_mode" @@ -12711,6 +14568,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSupportedFramebufferMixedSampl #endif +// VK_EXT_fragment_shader_interlock is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_fragment_shader_interlock 1 #define VK_EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION 1 #define VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME "VK_EXT_fragment_shader_interlock" @@ -12724,6 +14582,7 @@ typedef struct VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT { +// VK_EXT_ycbcr_image_arrays is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_ycbcr_image_arrays 1 #define VK_EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION 1 #define VK_EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME "VK_EXT_ycbcr_image_arrays" @@ -12735,6 +14594,7 @@ typedef struct VkPhysicalDeviceYcbcrImageArraysFeaturesEXT { +// VK_EXT_provoking_vertex is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_provoking_vertex 1 #define VK_EXT_PROVOKING_VERTEX_SPEC_VERSION 1 #define VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME "VK_EXT_provoking_vertex" @@ -12766,6 +14626,7 @@ typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT { +// VK_EXT_headless_surface is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_headless_surface 1 #define VK_EXT_HEADLESS_SURFACE_SPEC_VERSION 1 #define VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME "VK_EXT_headless_surface" @@ -12787,6 +14648,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateHeadlessSurfaceEXT( #endif +// VK_EXT_line_rasterization is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_line_rasterization 1 #define VK_EXT_LINE_RASTERIZATION_SPEC_VERSION 1 #define VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME "VK_EXT_line_rasterization" @@ -12834,6 +14696,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEXT( #endif +// VK_EXT_shader_atomic_float is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_atomic_float 1 #define VK_EXT_SHADER_ATOMIC_FLOAT_SPEC_VERSION 1 #define VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME "VK_EXT_shader_atomic_float" @@ -12856,6 +14719,7 @@ typedef struct VkPhysicalDeviceShaderAtomicFloatFeaturesEXT { +// VK_EXT_host_query_reset is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_host_query_reset 1 #define VK_EXT_HOST_QUERY_RESET_SPEC_VERSION 1 #define VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME "VK_EXT_host_query_reset" @@ -12872,6 +14736,7 @@ VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT( #endif +// VK_EXT_index_type_uint8 is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_index_type_uint8 1 #define VK_EXT_INDEX_TYPE_UINT8_SPEC_VERSION 1 #define VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME "VK_EXT_index_type_uint8" @@ -12883,6 +14748,7 @@ typedef struct VkPhysicalDeviceIndexTypeUint8FeaturesEXT { +// VK_EXT_extended_dynamic_state is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_extended_dynamic_state 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_SPEC_VERSION 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_extended_dynamic_state" @@ -12967,36 +14833,279 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilOpEXT( #endif -#define VK_EXT_shader_atomic_float2 1 -#define VK_EXT_SHADER_ATOMIC_FLOAT_2_SPEC_VERSION 1 -#define VK_EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME "VK_EXT_shader_atomic_float2" -typedef struct VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT { +// VK_EXT_host_image_copy is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_host_image_copy 1 +#define VK_EXT_HOST_IMAGE_COPY_SPEC_VERSION 1 +#define VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME "VK_EXT_host_image_copy" + +typedef enum VkHostImageCopyFlagBitsEXT { + VK_HOST_IMAGE_COPY_MEMCPY_EXT = 0x00000001, + VK_HOST_IMAGE_COPY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkHostImageCopyFlagBitsEXT; +typedef VkFlags VkHostImageCopyFlagsEXT; +typedef struct VkPhysicalDeviceHostImageCopyFeaturesEXT { VkStructureType sType; void* pNext; - VkBool32 shaderBufferFloat16Atomics; - VkBool32 shaderBufferFloat16AtomicAdd; - VkBool32 shaderBufferFloat16AtomicMinMax; - VkBool32 shaderBufferFloat32AtomicMinMax; - VkBool32 shaderBufferFloat64AtomicMinMax; - VkBool32 shaderSharedFloat16Atomics; - VkBool32 shaderSharedFloat16AtomicAdd; - VkBool32 shaderSharedFloat16AtomicMinMax; - VkBool32 shaderSharedFloat32AtomicMinMax; - VkBool32 shaderSharedFloat64AtomicMinMax; - VkBool32 shaderImageFloat32AtomicMinMax; - VkBool32 sparseImageFloat32AtomicMinMax; -} VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT; - - - -#define VK_EXT_shader_demote_to_helper_invocation 1 -#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION 1 -#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME "VK_EXT_shader_demote_to_helper_invocation" -typedef VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT; + VkBool32 hostImageCopy; +} VkPhysicalDeviceHostImageCopyFeaturesEXT; +typedef struct VkPhysicalDeviceHostImageCopyPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t copySrcLayoutCount; + VkImageLayout* pCopySrcLayouts; + uint32_t copyDstLayoutCount; + VkImageLayout* pCopyDstLayouts; + uint8_t optimalTilingLayoutUUID[VK_UUID_SIZE]; + VkBool32 identicalMemoryTypeRequirements; +} VkPhysicalDeviceHostImageCopyPropertiesEXT; + +typedef struct VkMemoryToImageCopyEXT { + VkStructureType sType; + const void* pNext; + const void* pHostPointer; + uint32_t memoryRowLength; + uint32_t memoryImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkMemoryToImageCopyEXT; +typedef struct VkImageToMemoryCopyEXT { + VkStructureType sType; + const void* pNext; + void* pHostPointer; + uint32_t memoryRowLength; + uint32_t memoryImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkImageToMemoryCopyEXT; -#define VK_NV_device_generated_commands 1 +typedef struct VkCopyMemoryToImageInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkMemoryToImageCopyEXT* pRegions; +} VkCopyMemoryToImageInfoEXT; + +typedef struct VkCopyImageToMemoryInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage srcImage; + VkImageLayout srcImageLayout; + uint32_t regionCount; + const VkImageToMemoryCopyEXT* pRegions; +} VkCopyImageToMemoryInfoEXT; + +typedef struct VkCopyImageToImageInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkImageCopy2* pRegions; +} VkCopyImageToImageInfoEXT; + +typedef struct VkHostImageLayoutTransitionInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + VkImageLayout oldLayout; + VkImageLayout newLayout; + VkImageSubresourceRange subresourceRange; +} VkHostImageLayoutTransitionInfoEXT; + +typedef struct VkSubresourceHostMemcpySizeEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize size; +} VkSubresourceHostMemcpySizeEXT; + +typedef struct VkHostImageCopyDevicePerformanceQueryEXT { + VkStructureType sType; + void* pNext; + VkBool32 optimalDeviceAccess; + VkBool32 identicalMemoryLayout; +} VkHostImageCopyDevicePerformanceQueryEXT; + +typedef VkSubresourceLayout2KHR VkSubresourceLayout2EXT; + +typedef VkImageSubresource2KHR VkImageSubresource2EXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToImageEXT)(VkDevice device, const VkCopyMemoryToImageInfoEXT* pCopyMemoryToImageInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyImageToMemoryEXT)(VkDevice device, const VkCopyImageToMemoryInfoEXT* pCopyImageToMemoryInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyImageToImageEXT)(VkDevice device, const VkCopyImageToImageInfoEXT* pCopyImageToImageInfo); +typedef VkResult (VKAPI_PTR *PFN_vkTransitionImageLayoutEXT)(VkDevice device, uint32_t transitionCount, const VkHostImageLayoutTransitionInfoEXT* pTransitions); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2EXT)(VkDevice device, VkImage image, const VkImageSubresource2KHR* pSubresource, VkSubresourceLayout2KHR* pLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToImageEXT( + VkDevice device, + const VkCopyMemoryToImageInfoEXT* pCopyMemoryToImageInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyImageToMemoryEXT( + VkDevice device, + const VkCopyImageToMemoryInfoEXT* pCopyImageToMemoryInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyImageToImageEXT( + VkDevice device, + const VkCopyImageToImageInfoEXT* pCopyImageToImageInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkTransitionImageLayoutEXT( + VkDevice device, + uint32_t transitionCount, + const VkHostImageLayoutTransitionInfoEXT* pTransitions); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2EXT( + VkDevice device, + VkImage image, + const VkImageSubresource2KHR* pSubresource, + VkSubresourceLayout2KHR* pLayout); +#endif + + +// VK_EXT_shader_atomic_float2 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_atomic_float2 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_2_SPEC_VERSION 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME "VK_EXT_shader_atomic_float2" +typedef struct VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderBufferFloat16Atomics; + VkBool32 shaderBufferFloat16AtomicAdd; + VkBool32 shaderBufferFloat16AtomicMinMax; + VkBool32 shaderBufferFloat32AtomicMinMax; + VkBool32 shaderBufferFloat64AtomicMinMax; + VkBool32 shaderSharedFloat16Atomics; + VkBool32 shaderSharedFloat16AtomicAdd; + VkBool32 shaderSharedFloat16AtomicMinMax; + VkBool32 shaderSharedFloat32AtomicMinMax; + VkBool32 shaderSharedFloat64AtomicMinMax; + VkBool32 shaderImageFloat32AtomicMinMax; + VkBool32 sparseImageFloat32AtomicMinMax; +} VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT; + + + +// VK_EXT_surface_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_surface_maintenance1 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_surface_maintenance1" + +typedef enum VkPresentScalingFlagBitsEXT { + VK_PRESENT_SCALING_ONE_TO_ONE_BIT_EXT = 0x00000001, + VK_PRESENT_SCALING_ASPECT_RATIO_STRETCH_BIT_EXT = 0x00000002, + VK_PRESENT_SCALING_STRETCH_BIT_EXT = 0x00000004, + VK_PRESENT_SCALING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentScalingFlagBitsEXT; +typedef VkFlags VkPresentScalingFlagsEXT; + +typedef enum VkPresentGravityFlagBitsEXT { + VK_PRESENT_GRAVITY_MIN_BIT_EXT = 0x00000001, + VK_PRESENT_GRAVITY_MAX_BIT_EXT = 0x00000002, + VK_PRESENT_GRAVITY_CENTERED_BIT_EXT = 0x00000004, + VK_PRESENT_GRAVITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentGravityFlagBitsEXT; +typedef VkFlags VkPresentGravityFlagsEXT; +typedef struct VkSurfacePresentModeEXT { + VkStructureType sType; + void* pNext; + VkPresentModeKHR presentMode; +} VkSurfacePresentModeEXT; + +typedef struct VkSurfacePresentScalingCapabilitiesEXT { + VkStructureType sType; + void* pNext; + VkPresentScalingFlagsEXT supportedPresentScaling; + VkPresentGravityFlagsEXT supportedPresentGravityX; + VkPresentGravityFlagsEXT supportedPresentGravityY; + VkExtent2D minScaledImageExtent; + VkExtent2D maxScaledImageExtent; +} VkSurfacePresentScalingCapabilitiesEXT; + +typedef struct VkSurfacePresentModeCompatibilityEXT { + VkStructureType sType; + void* pNext; + uint32_t presentModeCount; + VkPresentModeKHR* pPresentModes; +} VkSurfacePresentModeCompatibilityEXT; + + + +// VK_EXT_swapchain_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_swapchain_maintenance1 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_swapchain_maintenance1" +typedef struct VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 swapchainMaintenance1; +} VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT; + +typedef struct VkSwapchainPresentFenceInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkFence* pFences; +} VkSwapchainPresentFenceInfoEXT; + +typedef struct VkSwapchainPresentModesCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t presentModeCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModesCreateInfoEXT; + +typedef struct VkSwapchainPresentModeInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModeInfoEXT; + +typedef struct VkSwapchainPresentScalingCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPresentScalingFlagsEXT scalingBehavior; + VkPresentGravityFlagsEXT presentGravityX; + VkPresentGravityFlagsEXT presentGravityY; +} VkSwapchainPresentScalingCreateInfoEXT; + +typedef struct VkReleaseSwapchainImagesInfoEXT { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint32_t imageIndexCount; + const uint32_t* pImageIndices; +} VkReleaseSwapchainImagesInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkReleaseSwapchainImagesEXT)(VkDevice device, const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseSwapchainImagesEXT( + VkDevice device, + const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); +#endif + + +// VK_EXT_shader_demote_to_helper_invocation is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_demote_to_helper_invocation 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME "VK_EXT_shader_demote_to_helper_invocation" +typedef VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT; + + + +// VK_NV_device_generated_commands is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_generated_commands 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNV) #define VK_NV_DEVICE_GENERATED_COMMANDS_SPEC_VERSION 3 #define VK_NV_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME "VK_NV_device_generated_commands" @@ -13011,6 +15120,8 @@ typedef enum VkIndirectCommandsTokenTypeNV { VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NV = 6, VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_TASKS_NV = 7, VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_MESH_TASKS_NV = 1000328000, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NV = 1000428003, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NV = 1000428004, VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NV = 0x7FFFFFFF } VkIndirectCommandsTokenTypeNV; @@ -13187,6 +15298,7 @@ VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNV( #endif +// VK_NV_inherited_viewport_scissor is a preprocessor guard. Do not pass it to API calls. #define VK_NV_inherited_viewport_scissor 1 #define VK_NV_INHERITED_VIEWPORT_SCISSOR_SPEC_VERSION 1 #define VK_NV_INHERITED_VIEWPORT_SCISSOR_EXTENSION_NAME "VK_NV_inherited_viewport_scissor" @@ -13206,6 +15318,7 @@ typedef struct VkCommandBufferInheritanceViewportScissorInfoNV { +// VK_EXT_texel_buffer_alignment is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_texel_buffer_alignment 1 #define VK_EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION 1 #define VK_EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME "VK_EXT_texel_buffer_alignment" @@ -13219,8 +15332,9 @@ typedef VkPhysicalDeviceTexelBufferAlignmentProperties VkPhysicalDeviceTexelBuff +// VK_QCOM_render_pass_transform is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_render_pass_transform 1 -#define VK_QCOM_RENDER_PASS_TRANSFORM_SPEC_VERSION 3 +#define VK_QCOM_RENDER_PASS_TRANSFORM_SPEC_VERSION 4 #define VK_QCOM_RENDER_PASS_TRANSFORM_EXTENSION_NAME "VK_QCOM_render_pass_transform" typedef struct VkRenderPassTransformBeginInfoQCOM { VkStructureType sType; @@ -13237,6 +15351,51 @@ typedef struct VkCommandBufferInheritanceRenderPassTransformInfoQCOM { +// VK_EXT_depth_bias_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_bias_control 1 +#define VK_EXT_DEPTH_BIAS_CONTROL_SPEC_VERSION 1 +#define VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME "VK_EXT_depth_bias_control" + +typedef enum VkDepthBiasRepresentationEXT { + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT = 0, + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT = 1, + VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT = 2, + VK_DEPTH_BIAS_REPRESENTATION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDepthBiasRepresentationEXT; +typedef struct VkPhysicalDeviceDepthBiasControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthBiasControl; + VkBool32 leastRepresentableValueForceUnormRepresentation; + VkBool32 floatRepresentation; + VkBool32 depthBiasExact; +} VkPhysicalDeviceDepthBiasControlFeaturesEXT; + +typedef struct VkDepthBiasInfoEXT { + VkStructureType sType; + const void* pNext; + float depthBiasConstantFactor; + float depthBiasClamp; + float depthBiasSlopeFactor; +} VkDepthBiasInfoEXT; + +typedef struct VkDepthBiasRepresentationInfoEXT { + VkStructureType sType; + const void* pNext; + VkDepthBiasRepresentationEXT depthBiasRepresentation; + VkBool32 depthBiasExact; +} VkDepthBiasRepresentationInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias2EXT)(VkCommandBuffer commandBuffer, const VkDepthBiasInfoEXT* pDepthBiasInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias2EXT( + VkCommandBuffer commandBuffer, + const VkDepthBiasInfoEXT* pDepthBiasInfo); +#endif + + +// VK_EXT_device_memory_report is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_device_memory_report 1 #define VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION 2 #define VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME "VK_EXT_device_memory_report" @@ -13282,6 +15441,7 @@ typedef struct VkDeviceDeviceMemoryReportCreateInfoEXT { +// VK_EXT_acquire_drm_display is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_acquire_drm_display 1 #define VK_EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION 1 #define VK_EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_drm_display" @@ -13302,6 +15462,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetDrmDisplayEXT( #endif +// VK_EXT_robustness2 is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_robustness2 1 #define VK_EXT_ROBUSTNESS_2_SPEC_VERSION 1 #define VK_EXT_ROBUSTNESS_2_EXTENSION_NAME "VK_EXT_robustness2" @@ -13322,6 +15483,7 @@ typedef struct VkPhysicalDeviceRobustness2PropertiesEXT { +// VK_EXT_custom_border_color is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_custom_border_color 1 #define VK_EXT_CUSTOM_BORDER_COLOR_SPEC_VERSION 12 #define VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME "VK_EXT_custom_border_color" @@ -13347,11 +15509,37 @@ typedef struct VkPhysicalDeviceCustomBorderColorFeaturesEXT { +// VK_GOOGLE_user_type is a preprocessor guard. Do not pass it to API calls. #define VK_GOOGLE_user_type 1 #define VK_GOOGLE_USER_TYPE_SPEC_VERSION 1 #define VK_GOOGLE_USER_TYPE_EXTENSION_NAME "VK_GOOGLE_user_type" +// VK_NV_present_barrier is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_present_barrier 1 +#define VK_NV_PRESENT_BARRIER_SPEC_VERSION 1 +#define VK_NV_PRESENT_BARRIER_EXTENSION_NAME "VK_NV_present_barrier" +typedef struct VkPhysicalDevicePresentBarrierFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrier; +} VkPhysicalDevicePresentBarrierFeaturesNV; + +typedef struct VkSurfaceCapabilitiesPresentBarrierNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierSupported; +} VkSurfaceCapabilitiesPresentBarrierNV; + +typedef struct VkSwapchainPresentBarrierCreateInfoNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierEnable; +} VkSwapchainPresentBarrierCreateInfoNV; + + + +// VK_EXT_private_data is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_private_data 1 typedef VkPrivateDataSlot VkPrivateDataSlotEXT; @@ -13398,6 +15586,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetPrivateDataEXT( #endif +// VK_EXT_pipeline_creation_cache_control is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_pipeline_creation_cache_control 1 #define VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_SPEC_VERSION 3 #define VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME "VK_EXT_pipeline_creation_cache_control" @@ -13405,6 +15594,7 @@ typedef VkPhysicalDevicePipelineCreationCacheControlFeatures VkPhysicalDevicePip +// VK_NV_device_diagnostics_config is a preprocessor guard. Do not pass it to API calls. #define VK_NV_device_diagnostics_config 1 #define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION 2 #define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME "VK_NV_device_diagnostics_config" @@ -13431,113 +15621,435 @@ typedef struct VkDeviceDiagnosticsConfigCreateInfoNV { +// VK_QCOM_render_pass_store_ops is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_render_pass_store_ops 1 #define VK_QCOM_RENDER_PASS_STORE_OPS_SPEC_VERSION 2 #define VK_QCOM_RENDER_PASS_STORE_OPS_EXTENSION_NAME "VK_QCOM_render_pass_store_ops" -#define VK_EXT_graphics_pipeline_library 1 -#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION 1 -#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME "VK_EXT_graphics_pipeline_library" +// VK_NV_cuda_kernel_launch is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_cuda_kernel_launch 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCudaModuleNV) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCudaFunctionNV) +#define VK_NV_CUDA_KERNEL_LAUNCH_SPEC_VERSION 2 +#define VK_NV_CUDA_KERNEL_LAUNCH_EXTENSION_NAME "VK_NV_cuda_kernel_launch" +typedef struct VkCudaModuleCreateInfoNV { + VkStructureType sType; + const void* pNext; + size_t dataSize; + const void* pData; +} VkCudaModuleCreateInfoNV; -typedef enum VkGraphicsPipelineLibraryFlagBitsEXT { - VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT = 0x00000001, - VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT = 0x00000002, - VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT = 0x00000004, - VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT = 0x00000008, - VK_GRAPHICS_PIPELINE_LIBRARY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF -} VkGraphicsPipelineLibraryFlagBitsEXT; -typedef VkFlags VkGraphicsPipelineLibraryFlagsEXT; -typedef struct VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT { +typedef struct VkCudaFunctionCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkCudaModuleNV module; + const char* pName; +} VkCudaFunctionCreateInfoNV; + +typedef struct VkCudaLaunchInfoNV { + VkStructureType sType; + const void* pNext; + VkCudaFunctionNV function; + uint32_t gridDimX; + uint32_t gridDimY; + uint32_t gridDimZ; + uint32_t blockDimX; + uint32_t blockDimY; + uint32_t blockDimZ; + uint32_t sharedMemBytes; + size_t paramCount; + const void* const * pParams; + size_t extraCount; + const void* const * pExtras; +} VkCudaLaunchInfoNV; + +typedef struct VkPhysicalDeviceCudaKernelLaunchFeaturesNV { VkStructureType sType; void* pNext; - VkBool32 graphicsPipelineLibrary; -} VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT; + VkBool32 cudaKernelLaunchFeatures; +} VkPhysicalDeviceCudaKernelLaunchFeaturesNV; -typedef struct VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT { +typedef struct VkPhysicalDeviceCudaKernelLaunchPropertiesNV { VkStructureType sType; void* pNext; - VkBool32 graphicsPipelineLibraryFastLinking; - VkBool32 graphicsPipelineLibraryIndependentInterpolationDecoration; -} VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT; + uint32_t computeCapabilityMinor; + uint32_t computeCapabilityMajor; +} VkPhysicalDeviceCudaKernelLaunchPropertiesNV; -typedef struct VkGraphicsPipelineLibraryCreateInfoEXT { - VkStructureType sType; - void* pNext; - VkGraphicsPipelineLibraryFlagsEXT flags; -} VkGraphicsPipelineLibraryCreateInfoEXT; +typedef VkResult (VKAPI_PTR *PFN_vkCreateCudaModuleNV)(VkDevice device, const VkCudaModuleCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCudaModuleNV* pModule); +typedef VkResult (VKAPI_PTR *PFN_vkGetCudaModuleCacheNV)(VkDevice device, VkCudaModuleNV module, size_t* pCacheSize, void* pCacheData); +typedef VkResult (VKAPI_PTR *PFN_vkCreateCudaFunctionNV)(VkDevice device, const VkCudaFunctionCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCudaFunctionNV* pFunction); +typedef void (VKAPI_PTR *PFN_vkDestroyCudaModuleNV)(VkDevice device, VkCudaModuleNV module, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkDestroyCudaFunctionNV)(VkDevice device, VkCudaFunctionNV function, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdCudaLaunchKernelNV)(VkCommandBuffer commandBuffer, const VkCudaLaunchInfoNV* pLaunchInfo); +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCudaModuleNV( + VkDevice device, + const VkCudaModuleCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCudaModuleNV* pModule); +VKAPI_ATTR VkResult VKAPI_CALL vkGetCudaModuleCacheNV( + VkDevice device, + VkCudaModuleNV module, + size_t* pCacheSize, + void* pCacheData); -#define VK_AMD_shader_early_and_late_fragment_tests 1 -#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_SPEC_VERSION 1 -#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME "VK_AMD_shader_early_and_late_fragment_tests" -typedef struct VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD { - VkStructureType sType; - void* pNext; - VkBool32 shaderEarlyAndLateFragmentTests; -} VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD; +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCudaFunctionNV( + VkDevice device, + const VkCudaFunctionCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCudaFunctionNV* pFunction); +VKAPI_ATTR void VKAPI_CALL vkDestroyCudaModuleNV( + VkDevice device, + VkCudaModuleNV module, + const VkAllocationCallbacks* pAllocator); +VKAPI_ATTR void VKAPI_CALL vkDestroyCudaFunctionNV( + VkDevice device, + VkCudaFunctionNV function, + const VkAllocationCallbacks* pAllocator); -#define VK_NV_fragment_shading_rate_enums 1 -#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION 1 -#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME "VK_NV_fragment_shading_rate_enums" +VKAPI_ATTR void VKAPI_CALL vkCmdCudaLaunchKernelNV( + VkCommandBuffer commandBuffer, + const VkCudaLaunchInfoNV* pLaunchInfo); +#endif -typedef enum VkFragmentShadingRateTypeNV { - VK_FRAGMENT_SHADING_RATE_TYPE_FRAGMENT_SIZE_NV = 0, - VK_FRAGMENT_SHADING_RATE_TYPE_ENUMS_NV = 1, - VK_FRAGMENT_SHADING_RATE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF -} VkFragmentShadingRateTypeNV; -typedef enum VkFragmentShadingRateNV { - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV = 0, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV = 1, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV = 4, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV = 5, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV = 6, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV = 9, - VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV = 10, - VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV = 11, - VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV = 12, - VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV = 13, - VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV = 14, - VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV = 15, - VK_FRAGMENT_SHADING_RATE_MAX_ENUM_NV = 0x7FFFFFFF -} VkFragmentShadingRateNV; -typedef struct VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV { +// VK_NV_low_latency is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_low_latency 1 +#define VK_NV_LOW_LATENCY_SPEC_VERSION 1 +#define VK_NV_LOW_LATENCY_EXTENSION_NAME "VK_NV_low_latency" +typedef struct VkQueryLowLatencySupportNV { VkStructureType sType; - void* pNext; - VkBool32 fragmentShadingRateEnums; - VkBool32 supersampleFragmentShadingRates; - VkBool32 noInvocationFragmentShadingRates; -} VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV; + const void* pNext; + void* pQueriedLowLatencyData; +} VkQueryLowLatencySupportNV; -typedef struct VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV { - VkStructureType sType; - void* pNext; - VkSampleCountFlagBits maxFragmentShadingRateInvocationCount; -} VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV; -typedef struct VkPipelineFragmentShadingRateEnumStateCreateInfoNV { - VkStructureType sType; - const void* pNext; - VkFragmentShadingRateTypeNV shadingRateType; - VkFragmentShadingRateNV shadingRate; - VkFragmentShadingRateCombinerOpKHR combinerOps[2]; -} VkPipelineFragmentShadingRateEnumStateCreateInfoNV; -typedef void (VKAPI_PTR *PFN_vkCmdSetFragmentShadingRateEnumNV)(VkCommandBuffer commandBuffer, VkFragmentShadingRateNV shadingRate, const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); +// VK_EXT_descriptor_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_descriptor_buffer 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureKHR) +#define VK_EXT_DESCRIPTOR_BUFFER_SPEC_VERSION 1 +#define VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME "VK_EXT_descriptor_buffer" +typedef struct VkPhysicalDeviceDescriptorBufferPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 combinedImageSamplerDescriptorSingleArray; + VkBool32 bufferlessPushDescriptors; + VkBool32 allowSamplerImageViewPostSubmitCreation; + VkDeviceSize descriptorBufferOffsetAlignment; + uint32_t maxDescriptorBufferBindings; + uint32_t maxResourceDescriptorBufferBindings; + uint32_t maxSamplerDescriptorBufferBindings; + uint32_t maxEmbeddedImmutableSamplerBindings; + uint32_t maxEmbeddedImmutableSamplers; + size_t bufferCaptureReplayDescriptorDataSize; + size_t imageCaptureReplayDescriptorDataSize; + size_t imageViewCaptureReplayDescriptorDataSize; + size_t samplerCaptureReplayDescriptorDataSize; + size_t accelerationStructureCaptureReplayDescriptorDataSize; + size_t samplerDescriptorSize; + size_t combinedImageSamplerDescriptorSize; + size_t sampledImageDescriptorSize; + size_t storageImageDescriptorSize; + size_t uniformTexelBufferDescriptorSize; + size_t robustUniformTexelBufferDescriptorSize; + size_t storageTexelBufferDescriptorSize; + size_t robustStorageTexelBufferDescriptorSize; + size_t uniformBufferDescriptorSize; + size_t robustUniformBufferDescriptorSize; + size_t storageBufferDescriptorSize; + size_t robustStorageBufferDescriptorSize; + size_t inputAttachmentDescriptorSize; + size_t accelerationStructureDescriptorSize; + VkDeviceSize maxSamplerDescriptorBufferRange; + VkDeviceSize maxResourceDescriptorBufferRange; + VkDeviceSize samplerDescriptorBufferAddressSpaceSize; + VkDeviceSize resourceDescriptorBufferAddressSpaceSize; + VkDeviceSize descriptorBufferAddressSpaceSize; +} VkPhysicalDeviceDescriptorBufferPropertiesEXT; + +typedef struct VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT { + VkStructureType sType; + void* pNext; + size_t combinedImageSamplerDensityMapDescriptorSize; +} VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT; -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkCmdSetFragmentShadingRateEnumNV( - VkCommandBuffer commandBuffer, - VkFragmentShadingRateNV shadingRate, - const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); -#endif +typedef struct VkPhysicalDeviceDescriptorBufferFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 descriptorBuffer; + VkBool32 descriptorBufferCaptureReplay; + VkBool32 descriptorBufferImageLayoutIgnored; + VkBool32 descriptorBufferPushDescriptors; +} VkPhysicalDeviceDescriptorBufferFeaturesEXT; +typedef struct VkDescriptorAddressInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkDeviceSize range; + VkFormat format; +} VkDescriptorAddressInfoEXT; -#define VK_NV_ray_tracing_motion_blur 1 +typedef struct VkDescriptorBufferBindingInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkBufferUsageFlags usage; +} VkDescriptorBufferBindingInfoEXT; + +typedef struct VkDescriptorBufferBindingPushDescriptorBufferHandleEXT { + VkStructureType sType; + void* pNext; + VkBuffer buffer; +} VkDescriptorBufferBindingPushDescriptorBufferHandleEXT; + +typedef union VkDescriptorDataEXT { + const VkSampler* pSampler; + const VkDescriptorImageInfo* pCombinedImageSampler; + const VkDescriptorImageInfo* pInputAttachmentImage; + const VkDescriptorImageInfo* pSampledImage; + const VkDescriptorImageInfo* pStorageImage; + const VkDescriptorAddressInfoEXT* pUniformTexelBuffer; + const VkDescriptorAddressInfoEXT* pStorageTexelBuffer; + const VkDescriptorAddressInfoEXT* pUniformBuffer; + const VkDescriptorAddressInfoEXT* pStorageBuffer; + VkDeviceAddress accelerationStructure; +} VkDescriptorDataEXT; + +typedef struct VkDescriptorGetInfoEXT { + VkStructureType sType; + const void* pNext; + VkDescriptorType type; + VkDescriptorDataEXT data; +} VkDescriptorGetInfoEXT; + +typedef struct VkBufferCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferCaptureDescriptorDataInfoEXT; + +typedef struct VkImageCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageCaptureDescriptorDataInfoEXT; + +typedef struct VkImageViewCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageView imageView; +} VkImageViewCaptureDescriptorDataInfoEXT; + +typedef struct VkSamplerCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkSampler sampler; +} VkSamplerCaptureDescriptorDataInfoEXT; + +typedef struct VkOpaqueCaptureDescriptorDataCreateInfoEXT { + VkStructureType sType; + const void* pNext; + const void* opaqueCaptureDescriptorData; +} VkOpaqueCaptureDescriptorDataCreateInfoEXT; + +typedef struct VkAccelerationStructureCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR accelerationStructure; + VkAccelerationStructureNV accelerationStructureNV; +} VkAccelerationStructureCaptureDescriptorDataInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSizeEXT)(VkDevice device, VkDescriptorSetLayout layout, VkDeviceSize* pLayoutSizeInBytes); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutBindingOffsetEXT)(VkDevice device, VkDescriptorSetLayout layout, uint32_t binding, VkDeviceSize* pOffset); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorEXT)(VkDevice device, const VkDescriptorGetInfoEXT* pDescriptorInfo, size_t dataSize, void* pDescriptor); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBuffersEXT)(VkCommandBuffer commandBuffer, uint32_t bufferCount, const VkDescriptorBufferBindingInfoEXT* pBindingInfos); +typedef void (VKAPI_PTR *PFN_vkCmdSetDescriptorBufferOffsetsEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const uint32_t* pBufferIndices, const VkDeviceSize* pOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set); +typedef VkResult (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkBufferCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSizeEXT( + VkDevice device, + VkDescriptorSetLayout layout, + VkDeviceSize* pLayoutSizeInBytes); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutBindingOffsetEXT( + VkDevice device, + VkDescriptorSetLayout layout, + uint32_t binding, + VkDeviceSize* pOffset); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorEXT( + VkDevice device, + const VkDescriptorGetInfoEXT* pDescriptorInfo, + size_t dataSize, + void* pDescriptor); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBuffersEXT( + VkCommandBuffer commandBuffer, + uint32_t bufferCount, + const VkDescriptorBufferBindingInfoEXT* pBindingInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDescriptorBufferOffsetsEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t setCount, + const uint32_t* pBufferIndices, + const VkDeviceSize* pOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBufferEmbeddedSamplersEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t set); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkBufferCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageViewOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSamplerOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, + void* pData); +#endif + + +// VK_EXT_graphics_pipeline_library is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_graphics_pipeline_library 1 +#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION 1 +#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME "VK_EXT_graphics_pipeline_library" + +typedef enum VkGraphicsPipelineLibraryFlagBitsEXT { + VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT = 0x00000001, + VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT = 0x00000002, + VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT = 0x00000004, + VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT = 0x00000008, + VK_GRAPHICS_PIPELINE_LIBRARY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkGraphicsPipelineLibraryFlagBitsEXT; +typedef VkFlags VkGraphicsPipelineLibraryFlagsEXT; +typedef struct VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 graphicsPipelineLibrary; +} VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT; + +typedef struct VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 graphicsPipelineLibraryFastLinking; + VkBool32 graphicsPipelineLibraryIndependentInterpolationDecoration; +} VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT; + +typedef struct VkGraphicsPipelineLibraryCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkGraphicsPipelineLibraryFlagsEXT flags; +} VkGraphicsPipelineLibraryCreateInfoEXT; + + + +// VK_AMD_shader_early_and_late_fragment_tests is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_early_and_late_fragment_tests 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_SPEC_VERSION 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME "VK_AMD_shader_early_and_late_fragment_tests" +typedef struct VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD { + VkStructureType sType; + void* pNext; + VkBool32 shaderEarlyAndLateFragmentTests; +} VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD; + + + +// VK_NV_fragment_shading_rate_enums is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_fragment_shading_rate_enums 1 +#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME "VK_NV_fragment_shading_rate_enums" + +typedef enum VkFragmentShadingRateTypeNV { + VK_FRAGMENT_SHADING_RATE_TYPE_FRAGMENT_SIZE_NV = 0, + VK_FRAGMENT_SHADING_RATE_TYPE_ENUMS_NV = 1, + VK_FRAGMENT_SHADING_RATE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkFragmentShadingRateTypeNV; + +typedef enum VkFragmentShadingRateNV { + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV = 0, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV = 1, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV = 4, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV = 5, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV = 6, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV = 9, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV = 10, + VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV = 11, + VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV = 12, + VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV = 13, + VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV = 14, + VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV = 15, + VK_FRAGMENT_SHADING_RATE_MAX_ENUM_NV = 0x7FFFFFFF +} VkFragmentShadingRateNV; +typedef struct VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShadingRateEnums; + VkBool32 supersampleFragmentShadingRates; + VkBool32 noInvocationFragmentShadingRates; +} VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV; + +typedef struct VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV { + VkStructureType sType; + void* pNext; + VkSampleCountFlagBits maxFragmentShadingRateInvocationCount; +} VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV; + +typedef struct VkPipelineFragmentShadingRateEnumStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkFragmentShadingRateTypeNV shadingRateType; + VkFragmentShadingRateNV shadingRate; + VkFragmentShadingRateCombinerOpKHR combinerOps[2]; +} VkPipelineFragmentShadingRateEnumStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetFragmentShadingRateEnumNV)(VkCommandBuffer commandBuffer, VkFragmentShadingRateNV shadingRate, const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetFragmentShadingRateEnumNV( + VkCommandBuffer commandBuffer, + VkFragmentShadingRateNV shadingRate, + const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); +#endif + + +// VK_NV_ray_tracing_motion_blur is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing_motion_blur 1 #define VK_NV_RAY_TRACING_MOTION_BLUR_SPEC_VERSION 1 #define VK_NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME "VK_NV_ray_tracing_motion_blur" @@ -13627,6 +16139,7 @@ typedef struct VkPhysicalDeviceRayTracingMotionBlurFeaturesNV { +// VK_EXT_ycbcr_2plane_444_formats is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_ycbcr_2plane_444_formats 1 #define VK_EXT_YCBCR_2PLANE_444_FORMATS_SPEC_VERSION 1 #define VK_EXT_YCBCR_2PLANE_444_FORMATS_EXTENSION_NAME "VK_EXT_ycbcr_2plane_444_formats" @@ -13638,6 +16151,7 @@ typedef struct VkPhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT { +// VK_EXT_fragment_density_map2 is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_fragment_density_map2 1 #define VK_EXT_FRAGMENT_DENSITY_MAP_2_SPEC_VERSION 1 #define VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME "VK_EXT_fragment_density_map2" @@ -13658,8 +16172,9 @@ typedef struct VkPhysicalDeviceFragmentDensityMap2PropertiesEXT { +// VK_QCOM_rotated_copy_commands is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_rotated_copy_commands 1 -#define VK_QCOM_ROTATED_COPY_COMMANDS_SPEC_VERSION 1 +#define VK_QCOM_ROTATED_COPY_COMMANDS_SPEC_VERSION 2 #define VK_QCOM_ROTATED_COPY_COMMANDS_EXTENSION_NAME "VK_QCOM_rotated_copy_commands" typedef struct VkCopyCommandTransformInfoQCOM { VkStructureType sType; @@ -13669,6 +16184,7 @@ typedef struct VkCopyCommandTransformInfoQCOM { +// VK_EXT_image_robustness is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_robustness 1 #define VK_EXT_IMAGE_ROBUSTNESS_SPEC_VERSION 1 #define VK_EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME "VK_EXT_image_robustness" @@ -13676,6 +16192,7 @@ typedef VkPhysicalDeviceImageRobustnessFeatures VkPhysicalDeviceImageRobustnessF +// VK_EXT_image_compression_control is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_compression_control 1 #define VK_EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION 1 #define VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME "VK_EXT_image_compression_control" @@ -13732,18 +16249,6 @@ typedef struct VkImageCompressionControlEXT { VkImageCompressionFixedRateFlagsEXT* pFixedRateFlags; } VkImageCompressionControlEXT; -typedef struct VkSubresourceLayout2EXT { - VkStructureType sType; - void* pNext; - VkSubresourceLayout subresourceLayout; -} VkSubresourceLayout2EXT; - -typedef struct VkImageSubresource2EXT { - VkStructureType sType; - void* pNext; - VkImageSubresource imageSubresource; -} VkImageSubresource2EXT; - typedef struct VkImageCompressionPropertiesEXT { VkStructureType sType; void* pNext; @@ -13751,17 +16256,9 @@ typedef struct VkImageCompressionPropertiesEXT { VkImageCompressionFixedRateFlagsEXT imageCompressionFixedRateFlags; } VkImageCompressionPropertiesEXT; -typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2EXT)(VkDevice device, VkImage image, const VkImageSubresource2EXT* pSubresource, VkSubresourceLayout2EXT* pLayout); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2EXT( - VkDevice device, - VkImage image, - const VkImageSubresource2EXT* pSubresource, - VkSubresourceLayout2EXT* pLayout); -#endif +// VK_EXT_attachment_feedback_loop_layout is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_attachment_feedback_loop_layout 1 #define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_SPEC_VERSION 2 #define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_layout" @@ -13773,6 +16270,7 @@ typedef struct VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT { +// VK_EXT_4444_formats is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_4444_formats 1 #define VK_EXT_4444_FORMATS_SPEC_VERSION 1 #define VK_EXT_4444_FORMATS_EXTENSION_NAME "VK_EXT_4444_formats" @@ -13785,6 +16283,87 @@ typedef struct VkPhysicalDevice4444FormatsFeaturesEXT { +// VK_EXT_device_fault is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_device_fault 1 +#define VK_EXT_DEVICE_FAULT_SPEC_VERSION 2 +#define VK_EXT_DEVICE_FAULT_EXTENSION_NAME "VK_EXT_device_fault" + +typedef enum VkDeviceFaultAddressTypeEXT { + VK_DEVICE_FAULT_ADDRESS_TYPE_NONE_EXT = 0, + VK_DEVICE_FAULT_ADDRESS_TYPE_READ_INVALID_EXT = 1, + VK_DEVICE_FAULT_ADDRESS_TYPE_WRITE_INVALID_EXT = 2, + VK_DEVICE_FAULT_ADDRESS_TYPE_EXECUTE_INVALID_EXT = 3, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_UNKNOWN_EXT = 4, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_INVALID_EXT = 5, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_FAULT_EXT = 6, + VK_DEVICE_FAULT_ADDRESS_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultAddressTypeEXT; + +typedef enum VkDeviceFaultVendorBinaryHeaderVersionEXT { + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_ONE_EXT = 1, + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultVendorBinaryHeaderVersionEXT; +typedef struct VkPhysicalDeviceFaultFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 deviceFault; + VkBool32 deviceFaultVendorBinary; +} VkPhysicalDeviceFaultFeaturesEXT; + +typedef struct VkDeviceFaultCountsEXT { + VkStructureType sType; + void* pNext; + uint32_t addressInfoCount; + uint32_t vendorInfoCount; + VkDeviceSize vendorBinarySize; +} VkDeviceFaultCountsEXT; + +typedef struct VkDeviceFaultAddressInfoEXT { + VkDeviceFaultAddressTypeEXT addressType; + VkDeviceAddress reportedAddress; + VkDeviceSize addressPrecision; +} VkDeviceFaultAddressInfoEXT; + +typedef struct VkDeviceFaultVendorInfoEXT { + char description[VK_MAX_DESCRIPTION_SIZE]; + uint64_t vendorFaultCode; + uint64_t vendorFaultData; +} VkDeviceFaultVendorInfoEXT; + +typedef struct VkDeviceFaultInfoEXT { + VkStructureType sType; + void* pNext; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkDeviceFaultAddressInfoEXT* pAddressInfos; + VkDeviceFaultVendorInfoEXT* pVendorInfos; + void* pVendorBinaryData; +} VkDeviceFaultInfoEXT; + +typedef struct VkDeviceFaultVendorBinaryHeaderVersionOneEXT { + uint32_t headerSize; + VkDeviceFaultVendorBinaryHeaderVersionEXT headerVersion; + uint32_t vendorID; + uint32_t deviceID; + uint32_t driverVersion; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; + uint32_t applicationNameOffset; + uint32_t applicationVersion; + uint32_t engineNameOffset; + uint32_t engineVersion; + uint32_t apiVersion; +} VkDeviceFaultVendorBinaryHeaderVersionOneEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceFaultInfoEXT)(VkDevice device, VkDeviceFaultCountsEXT* pFaultCounts, VkDeviceFaultInfoEXT* pFaultInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceFaultInfoEXT( + VkDevice device, + VkDeviceFaultCountsEXT* pFaultCounts, + VkDeviceFaultInfoEXT* pFaultInfo); +#endif + + +// VK_ARM_rasterization_order_attachment_access is a preprocessor guard. Do not pass it to API calls. #define VK_ARM_rasterization_order_attachment_access 1 #define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 #define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_ARM_rasterization_order_attachment_access" @@ -13800,6 +16379,7 @@ typedef VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT VkPhysical +// VK_EXT_rgba10x6_formats is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_rgba10x6_formats 1 #define VK_EXT_RGBA10X6_FORMATS_SPEC_VERSION 1 #define VK_EXT_RGBA10X6_FORMATS_EXTENSION_NAME "VK_EXT_rgba10x6_formats" @@ -13811,47 +16391,37 @@ typedef struct VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT { -#define VK_NV_acquire_winrt_display 1 -#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1 -#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display" -typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); -typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay); - -#ifndef VK_NO_PROTOTYPES -VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV( - VkPhysicalDevice physicalDevice, - VkDisplayKHR display); - -VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV( - VkPhysicalDevice physicalDevice, - uint32_t deviceRelativeId, - VkDisplayKHR* pDisplay); -#endif - - +// VK_VALVE_mutable_descriptor_type is a preprocessor guard. Do not pass it to API calls. #define VK_VALVE_mutable_descriptor_type 1 #define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 #define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_VALVE_mutable_descriptor_type" -typedef struct VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE { +typedef struct VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT { VkStructureType sType; void* pNext; VkBool32 mutableDescriptorType; -} VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE; +} VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT; + +typedef VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE; -typedef struct VkMutableDescriptorTypeListVALVE { +typedef struct VkMutableDescriptorTypeListEXT { uint32_t descriptorTypeCount; const VkDescriptorType* pDescriptorTypes; -} VkMutableDescriptorTypeListVALVE; +} VkMutableDescriptorTypeListEXT; -typedef struct VkMutableDescriptorTypeCreateInfoVALVE { - VkStructureType sType; - const void* pNext; - uint32_t mutableDescriptorTypeListCount; - const VkMutableDescriptorTypeListVALVE* pMutableDescriptorTypeLists; -} VkMutableDescriptorTypeCreateInfoVALVE; +typedef VkMutableDescriptorTypeListEXT VkMutableDescriptorTypeListVALVE; + +typedef struct VkMutableDescriptorTypeCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t mutableDescriptorTypeListCount; + const VkMutableDescriptorTypeListEXT* pMutableDescriptorTypeLists; +} VkMutableDescriptorTypeCreateInfoEXT; + +typedef VkMutableDescriptorTypeCreateInfoEXT VkMutableDescriptorTypeCreateInfoVALVE; +// VK_EXT_vertex_input_dynamic_state is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_vertex_input_dynamic_state 1 #define VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_SPEC_VERSION 2 #define VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_vertex_input_dynamic_state" @@ -13891,6 +16461,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetVertexInputEXT( #endif +// VK_EXT_physical_device_drm is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_physical_device_drm 1 #define VK_EXT_PHYSICAL_DEVICE_DRM_SPEC_VERSION 1 #define VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME "VK_EXT_physical_device_drm" @@ -13907,6 +16478,40 @@ typedef struct VkPhysicalDeviceDrmPropertiesEXT { +// VK_EXT_device_address_binding_report is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_device_address_binding_report 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_SPEC_VERSION 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME "VK_EXT_device_address_binding_report" + +typedef enum VkDeviceAddressBindingTypeEXT { + VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT = 0, + VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT = 1, + VK_DEVICE_ADDRESS_BINDING_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingTypeEXT; + +typedef enum VkDeviceAddressBindingFlagBitsEXT { + VK_DEVICE_ADDRESS_BINDING_INTERNAL_OBJECT_BIT_EXT = 0x00000001, + VK_DEVICE_ADDRESS_BINDING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingFlagBitsEXT; +typedef VkFlags VkDeviceAddressBindingFlagsEXT; +typedef struct VkPhysicalDeviceAddressBindingReportFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 reportAddressBinding; +} VkPhysicalDeviceAddressBindingReportFeaturesEXT; + +typedef struct VkDeviceAddressBindingCallbackDataEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddressBindingFlagsEXT flags; + VkDeviceAddress baseAddress; + VkDeviceSize size; + VkDeviceAddressBindingTypeEXT bindingType; +} VkDeviceAddressBindingCallbackDataEXT; + + + +// VK_EXT_depth_clip_control is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_depth_clip_control 1 #define VK_EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION 1 #define VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME "VK_EXT_depth_clip_control" @@ -13924,6 +16529,7 @@ typedef struct VkPipelineViewportDepthClipControlCreateInfoEXT { +// VK_EXT_primitive_topology_list_restart is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_primitive_topology_list_restart 1 #define VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_SPEC_VERSION 1 #define VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME "VK_EXT_primitive_topology_list_restart" @@ -13936,8 +16542,9 @@ typedef struct VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT { +// VK_HUAWEI_subpass_shading is a preprocessor guard. Do not pass it to API calls. #define VK_HUAWEI_subpass_shading 1 -#define VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION 2 +#define VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION 3 #define VK_HUAWEI_SUBPASS_SHADING_EXTENSION_NAME "VK_HUAWEI_subpass_shading" typedef struct VkSubpassShadingPipelineCreateInfoHUAWEI { VkStructureType sType; @@ -13972,6 +16579,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSubpassShadingHUAWEI( #endif +// VK_HUAWEI_invocation_mask is a preprocessor guard. Do not pass it to API calls. #define VK_HUAWEI_invocation_mask 1 #define VK_HUAWEI_INVOCATION_MASK_SPEC_VERSION 1 #define VK_HUAWEI_INVOCATION_MASK_EXTENSION_NAME "VK_HUAWEI_invocation_mask" @@ -13991,6 +16599,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdBindInvocationMaskHUAWEI( #endif +// VK_NV_external_memory_rdma is a preprocessor guard. Do not pass it to API calls. #define VK_NV_external_memory_rdma 1 typedef void* VkRemoteAddressNV; #define VK_NV_EXTERNAL_MEMORY_RDMA_SPEC_VERSION 1 @@ -14018,6 +16627,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryRemoteAddressNV( #endif +// VK_EXT_pipeline_properties is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_pipeline_properties 1 #define VK_EXT_PIPELINE_PROPERTIES_SPEC_VERSION 1 #define VK_EXT_PIPELINE_PROPERTIES_EXTENSION_NAME "VK_EXT_pipeline_properties" @@ -14045,6 +16655,39 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelinePropertiesEXT( #endif +// VK_EXT_frame_boundary is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_frame_boundary 1 +#define VK_EXT_FRAME_BOUNDARY_SPEC_VERSION 1 +#define VK_EXT_FRAME_BOUNDARY_EXTENSION_NAME "VK_EXT_frame_boundary" + +typedef enum VkFrameBoundaryFlagBitsEXT { + VK_FRAME_BOUNDARY_FRAME_END_BIT_EXT = 0x00000001, + VK_FRAME_BOUNDARY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkFrameBoundaryFlagBitsEXT; +typedef VkFlags VkFrameBoundaryFlagsEXT; +typedef struct VkPhysicalDeviceFrameBoundaryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 frameBoundary; +} VkPhysicalDeviceFrameBoundaryFeaturesEXT; + +typedef struct VkFrameBoundaryEXT { + VkStructureType sType; + const void* pNext; + VkFrameBoundaryFlagsEXT flags; + uint64_t frameID; + uint32_t imageCount; + const VkImage* pImages; + uint32_t bufferCount; + const VkBuffer* pBuffers; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkFrameBoundaryEXT; + + + +// VK_EXT_multisampled_render_to_single_sampled is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_multisampled_render_to_single_sampled 1 #define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_SPEC_VERSION 1 #define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME "VK_EXT_multisampled_render_to_single_sampled" @@ -14069,6 +16712,7 @@ typedef struct VkMultisampledRenderToSingleSampledInfoEXT { +// VK_EXT_extended_dynamic_state2 is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_extended_dynamic_state2 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_2_SPEC_VERSION 1 #define VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME "VK_EXT_extended_dynamic_state2" @@ -14109,6 +16753,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveRestartEnableEXT( #endif +// VK_EXT_color_write_enable is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_color_write_enable 1 #define VK_EXT_COLOR_WRITE_ENABLE_SPEC_VERSION 1 #define VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME "VK_EXT_color_write_enable" @@ -14135,6 +16780,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetColorWrite #endif +// VK_EXT_primitives_generated_query is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_primitives_generated_query 1 #define VK_EXT_PRIMITIVES_GENERATED_QUERY_SPEC_VERSION 1 #define VK_EXT_PRIMITIVES_GENERATED_QUERY_EXTENSION_NAME "VK_EXT_primitives_generated_query" @@ -14148,6 +16794,7 @@ typedef struct VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT { +// VK_EXT_global_priority_query is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_global_priority_query 1 #define VK_EXT_GLOBAL_PRIORITY_QUERY_SPEC_VERSION 1 #define VK_EXT_GLOBAL_PRIORITY_QUERY_EXTENSION_NAME "VK_EXT_global_priority_query" @@ -14158,6 +16805,7 @@ typedef VkQueueFamilyGlobalPriorityPropertiesKHR VkQueueFamilyGlobalPriorityProp +// VK_EXT_image_view_min_lod is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_view_min_lod 1 #define VK_EXT_IMAGE_VIEW_MIN_LOD_SPEC_VERSION 1 #define VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME "VK_EXT_image_view_min_lod" @@ -14175,6 +16823,7 @@ typedef struct VkImageViewMinLodCreateInfoEXT { +// VK_EXT_multi_draw is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_multi_draw 1 #define VK_EXT_MULTI_DRAW_SPEC_VERSION 1 #define VK_EXT_MULTI_DRAW_EXTENSION_NAME "VK_EXT_multi_draw" @@ -14224,6 +16873,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdDrawMultiIndexedEXT( #endif +// VK_EXT_image_2d_view_of_3d is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_2d_view_of_3d 1 #define VK_EXT_IMAGE_2D_VIEW_OF_3D_SPEC_VERSION 1 #define VK_EXT_IMAGE_2D_VIEW_OF_3D_EXTENSION_NAME "VK_EXT_image_2d_view_of_3d" @@ -14236,32 +16886,372 @@ typedef struct VkPhysicalDeviceImage2DViewOf3DFeaturesEXT { -#define VK_EXT_load_store_op_none 1 -#define VK_EXT_LOAD_STORE_OP_NONE_SPEC_VERSION 1 -#define VK_EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_EXT_load_store_op_none" - +// VK_EXT_shader_tile_image is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_tile_image 1 +#define VK_EXT_SHADER_TILE_IMAGE_SPEC_VERSION 1 +#define VK_EXT_SHADER_TILE_IMAGE_EXTENSION_NAME "VK_EXT_shader_tile_image" +typedef struct VkPhysicalDeviceShaderTileImageFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderTileImageColorReadAccess; + VkBool32 shaderTileImageDepthReadAccess; + VkBool32 shaderTileImageStencilReadAccess; +} VkPhysicalDeviceShaderTileImageFeaturesEXT; -#define VK_EXT_border_color_swizzle 1 -#define VK_EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION 1 -#define VK_EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME "VK_EXT_border_color_swizzle" -typedef struct VkPhysicalDeviceBorderColorSwizzleFeaturesEXT { +typedef struct VkPhysicalDeviceShaderTileImagePropertiesEXT { VkStructureType sType; void* pNext; - VkBool32 borderColorSwizzle; - VkBool32 borderColorSwizzleFromImage; -} VkPhysicalDeviceBorderColorSwizzleFeaturesEXT; + VkBool32 shaderTileImageCoherentReadAccelerated; + VkBool32 shaderTileImageReadSampleFromPixelRateInvocation; + VkBool32 shaderTileImageReadFromHelperInvocation; +} VkPhysicalDeviceShaderTileImagePropertiesEXT; -typedef struct VkSamplerBorderColorComponentMappingCreateInfoEXT { - VkStructureType sType; - const void* pNext; - VkComponentMapping components; - VkBool32 srgb; -} VkSamplerBorderColorComponentMappingCreateInfoEXT; +// VK_EXT_opacity_micromap is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_opacity_micromap 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkMicromapEXT) +#define VK_EXT_OPACITY_MICROMAP_SPEC_VERSION 2 +#define VK_EXT_OPACITY_MICROMAP_EXTENSION_NAME "VK_EXT_opacity_micromap" -#define VK_EXT_pageable_device_local_memory 1 -#define VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION 1 +typedef enum VkMicromapTypeEXT { + VK_MICROMAP_TYPE_OPACITY_MICROMAP_EXT = 0, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_MICROMAP_TYPE_DISPLACEMENT_MICROMAP_NV = 1000397000, +#endif + VK_MICROMAP_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapTypeEXT; + +typedef enum VkBuildMicromapModeEXT { + VK_BUILD_MICROMAP_MODE_BUILD_EXT = 0, + VK_BUILD_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapModeEXT; + +typedef enum VkCopyMicromapModeEXT { + VK_COPY_MICROMAP_MODE_CLONE_EXT = 0, + VK_COPY_MICROMAP_MODE_SERIALIZE_EXT = 1, + VK_COPY_MICROMAP_MODE_DESERIALIZE_EXT = 2, + VK_COPY_MICROMAP_MODE_COMPACT_EXT = 3, + VK_COPY_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkCopyMicromapModeEXT; + +typedef enum VkOpacityMicromapFormatEXT { + VK_OPACITY_MICROMAP_FORMAT_2_STATE_EXT = 1, + VK_OPACITY_MICROMAP_FORMAT_4_STATE_EXT = 2, + VK_OPACITY_MICROMAP_FORMAT_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapFormatEXT; + +typedef enum VkOpacityMicromapSpecialIndexEXT { + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_TRANSPARENT_EXT = -1, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_OPAQUE_EXT = -2, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_TRANSPARENT_EXT = -3, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_OPAQUE_EXT = -4, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapSpecialIndexEXT; + +typedef enum VkAccelerationStructureCompatibilityKHR { + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR = 0, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR = 1, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureCompatibilityKHR; + +typedef enum VkAccelerationStructureBuildTypeKHR { + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureBuildTypeKHR; + +typedef enum VkBuildMicromapFlagBitsEXT { + VK_BUILD_MICROMAP_PREFER_FAST_TRACE_BIT_EXT = 0x00000001, + VK_BUILD_MICROMAP_PREFER_FAST_BUILD_BIT_EXT = 0x00000002, + VK_BUILD_MICROMAP_ALLOW_COMPACTION_BIT_EXT = 0x00000004, + VK_BUILD_MICROMAP_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapFlagBitsEXT; +typedef VkFlags VkBuildMicromapFlagsEXT; + +typedef enum VkMicromapCreateFlagBitsEXT { + VK_MICROMAP_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000001, + VK_MICROMAP_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapCreateFlagBitsEXT; +typedef VkFlags VkMicromapCreateFlagsEXT; +typedef struct VkMicromapUsageEXT { + uint32_t count; + uint32_t subdivisionLevel; + uint32_t format; +} VkMicromapUsageEXT; + +typedef union VkDeviceOrHostAddressKHR { + VkDeviceAddress deviceAddress; + void* hostAddress; +} VkDeviceOrHostAddressKHR; + +typedef struct VkMicromapBuildInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapTypeEXT type; + VkBuildMicromapFlagsEXT flags; + VkBuildMicromapModeEXT mode; + VkMicromapEXT dstMicromap; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkDeviceOrHostAddressConstKHR data; + VkDeviceOrHostAddressKHR scratchData; + VkDeviceOrHostAddressConstKHR triangleArray; + VkDeviceSize triangleArrayStride; +} VkMicromapBuildInfoEXT; + +typedef struct VkMicromapCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapCreateFlagsEXT createFlags; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; + VkMicromapTypeEXT type; + VkDeviceAddress deviceAddress; +} VkMicromapCreateInfoEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 micromap; + VkBool32 micromapCaptureReplay; + VkBool32 micromapHostCommands; +} VkPhysicalDeviceOpacityMicromapFeaturesEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxOpacity2StateSubdivisionLevel; + uint32_t maxOpacity4StateSubdivisionLevel; +} VkPhysicalDeviceOpacityMicromapPropertiesEXT; + +typedef struct VkMicromapVersionInfoEXT { + VkStructureType sType; + const void* pNext; + const uint8_t* pVersionData; +} VkMicromapVersionInfoEXT; + +typedef struct VkCopyMicromapToMemoryInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkDeviceOrHostAddressKHR dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapToMemoryInfoEXT; + +typedef struct VkCopyMemoryToMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMemoryToMicromapInfoEXT; + +typedef struct VkCopyMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapInfoEXT; + +typedef struct VkMicromapBuildSizesInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceSize micromapSize; + VkDeviceSize buildScratchSize; + VkBool32 discardable; +} VkMicromapBuildSizesInfoEXT; + +typedef struct VkAccelerationStructureTrianglesOpacityMicromapEXT { + VkStructureType sType; + void* pNext; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexBuffer; + VkDeviceSize indexStride; + uint32_t baseTriangle; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkMicromapEXT micromap; +} VkAccelerationStructureTrianglesOpacityMicromapEXT; + +typedef struct VkMicromapTriangleEXT { + uint32_t dataOffset; + uint16_t subdivisionLevel; + uint16_t format; +} VkMicromapTriangleEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMicromapEXT)(VkDevice device, const VkMicromapCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkMicromapEXT* pMicromap); +typedef void (VKAPI_PTR *PFN_vkDestroyMicromapEXT)(VkDevice device, VkMicromapEXT micromap, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBuildMicromapsEXT)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBuildMicromapsEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapToMemoryEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkWriteMicromapsPropertiesEXT)(VkDevice device, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, size_t dataSize, void* pData, size_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapToMemoryEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteMicromapsPropertiesEXT)(VkCommandBuffer commandBuffer, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef void (VKAPI_PTR *PFN_vkGetDeviceMicromapCompatibilityEXT)(VkDevice device, const VkMicromapVersionInfoEXT* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility); +typedef void (VKAPI_PTR *PFN_vkGetMicromapBuildSizesEXT)(VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkMicromapBuildInfoEXT* pBuildInfo, VkMicromapBuildSizesInfoEXT* pSizeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMicromapEXT( + VkDevice device, + const VkMicromapCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkMicromapEXT* pMicromap); + +VKAPI_ATTR void VKAPI_CALL vkDestroyMicromapEXT( + VkDevice device, + VkMicromapEXT micromap, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildMicromapsEXT( + VkCommandBuffer commandBuffer, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBuildMicromapsEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapToMemoryEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkWriteMicromapsPropertiesEXT( + VkDevice device, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + size_t dataSize, + void* pData, + size_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapToMemoryEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteMicromapsPropertiesEXT( + VkCommandBuffer commandBuffer, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceMicromapCompatibilityEXT( + VkDevice device, + const VkMicromapVersionInfoEXT* pVersionInfo, + VkAccelerationStructureCompatibilityKHR* pCompatibility); + +VKAPI_ATTR void VKAPI_CALL vkGetMicromapBuildSizesEXT( + VkDevice device, + VkAccelerationStructureBuildTypeKHR buildType, + const VkMicromapBuildInfoEXT* pBuildInfo, + VkMicromapBuildSizesInfoEXT* pSizeInfo); +#endif + + +// VK_EXT_load_store_op_none is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_load_store_op_none 1 +#define VK_EXT_LOAD_STORE_OP_NONE_SPEC_VERSION 1 +#define VK_EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_EXT_load_store_op_none" + + +// VK_HUAWEI_cluster_culling_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_HUAWEI_cluster_culling_shader 1 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_SPEC_VERSION 3 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_EXTENSION_NAME "VK_HUAWEI_cluster_culling_shader" +typedef struct VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 clustercullingShader; + VkBool32 multiviewClusterCullingShader; +} VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI; + +typedef struct VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI { + VkStructureType sType; + void* pNext; + uint32_t maxWorkGroupCount[3]; + uint32_t maxWorkGroupSize[3]; + uint32_t maxOutputClusterCount; + VkDeviceSize indirectBufferOffsetAlignment; +} VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI; + +typedef struct VkPhysicalDeviceClusterCullingShaderVrsFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 clusterShadingRate; +} VkPhysicalDeviceClusterCullingShaderVrsFeaturesHUAWEI; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterHUAWEI)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterIndirectHUAWEI)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterHUAWEI( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterIndirectHUAWEI( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset); +#endif + + +// VK_EXT_border_color_swizzle is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_border_color_swizzle 1 +#define VK_EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION 1 +#define VK_EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME "VK_EXT_border_color_swizzle" +typedef struct VkPhysicalDeviceBorderColorSwizzleFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 borderColorSwizzle; + VkBool32 borderColorSwizzleFromImage; +} VkPhysicalDeviceBorderColorSwizzleFeaturesEXT; + +typedef struct VkSamplerBorderColorComponentMappingCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkComponentMapping components; + VkBool32 srgb; +} VkSamplerBorderColorComponentMappingCreateInfoEXT; + + + +// VK_EXT_pageable_device_local_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pageable_device_local_memory 1 +#define VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION 1 #define VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME "VK_EXT_pageable_device_local_memory" typedef struct VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT { VkStructureType sType; @@ -14279,6 +17269,71 @@ VKAPI_ATTR void VKAPI_CALL vkSetDeviceMemoryPriorityEXT( #endif +// VK_ARM_shader_core_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_shader_core_properties 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_SPEC_VERSION 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_ARM_shader_core_properties" +typedef struct VkPhysicalDeviceShaderCorePropertiesARM { + VkStructureType sType; + void* pNext; + uint32_t pixelRate; + uint32_t texelRate; + uint32_t fmaRate; +} VkPhysicalDeviceShaderCorePropertiesARM; + + + +// VK_ARM_scheduling_controls is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_scheduling_controls 1 +#define VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION 1 +#define VK_ARM_SCHEDULING_CONTROLS_EXTENSION_NAME "VK_ARM_scheduling_controls" +typedef VkFlags64 VkPhysicalDeviceSchedulingControlsFlagsARM; + +// Flag bits for VkPhysicalDeviceSchedulingControlsFlagBitsARM +typedef VkFlags64 VkPhysicalDeviceSchedulingControlsFlagBitsARM; +static const VkPhysicalDeviceSchedulingControlsFlagBitsARM VK_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_SHADER_CORE_COUNT_ARM = 0x00000001ULL; + +typedef struct VkDeviceQueueShaderCoreControlCreateInfoARM { + VkStructureType sType; + void* pNext; + uint32_t shaderCoreCount; +} VkDeviceQueueShaderCoreControlCreateInfoARM; + +typedef struct VkPhysicalDeviceSchedulingControlsFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 schedulingControls; +} VkPhysicalDeviceSchedulingControlsFeaturesARM; + +typedef struct VkPhysicalDeviceSchedulingControlsPropertiesARM { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceSchedulingControlsFlagsARM schedulingControlsFlags; +} VkPhysicalDeviceSchedulingControlsPropertiesARM; + + + +// VK_EXT_image_sliced_view_of_3d is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_sliced_view_of_3d 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_SPEC_VERSION 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_EXTENSION_NAME "VK_EXT_image_sliced_view_of_3d" +#define VK_REMAINING_3D_SLICES_EXT (~0U) +typedef struct VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageSlicedViewOf3D; +} VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT; + +typedef struct VkImageViewSlicedCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t sliceOffset; + uint32_t sliceCount; +} VkImageViewSlicedCreateInfoEXT; + + + +// VK_VALVE_descriptor_set_host_mapping is a preprocessor guard. Do not pass it to API calls. #define VK_VALVE_descriptor_set_host_mapping 1 #define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_SPEC_VERSION 1 #define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_EXTENSION_NAME "VK_VALVE_descriptor_set_host_mapping" @@ -14318,6 +17373,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetHostMappingVALVE( #endif +// VK_EXT_depth_clamp_zero_one is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_depth_clamp_zero_one 1 #define VK_EXT_DEPTH_CLAMP_ZERO_ONE_SPEC_VERSION 1 #define VK_EXT_DEPTH_CLAMP_ZERO_ONE_EXTENSION_NAME "VK_EXT_depth_clamp_zero_one" @@ -14329,6 +17385,7 @@ typedef struct VkPhysicalDeviceDepthClampZeroOneFeaturesEXT { +// VK_EXT_non_seamless_cube_map is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_non_seamless_cube_map 1 #define VK_EXT_NON_SEAMLESS_CUBE_MAP_SPEC_VERSION 1 #define VK_EXT_NON_SEAMLESS_CUBE_MAP_EXTENSION_NAME "VK_EXT_non_seamless_cube_map" @@ -14340,6 +17397,46 @@ typedef struct VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT { +// VK_ARM_render_pass_striped is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_render_pass_striped 1 +#define VK_ARM_RENDER_PASS_STRIPED_SPEC_VERSION 1 +#define VK_ARM_RENDER_PASS_STRIPED_EXTENSION_NAME "VK_ARM_render_pass_striped" +typedef struct VkPhysicalDeviceRenderPassStripedFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 renderPassStriped; +} VkPhysicalDeviceRenderPassStripedFeaturesARM; + +typedef struct VkPhysicalDeviceRenderPassStripedPropertiesARM { + VkStructureType sType; + void* pNext; + VkExtent2D renderPassStripeGranularity; + uint32_t maxRenderPassStripes; +} VkPhysicalDeviceRenderPassStripedPropertiesARM; + +typedef struct VkRenderPassStripeInfoARM { + VkStructureType sType; + const void* pNext; + VkRect2D stripeArea; +} VkRenderPassStripeInfoARM; + +typedef struct VkRenderPassStripeBeginInfoARM { + VkStructureType sType; + const void* pNext; + uint32_t stripeInfoCount; + const VkRenderPassStripeInfoARM* pStripeInfos; +} VkRenderPassStripeBeginInfoARM; + +typedef struct VkRenderPassStripeSubmitInfoARM { + VkStructureType sType; + const void* pNext; + uint32_t stripeSemaphoreInfoCount; + const VkSemaphoreSubmitInfo* pStripeSemaphoreInfos; +} VkRenderPassStripeSubmitInfoARM; + + + +// VK_QCOM_fragment_density_map_offset is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_fragment_density_map_offset 1 #define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_SPEC_VERSION 1 #define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_EXTENSION_NAME "VK_QCOM_fragment_density_map_offset" @@ -14364,6 +17461,159 @@ typedef struct VkSubpassFragmentDensityMapOffsetEndInfoQCOM { +// VK_NV_copy_memory_indirect is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_copy_memory_indirect 1 +#define VK_NV_COPY_MEMORY_INDIRECT_SPEC_VERSION 1 +#define VK_NV_COPY_MEMORY_INDIRECT_EXTENSION_NAME "VK_NV_copy_memory_indirect" +typedef struct VkCopyMemoryIndirectCommandNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize size; +} VkCopyMemoryIndirectCommandNV; + +typedef struct VkCopyMemoryToImageIndirectCommandNV { + VkDeviceAddress srcAddress; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkCopyMemoryToImageIndirectCommandNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 indirectCopy; +} VkPhysicalDeviceCopyMemoryIndirectFeaturesNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectPropertiesNV { + VkStructureType sType; + void* pNext; + VkQueueFlags supportedQueues; +} VkPhysicalDeviceCopyMemoryIndirectPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToImageIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageSubresourceLayers* pImageSubresources); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToImageIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride, + VkImage dstImage, + VkImageLayout dstImageLayout, + const VkImageSubresourceLayers* pImageSubresources); +#endif + + +// VK_NV_memory_decompression is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_memory_decompression 1 +#define VK_NV_MEMORY_DECOMPRESSION_SPEC_VERSION 1 +#define VK_NV_MEMORY_DECOMPRESSION_EXTENSION_NAME "VK_NV_memory_decompression" + +// Flag bits for VkMemoryDecompressionMethodFlagBitsNV +typedef VkFlags64 VkMemoryDecompressionMethodFlagBitsNV; +static const VkMemoryDecompressionMethodFlagBitsNV VK_MEMORY_DECOMPRESSION_METHOD_GDEFLATE_1_0_BIT_NV = 0x00000001ULL; + +typedef VkFlags64 VkMemoryDecompressionMethodFlagsNV; +typedef struct VkDecompressMemoryRegionNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize compressedSize; + VkDeviceSize decompressedSize; + VkMemoryDecompressionMethodFlagsNV decompressionMethod; +} VkDecompressMemoryRegionNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 memoryDecompression; +} VkPhysicalDeviceMemoryDecompressionFeaturesNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionPropertiesNV { + VkStructureType sType; + void* pNext; + VkMemoryDecompressionMethodFlagsNV decompressionMethods; + uint64_t maxDecompressionIndirectCount; +} VkPhysicalDeviceMemoryDecompressionPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryNV)(VkCommandBuffer commandBuffer, uint32_t decompressRegionCount, const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryIndirectCountNV)(VkCommandBuffer commandBuffer, VkDeviceAddress indirectCommandsAddress, VkDeviceAddress indirectCommandsCountAddress, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryNV( + VkCommandBuffer commandBuffer, + uint32_t decompressRegionCount, + const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryIndirectCountNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress indirectCommandsAddress, + VkDeviceAddress indirectCommandsCountAddress, + uint32_t stride); +#endif + + +// VK_NV_device_generated_commands_compute is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_generated_commands_compute 1 +#define VK_NV_DEVICE_GENERATED_COMMANDS_COMPUTE_SPEC_VERSION 2 +#define VK_NV_DEVICE_GENERATED_COMMANDS_COMPUTE_EXTENSION_NAME "VK_NV_device_generated_commands_compute" +typedef struct VkPhysicalDeviceDeviceGeneratedCommandsComputeFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 deviceGeneratedCompute; + VkBool32 deviceGeneratedComputePipelines; + VkBool32 deviceGeneratedComputeCaptureReplay; +} VkPhysicalDeviceDeviceGeneratedCommandsComputeFeaturesNV; + +typedef struct VkComputePipelineIndirectBufferInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceAddress deviceAddress; + VkDeviceSize size; + VkDeviceAddress pipelineDeviceAddressCaptureReplay; +} VkComputePipelineIndirectBufferInfoNV; + +typedef struct VkPipelineIndirectDeviceAddressInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineBindPoint pipelineBindPoint; + VkPipeline pipeline; +} VkPipelineIndirectDeviceAddressInfoNV; + +typedef struct VkBindPipelineIndirectCommandNV { + VkDeviceAddress pipelineAddress; +} VkBindPipelineIndirectCommandNV; + +typedef void (VKAPI_PTR *PFN_vkGetPipelineIndirectMemoryRequirementsNV)(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkCmdUpdatePipelineIndirectBufferNV)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetPipelineIndirectDeviceAddressNV)(VkDevice device, const VkPipelineIndirectDeviceAddressInfoNV* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPipelineIndirectMemoryRequirementsNV( + VkDevice device, + const VkComputePipelineCreateInfo* pCreateInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkCmdUpdatePipelineIndirectBufferNV( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline); + +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetPipelineIndirectDeviceAddressNV( + VkDevice device, + const VkPipelineIndirectDeviceAddressInfoNV* pInfo); +#endif + + +// VK_NV_linear_color_attachment is a preprocessor guard. Do not pass it to API calls. #define VK_NV_linear_color_attachment 1 #define VK_NV_LINEAR_COLOR_ATTACHMENT_SPEC_VERSION 1 #define VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME "VK_NV_linear_color_attachment" @@ -14375,11 +17625,13 @@ typedef struct VkPhysicalDeviceLinearColorAttachmentFeaturesNV { +// VK_GOOGLE_surfaceless_query is a preprocessor guard. Do not pass it to API calls. #define VK_GOOGLE_surfaceless_query 1 -#define VK_GOOGLE_SURFACELESS_QUERY_SPEC_VERSION 1 +#define VK_GOOGLE_SURFACELESS_QUERY_SPEC_VERSION 2 #define VK_GOOGLE_SURFACELESS_QUERY_EXTENSION_NAME "VK_GOOGLE_surfaceless_query" +// VK_EXT_image_compression_control_swapchain is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_image_compression_control_swapchain 1 #define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION 1 #define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME "VK_EXT_image_compression_control_swapchain" @@ -14391,6 +17643,7 @@ typedef struct VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT { +// VK_QCOM_image_processing is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_image_processing 1 #define VK_QCOM_IMAGE_PROCESSING_SPEC_VERSION 1 #define VK_QCOM_IMAGE_PROCESSING_EXTENSION_NAME "VK_QCOM_image_processing" @@ -14421,6 +17674,273 @@ typedef struct VkPhysicalDeviceImageProcessingPropertiesQCOM { +// VK_EXT_nested_command_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_nested_command_buffer 1 +#define VK_EXT_NESTED_COMMAND_BUFFER_SPEC_VERSION 1 +#define VK_EXT_NESTED_COMMAND_BUFFER_EXTENSION_NAME "VK_EXT_nested_command_buffer" +typedef struct VkPhysicalDeviceNestedCommandBufferFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 nestedCommandBuffer; + VkBool32 nestedCommandBufferRendering; + VkBool32 nestedCommandBufferSimultaneousUse; +} VkPhysicalDeviceNestedCommandBufferFeaturesEXT; + +typedef struct VkPhysicalDeviceNestedCommandBufferPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxCommandBufferNestingLevel; +} VkPhysicalDeviceNestedCommandBufferPropertiesEXT; + + + +// VK_EXT_external_memory_acquire_unmodified is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_external_memory_acquire_unmodified 1 +#define VK_EXT_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXTENSION_NAME "VK_EXT_external_memory_acquire_unmodified" +typedef struct VkExternalMemoryAcquireUnmodifiedEXT { + VkStructureType sType; + const void* pNext; + VkBool32 acquireUnmodifiedMemory; +} VkExternalMemoryAcquireUnmodifiedEXT; + + + +// VK_EXT_extended_dynamic_state3 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_extended_dynamic_state3 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_SPEC_VERSION 2 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME "VK_EXT_extended_dynamic_state3" +typedef struct VkPhysicalDeviceExtendedDynamicState3FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 extendedDynamicState3TessellationDomainOrigin; + VkBool32 extendedDynamicState3DepthClampEnable; + VkBool32 extendedDynamicState3PolygonMode; + VkBool32 extendedDynamicState3RasterizationSamples; + VkBool32 extendedDynamicState3SampleMask; + VkBool32 extendedDynamicState3AlphaToCoverageEnable; + VkBool32 extendedDynamicState3AlphaToOneEnable; + VkBool32 extendedDynamicState3LogicOpEnable; + VkBool32 extendedDynamicState3ColorBlendEnable; + VkBool32 extendedDynamicState3ColorBlendEquation; + VkBool32 extendedDynamicState3ColorWriteMask; + VkBool32 extendedDynamicState3RasterizationStream; + VkBool32 extendedDynamicState3ConservativeRasterizationMode; + VkBool32 extendedDynamicState3ExtraPrimitiveOverestimationSize; + VkBool32 extendedDynamicState3DepthClipEnable; + VkBool32 extendedDynamicState3SampleLocationsEnable; + VkBool32 extendedDynamicState3ColorBlendAdvanced; + VkBool32 extendedDynamicState3ProvokingVertexMode; + VkBool32 extendedDynamicState3LineRasterizationMode; + VkBool32 extendedDynamicState3LineStippleEnable; + VkBool32 extendedDynamicState3DepthClipNegativeOneToOne; + VkBool32 extendedDynamicState3ViewportWScalingEnable; + VkBool32 extendedDynamicState3ViewportSwizzle; + VkBool32 extendedDynamicState3CoverageToColorEnable; + VkBool32 extendedDynamicState3CoverageToColorLocation; + VkBool32 extendedDynamicState3CoverageModulationMode; + VkBool32 extendedDynamicState3CoverageModulationTableEnable; + VkBool32 extendedDynamicState3CoverageModulationTable; + VkBool32 extendedDynamicState3CoverageReductionMode; + VkBool32 extendedDynamicState3RepresentativeFragmentTestEnable; + VkBool32 extendedDynamicState3ShadingRateImageEnable; +} VkPhysicalDeviceExtendedDynamicState3FeaturesEXT; + +typedef struct VkPhysicalDeviceExtendedDynamicState3PropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 dynamicPrimitiveTopologyUnrestricted; +} VkPhysicalDeviceExtendedDynamicState3PropertiesEXT; + +typedef struct VkColorBlendEquationEXT { + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; +} VkColorBlendEquationEXT; + +typedef struct VkColorBlendAdvancedEXT { + VkBlendOp advancedBlendOp; + VkBool32 srcPremultiplied; + VkBool32 dstPremultiplied; + VkBlendOverlapEXT blendOverlap; + VkBool32 clampResults; +} VkColorBlendAdvancedEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetTessellationDomainOriginEXT)(VkCommandBuffer commandBuffer, VkTessellationDomainOrigin domainOrigin); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClampEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClampEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetPolygonModeEXT)(VkCommandBuffer commandBuffer, VkPolygonMode polygonMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationSamplesEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits rasterizationSamples); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleMaskEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits samples, const VkSampleMask* pSampleMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToCoverageEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToCoverageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToOneEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToOneEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetLogicOpEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 logicOpEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEnableEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkBool32* pColorBlendEnables); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEquationEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendEquationEXT* pColorBlendEquations); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorWriteMaskEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorComponentFlags* pColorWriteMasks); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationStreamEXT)(VkCommandBuffer commandBuffer, uint32_t rasterizationStream); +typedef void (VKAPI_PTR *PFN_vkCmdSetConservativeRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkConservativeRasterizationModeEXT conservativeRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT)(VkCommandBuffer commandBuffer, float extraPrimitiveOverestimationSize); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClipEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 sampleLocationsEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendAdvancedEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendAdvancedEXT* pColorBlendAdvanced); +typedef void (VKAPI_PTR *PFN_vkCmdSetProvokingVertexModeEXT)(VkCommandBuffer commandBuffer, VkProvokingVertexModeEXT provokingVertexMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkLineRasterizationModeEXT lineRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 stippledLineEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipNegativeOneToOneEXT)(VkCommandBuffer commandBuffer, VkBool32 negativeOneToOne); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingEnableNV)(VkCommandBuffer commandBuffer, VkBool32 viewportWScalingEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportSwizzleNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportSwizzleNV* pViewportSwizzles); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageToColorEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorLocationNV)(VkCommandBuffer commandBuffer, uint32_t coverageToColorLocation); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationModeNV)(VkCommandBuffer commandBuffer, VkCoverageModulationModeNV coverageModulationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageModulationTableEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableNV)(VkCommandBuffer commandBuffer, uint32_t coverageModulationTableCount, const float* pCoverageModulationTable); +typedef void (VKAPI_PTR *PFN_vkCmdSetShadingRateImageEnableNV)(VkCommandBuffer commandBuffer, VkBool32 shadingRateImageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetRepresentativeFragmentTestEnableNV)(VkCommandBuffer commandBuffer, VkBool32 representativeFragmentTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageReductionModeNV)(VkCommandBuffer commandBuffer, VkCoverageReductionModeNV coverageReductionMode); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetTessellationDomainOriginEXT( + VkCommandBuffer commandBuffer, + VkTessellationDomainOrigin domainOrigin); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClampEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClampEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPolygonModeEXT( + VkCommandBuffer commandBuffer, + VkPolygonMode polygonMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationSamplesEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits rasterizationSamples); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleMaskEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits samples, + const VkSampleMask* pSampleMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToCoverageEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToCoverageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToOneEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToOneEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLogicOpEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 logicOpEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEnableEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkBool32* pColorBlendEnables); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEquationEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendEquationEXT* pColorBlendEquations); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorWriteMaskEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorComponentFlags* pColorWriteMasks); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationStreamEXT( + VkCommandBuffer commandBuffer, + uint32_t rasterizationStream); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetConservativeRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkConservativeRasterizationModeEXT conservativeRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetExtraPrimitiveOverestimationSizeEXT( + VkCommandBuffer commandBuffer, + float extraPrimitiveOverestimationSize); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClipEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 sampleLocationsEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendAdvancedEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendAdvancedEXT* pColorBlendAdvanced); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetProvokingVertexModeEXT( + VkCommandBuffer commandBuffer, + VkProvokingVertexModeEXT provokingVertexMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkLineRasterizationModeEXT lineRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 stippledLineEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipNegativeOneToOneEXT( + VkCommandBuffer commandBuffer, + VkBool32 negativeOneToOne); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 viewportWScalingEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportSwizzleNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewportSwizzleNV* pViewportSwizzles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageToColorEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorLocationNV( + VkCommandBuffer commandBuffer, + uint32_t coverageToColorLocation); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationModeNV( + VkCommandBuffer commandBuffer, + VkCoverageModulationModeNV coverageModulationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageModulationTableEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableNV( + VkCommandBuffer commandBuffer, + uint32_t coverageModulationTableCount, + const float* pCoverageModulationTable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetShadingRateImageEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 shadingRateImageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRepresentativeFragmentTestEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 representativeFragmentTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageReductionModeNV( + VkCommandBuffer commandBuffer, + VkCoverageReductionModeNV coverageReductionMode); +#endif + + +// VK_EXT_subpass_merge_feedback is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_subpass_merge_feedback 1 #define VK_EXT_SUBPASS_MERGE_FEEDBACK_SPEC_VERSION 2 #define VK_EXT_SUBPASS_MERGE_FEEDBACK_EXTENSION_NAME "VK_EXT_subpass_merge_feedback" @@ -14478,6 +17998,38 @@ typedef struct VkRenderPassSubpassFeedbackCreateInfoEXT { +// VK_LUNARG_direct_driver_loading is a preprocessor guard. Do not pass it to API calls. +#define VK_LUNARG_direct_driver_loading 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_SPEC_VERSION 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME "VK_LUNARG_direct_driver_loading" + +typedef enum VkDirectDriverLoadingModeLUNARG { + VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG = 0, + VK_DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG = 1, + VK_DIRECT_DRIVER_LOADING_MODE_MAX_ENUM_LUNARG = 0x7FFFFFFF +} VkDirectDriverLoadingModeLUNARG; +typedef VkFlags VkDirectDriverLoadingFlagsLUNARG; +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddrLUNARG)( + VkInstance instance, const char* pName); + +typedef struct VkDirectDriverLoadingInfoLUNARG { + VkStructureType sType; + void* pNext; + VkDirectDriverLoadingFlagsLUNARG flags; + PFN_vkGetInstanceProcAddrLUNARG pfnGetInstanceProcAddr; +} VkDirectDriverLoadingInfoLUNARG; + +typedef struct VkDirectDriverLoadingListLUNARG { + VkStructureType sType; + const void* pNext; + VkDirectDriverLoadingModeLUNARG mode; + uint32_t driverCount; + const VkDirectDriverLoadingInfoLUNARG* pDrivers; +} VkDirectDriverLoadingListLUNARG; + + + +// VK_EXT_shader_module_identifier is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_shader_module_identifier 1 #define VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT 32U #define VK_EXT_SHADER_MODULE_IDENTIFIER_SPEC_VERSION 1 @@ -14524,11 +18076,178 @@ VKAPI_ATTR void VKAPI_CALL vkGetShaderModuleCreateInfoIdentifierEXT( #endif +// VK_EXT_rasterization_order_attachment_access is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_rasterization_order_attachment_access 1 #define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 #define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_EXT_rasterization_order_attachment_access" +// VK_NV_optical_flow is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_optical_flow 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkOpticalFlowSessionNV) +#define VK_NV_OPTICAL_FLOW_SPEC_VERSION 1 +#define VK_NV_OPTICAL_FLOW_EXTENSION_NAME "VK_NV_optical_flow" + +typedef enum VkOpticalFlowPerformanceLevelNV { + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV = 1, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MEDIUM_NV = 2, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_FAST_NV = 3, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowPerformanceLevelNV; + +typedef enum VkOpticalFlowSessionBindingPointNV { + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_INPUT_NV = 1, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_REFERENCE_NV = 2, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_HINT_NV = 3, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_FLOW_VECTOR_NV = 4, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_FLOW_VECTOR_NV = 5, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_COST_NV = 6, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_COST_NV = 7, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_GLOBAL_FLOW_NV = 8, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionBindingPointNV; + +typedef enum VkOpticalFlowGridSizeFlagBitsNV { + VK_OPTICAL_FLOW_GRID_SIZE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_GRID_SIZE_1X1_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_GRID_SIZE_2X2_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_GRID_SIZE_4X4_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_GRID_SIZE_8X8_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_GRID_SIZE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowGridSizeFlagBitsNV; +typedef VkFlags VkOpticalFlowGridSizeFlagsNV; + +typedef enum VkOpticalFlowUsageFlagBitsNV { + VK_OPTICAL_FLOW_USAGE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_USAGE_INPUT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_USAGE_OUTPUT_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_USAGE_HINT_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_USAGE_COST_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_USAGE_GLOBAL_FLOW_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_USAGE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowUsageFlagBitsNV; +typedef VkFlags VkOpticalFlowUsageFlagsNV; + +typedef enum VkOpticalFlowSessionCreateFlagBitsNV { + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_HINT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_COST_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_GLOBAL_FLOW_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_SESSION_CREATE_ALLOW_REGIONS_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_SESSION_CREATE_BOTH_DIRECTIONS_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_SESSION_CREATE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionCreateFlagBitsNV; +typedef VkFlags VkOpticalFlowSessionCreateFlagsNV; + +typedef enum VkOpticalFlowExecuteFlagBitsNV { + VK_OPTICAL_FLOW_EXECUTE_DISABLE_TEMPORAL_HINTS_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_EXECUTE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowExecuteFlagBitsNV; +typedef VkFlags VkOpticalFlowExecuteFlagsNV; +typedef struct VkPhysicalDeviceOpticalFlowFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 opticalFlow; +} VkPhysicalDeviceOpticalFlowFeaturesNV; + +typedef struct VkPhysicalDeviceOpticalFlowPropertiesNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowGridSizeFlagsNV supportedOutputGridSizes; + VkOpticalFlowGridSizeFlagsNV supportedHintGridSizes; + VkBool32 hintSupported; + VkBool32 costSupported; + VkBool32 bidirectionalFlowSupported; + VkBool32 globalFlowSupported; + uint32_t minWidth; + uint32_t minHeight; + uint32_t maxWidth; + uint32_t maxHeight; + uint32_t maxNumRegionsOfInterest; +} VkPhysicalDeviceOpticalFlowPropertiesNV; + +typedef struct VkOpticalFlowImageFormatInfoNV { + VkStructureType sType; + const void* pNext; + VkOpticalFlowUsageFlagsNV usage; +} VkOpticalFlowImageFormatInfoNV; + +typedef struct VkOpticalFlowImageFormatPropertiesNV { + VkStructureType sType; + const void* pNext; + VkFormat format; +} VkOpticalFlowImageFormatPropertiesNV; + +typedef struct VkOpticalFlowSessionCreateInfoNV { + VkStructureType sType; + void* pNext; + uint32_t width; + uint32_t height; + VkFormat imageFormat; + VkFormat flowVectorFormat; + VkFormat costFormat; + VkOpticalFlowGridSizeFlagsNV outputGridSize; + VkOpticalFlowGridSizeFlagsNV hintGridSize; + VkOpticalFlowPerformanceLevelNV performanceLevel; + VkOpticalFlowSessionCreateFlagsNV flags; +} VkOpticalFlowSessionCreateInfoNV; + +typedef struct VkOpticalFlowSessionCreatePrivateDataInfoNV { + VkStructureType sType; + void* pNext; + uint32_t id; + uint32_t size; + const void* pPrivateData; +} VkOpticalFlowSessionCreatePrivateDataInfoNV; + +typedef struct VkOpticalFlowExecuteInfoNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowExecuteFlagsNV flags; + uint32_t regionCount; + const VkRect2D* pRegions; +} VkOpticalFlowExecuteInfoNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV)(VkPhysicalDevice physicalDevice, const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, uint32_t* pFormatCount, VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateOpticalFlowSessionNV)(VkDevice device, const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkOpticalFlowSessionNV* pSession); +typedef void (VKAPI_PTR *PFN_vkDestroyOpticalFlowSessionNV)(VkDevice device, VkOpticalFlowSessionNV session, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkBindOpticalFlowSessionImageNV)(VkDevice device, VkOpticalFlowSessionNV session, VkOpticalFlowSessionBindingPointNV bindingPoint, VkImageView view, VkImageLayout layout); +typedef void (VKAPI_PTR *PFN_vkCmdOpticalFlowExecuteNV)(VkCommandBuffer commandBuffer, VkOpticalFlowSessionNV session, const VkOpticalFlowExecuteInfoNV* pExecuteInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceOpticalFlowImageFormatsNV( + VkPhysicalDevice physicalDevice, + const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, + uint32_t* pFormatCount, + VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateOpticalFlowSessionNV( + VkDevice device, + const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkOpticalFlowSessionNV* pSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyOpticalFlowSessionNV( + VkDevice device, + VkOpticalFlowSessionNV session, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindOpticalFlowSessionImageNV( + VkDevice device, + VkOpticalFlowSessionNV session, + VkOpticalFlowSessionBindingPointNV bindingPoint, + VkImageView view, + VkImageLayout layout); + +VKAPI_ATTR void VKAPI_CALL vkCmdOpticalFlowExecuteNV( + VkCommandBuffer commandBuffer, + VkOpticalFlowSessionNV session, + const VkOpticalFlowExecuteInfoNV* pExecuteInfo); +#endif + + +// VK_EXT_legacy_dithering is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_legacy_dithering 1 #define VK_EXT_LEGACY_DITHERING_SPEC_VERSION 1 #define VK_EXT_LEGACY_DITHERING_EXTENSION_NAME "VK_EXT_legacy_dithering" @@ -14540,6 +18259,106 @@ typedef struct VkPhysicalDeviceLegacyDitheringFeaturesEXT { +// VK_EXT_pipeline_protected_access is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_protected_access 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_EXTENSION_NAME "VK_EXT_pipeline_protected_access" +typedef struct VkPhysicalDevicePipelineProtectedAccessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineProtectedAccess; +} VkPhysicalDevicePipelineProtectedAccessFeaturesEXT; + + + +// VK_EXT_shader_object is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_object 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderEXT) +#define VK_EXT_SHADER_OBJECT_SPEC_VERSION 1 +#define VK_EXT_SHADER_OBJECT_EXTENSION_NAME "VK_EXT_shader_object" + +typedef enum VkShaderCodeTypeEXT { + VK_SHADER_CODE_TYPE_BINARY_EXT = 0, + VK_SHADER_CODE_TYPE_SPIRV_EXT = 1, + VK_SHADER_CODE_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCodeTypeEXT; + +typedef enum VkShaderCreateFlagBitsEXT { + VK_SHADER_CREATE_LINK_STAGE_BIT_EXT = 0x00000001, + VK_SHADER_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000002, + VK_SHADER_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000004, + VK_SHADER_CREATE_NO_TASK_SHADER_BIT_EXT = 0x00000008, + VK_SHADER_CREATE_DISPATCH_BASE_BIT_EXT = 0x00000010, + VK_SHADER_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_EXT = 0x00000020, + VK_SHADER_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00000040, + VK_SHADER_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCreateFlagBitsEXT; +typedef VkFlags VkShaderCreateFlagsEXT; +typedef struct VkPhysicalDeviceShaderObjectFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderObject; +} VkPhysicalDeviceShaderObjectFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderObjectPropertiesEXT { + VkStructureType sType; + void* pNext; + uint8_t shaderBinaryUUID[VK_UUID_SIZE]; + uint32_t shaderBinaryVersion; +} VkPhysicalDeviceShaderObjectPropertiesEXT; + +typedef struct VkShaderCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderCreateFlagsEXT flags; + VkShaderStageFlagBits stage; + VkShaderStageFlags nextStage; + VkShaderCodeTypeEXT codeType; + size_t codeSize; + const void* pCode; + const char* pName; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; + uint32_t pushConstantRangeCount; + const VkPushConstantRange* pPushConstantRanges; + const VkSpecializationInfo* pSpecializationInfo; +} VkShaderCreateInfoEXT; + +typedef VkPipelineShaderStageRequiredSubgroupSizeCreateInfo VkShaderRequiredSubgroupSizeCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateShadersEXT)(VkDevice device, uint32_t createInfoCount, const VkShaderCreateInfoEXT* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkShaderEXT* pShaders); +typedef void (VKAPI_PTR *PFN_vkDestroyShaderEXT)(VkDevice device, VkShaderEXT shader, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetShaderBinaryDataEXT)(VkDevice device, VkShaderEXT shader, size_t* pDataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdBindShadersEXT)(VkCommandBuffer commandBuffer, uint32_t stageCount, const VkShaderStageFlagBits* pStages, const VkShaderEXT* pShaders); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateShadersEXT( + VkDevice device, + uint32_t createInfoCount, + const VkShaderCreateInfoEXT* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkShaderEXT* pShaders); + +VKAPI_ATTR void VKAPI_CALL vkDestroyShaderEXT( + VkDevice device, + VkShaderEXT shader, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderBinaryDataEXT( + VkDevice device, + VkShaderEXT shader, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindShadersEXT( + VkCommandBuffer commandBuffer, + uint32_t stageCount, + const VkShaderStageFlagBits* pStages, + const VkShaderEXT* pShaders); +#endif + + +// VK_QCOM_tile_properties is a preprocessor guard. Do not pass it to API calls. #define VK_QCOM_tile_properties 1 #define VK_QCOM_TILE_PROPERTIES_SPEC_VERSION 1 #define VK_QCOM_TILE_PROPERTIES_EXTENSION_NAME "VK_QCOM_tile_properties" @@ -14574,6 +18393,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetDynamicRenderingTilePropertiesQCOM( #endif +// VK_SEC_amigo_profiling is a preprocessor guard. Do not pass it to API calls. #define VK_SEC_amigo_profiling 1 #define VK_SEC_AMIGO_PROFILING_SPEC_VERSION 1 #define VK_SEC_AMIGO_PROFILING_EXTENSION_NAME "VK_SEC_amigo_profiling" @@ -14592,8 +18412,454 @@ typedef struct VkAmigoProfilingSubmitInfoSEC { +// VK_QCOM_multiview_per_view_viewports is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_multiview_per_view_viewports 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_EXTENSION_NAME "VK_QCOM_multiview_per_view_viewports" +typedef struct VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewViewports; +} VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM; + + + +// VK_NV_ray_tracing_invocation_reorder is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing_invocation_reorder 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_SPEC_VERSION 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME "VK_NV_ray_tracing_invocation_reorder" + +typedef enum VkRayTracingInvocationReorderModeNV { + VK_RAY_TRACING_INVOCATION_REORDER_MODE_NONE_NV = 0, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_NV = 1, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkRayTracingInvocationReorderModeNV; +typedef struct VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV { + VkStructureType sType; + void* pNext; + VkRayTracingInvocationReorderModeNV rayTracingInvocationReorderReorderingHint; +} VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV; + +typedef struct VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingInvocationReorder; +} VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV; + + + +// VK_NV_extended_sparse_address_space is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_extended_sparse_address_space 1 +#define VK_NV_EXTENDED_SPARSE_ADDRESS_SPACE_SPEC_VERSION 1 +#define VK_NV_EXTENDED_SPARSE_ADDRESS_SPACE_EXTENSION_NAME "VK_NV_extended_sparse_address_space" +typedef struct VkPhysicalDeviceExtendedSparseAddressSpaceFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 extendedSparseAddressSpace; +} VkPhysicalDeviceExtendedSparseAddressSpaceFeaturesNV; + +typedef struct VkPhysicalDeviceExtendedSparseAddressSpacePropertiesNV { + VkStructureType sType; + void* pNext; + VkDeviceSize extendedSparseAddressSpaceSize; + VkImageUsageFlags extendedSparseImageUsageFlags; + VkBufferUsageFlags extendedSparseBufferUsageFlags; +} VkPhysicalDeviceExtendedSparseAddressSpacePropertiesNV; + + + +// VK_EXT_mutable_descriptor_type is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_mutable_descriptor_type 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_EXT_mutable_descriptor_type" + + +// VK_EXT_layer_settings is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_layer_settings 1 +#define VK_EXT_LAYER_SETTINGS_SPEC_VERSION 2 +#define VK_EXT_LAYER_SETTINGS_EXTENSION_NAME "VK_EXT_layer_settings" + +typedef enum VkLayerSettingTypeEXT { + VK_LAYER_SETTING_TYPE_BOOL32_EXT = 0, + VK_LAYER_SETTING_TYPE_INT32_EXT = 1, + VK_LAYER_SETTING_TYPE_INT64_EXT = 2, + VK_LAYER_SETTING_TYPE_UINT32_EXT = 3, + VK_LAYER_SETTING_TYPE_UINT64_EXT = 4, + VK_LAYER_SETTING_TYPE_FLOAT32_EXT = 5, + VK_LAYER_SETTING_TYPE_FLOAT64_EXT = 6, + VK_LAYER_SETTING_TYPE_STRING_EXT = 7, + VK_LAYER_SETTING_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkLayerSettingTypeEXT; +typedef struct VkLayerSettingEXT { + const char* pLayerName; + const char* pSettingName; + VkLayerSettingTypeEXT type; + uint32_t valueCount; + const void* pValues; +} VkLayerSettingEXT; + +typedef struct VkLayerSettingsCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t settingCount; + const VkLayerSettingEXT* pSettings; +} VkLayerSettingsCreateInfoEXT; + + + +// VK_ARM_shader_core_builtins is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_shader_core_builtins 1 +#define VK_ARM_SHADER_CORE_BUILTINS_SPEC_VERSION 2 +#define VK_ARM_SHADER_CORE_BUILTINS_EXTENSION_NAME "VK_ARM_shader_core_builtins" +typedef struct VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 shaderCoreBuiltins; +} VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM; + +typedef struct VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM { + VkStructureType sType; + void* pNext; + uint64_t shaderCoreMask; + uint32_t shaderCoreCount; + uint32_t shaderWarpsPerCore; +} VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM; + + + +// VK_EXT_pipeline_library_group_handles is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_library_group_handles 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_EXTENSION_NAME "VK_EXT_pipeline_library_group_handles" +typedef struct VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineLibraryGroupHandles; +} VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT; + + + +// VK_EXT_dynamic_rendering_unused_attachments is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_dynamic_rendering_unused_attachments 1 +#define VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_SPEC_VERSION 1 +#define VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_EXTENSION_NAME "VK_EXT_dynamic_rendering_unused_attachments" +typedef struct VkPhysicalDeviceDynamicRenderingUnusedAttachmentsFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 dynamicRenderingUnusedAttachments; +} VkPhysicalDeviceDynamicRenderingUnusedAttachmentsFeaturesEXT; + + + +// VK_NV_low_latency2 is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_low_latency2 1 +#define VK_NV_LOW_LATENCY_2_SPEC_VERSION 2 +#define VK_NV_LOW_LATENCY_2_EXTENSION_NAME "VK_NV_low_latency2" + +typedef enum VkLatencyMarkerNV { + VK_LATENCY_MARKER_SIMULATION_START_NV = 0, + VK_LATENCY_MARKER_SIMULATION_END_NV = 1, + VK_LATENCY_MARKER_RENDERSUBMIT_START_NV = 2, + VK_LATENCY_MARKER_RENDERSUBMIT_END_NV = 3, + VK_LATENCY_MARKER_PRESENT_START_NV = 4, + VK_LATENCY_MARKER_PRESENT_END_NV = 5, + VK_LATENCY_MARKER_INPUT_SAMPLE_NV = 6, + VK_LATENCY_MARKER_TRIGGER_FLASH_NV = 7, + VK_LATENCY_MARKER_OUT_OF_BAND_RENDERSUBMIT_START_NV = 8, + VK_LATENCY_MARKER_OUT_OF_BAND_RENDERSUBMIT_END_NV = 9, + VK_LATENCY_MARKER_OUT_OF_BAND_PRESENT_START_NV = 10, + VK_LATENCY_MARKER_OUT_OF_BAND_PRESENT_END_NV = 11, + VK_LATENCY_MARKER_MAX_ENUM_NV = 0x7FFFFFFF +} VkLatencyMarkerNV; + +typedef enum VkOutOfBandQueueTypeNV { + VK_OUT_OF_BAND_QUEUE_TYPE_RENDER_NV = 0, + VK_OUT_OF_BAND_QUEUE_TYPE_PRESENT_NV = 1, + VK_OUT_OF_BAND_QUEUE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkOutOfBandQueueTypeNV; +typedef struct VkLatencySleepModeInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 lowLatencyMode; + VkBool32 lowLatencyBoost; + uint32_t minimumIntervalUs; +} VkLatencySleepModeInfoNV; + +typedef struct VkLatencySleepInfoNV { + VkStructureType sType; + const void* pNext; + VkSemaphore signalSemaphore; + uint64_t value; +} VkLatencySleepInfoNV; + +typedef struct VkSetLatencyMarkerInfoNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; + VkLatencyMarkerNV marker; +} VkSetLatencyMarkerInfoNV; + +typedef struct VkLatencyTimingsFrameReportNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; + uint64_t inputSampleTimeUs; + uint64_t simStartTimeUs; + uint64_t simEndTimeUs; + uint64_t renderSubmitStartTimeUs; + uint64_t renderSubmitEndTimeUs; + uint64_t presentStartTimeUs; + uint64_t presentEndTimeUs; + uint64_t driverStartTimeUs; + uint64_t driverEndTimeUs; + uint64_t osRenderQueueStartTimeUs; + uint64_t osRenderQueueEndTimeUs; + uint64_t gpuRenderStartTimeUs; + uint64_t gpuRenderEndTimeUs; +} VkLatencyTimingsFrameReportNV; + +typedef struct VkGetLatencyMarkerInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t timingCount; + VkLatencyTimingsFrameReportNV* pTimings; +} VkGetLatencyMarkerInfoNV; + +typedef struct VkLatencySubmissionPresentIdNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; +} VkLatencySubmissionPresentIdNV; + +typedef struct VkSwapchainLatencyCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 latencyModeEnable; +} VkSwapchainLatencyCreateInfoNV; + +typedef struct VkOutOfBandQueueTypeInfoNV { + VkStructureType sType; + const void* pNext; + VkOutOfBandQueueTypeNV queueType; +} VkOutOfBandQueueTypeInfoNV; + +typedef struct VkLatencySurfaceCapabilitiesNV { + VkStructureType sType; + const void* pNext; + uint32_t presentModeCount; + VkPresentModeKHR* pPresentModes; +} VkLatencySurfaceCapabilitiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkSetLatencySleepModeNV)(VkDevice device, VkSwapchainKHR swapchain, const VkLatencySleepModeInfoNV* pSleepModeInfo); +typedef VkResult (VKAPI_PTR *PFN_vkLatencySleepNV)(VkDevice device, VkSwapchainKHR swapchain, const VkLatencySleepInfoNV* pSleepInfo); +typedef void (VKAPI_PTR *PFN_vkSetLatencyMarkerNV)(VkDevice device, VkSwapchainKHR swapchain, const VkSetLatencyMarkerInfoNV* pLatencyMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkGetLatencyTimingsNV)(VkDevice device, VkSwapchainKHR swapchain, VkGetLatencyMarkerInfoNV* pLatencyMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkQueueNotifyOutOfBandNV)(VkQueue queue, const VkOutOfBandQueueTypeInfoNV* pQueueTypeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkSetLatencySleepModeNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkLatencySleepModeInfoNV* pSleepModeInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkLatencySleepNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkLatencySleepInfoNV* pSleepInfo); + +VKAPI_ATTR void VKAPI_CALL vkSetLatencyMarkerNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkSetLatencyMarkerInfoNV* pLatencyMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkGetLatencyTimingsNV( + VkDevice device, + VkSwapchainKHR swapchain, + VkGetLatencyMarkerInfoNV* pLatencyMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueNotifyOutOfBandNV( + VkQueue queue, + const VkOutOfBandQueueTypeInfoNV* pQueueTypeInfo); +#endif + + +// VK_QCOM_multiview_per_view_render_areas is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_multiview_per_view_render_areas 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_EXTENSION_NAME "VK_QCOM_multiview_per_view_render_areas" +typedef struct VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewRenderAreas; +} VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM; + +typedef struct VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM { + VkStructureType sType; + const void* pNext; + uint32_t perViewRenderAreaCount; + const VkRect2D* pPerViewRenderAreas; +} VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM; + + + +// VK_NV_per_stage_descriptor_set is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_per_stage_descriptor_set 1 +#define VK_NV_PER_STAGE_DESCRIPTOR_SET_SPEC_VERSION 1 +#define VK_NV_PER_STAGE_DESCRIPTOR_SET_EXTENSION_NAME "VK_NV_per_stage_descriptor_set" +typedef struct VkPhysicalDevicePerStageDescriptorSetFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 perStageDescriptorSet; + VkBool32 dynamicPipelineLayout; +} VkPhysicalDevicePerStageDescriptorSetFeaturesNV; + + + +// VK_QCOM_image_processing2 is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_image_processing2 1 +#define VK_QCOM_IMAGE_PROCESSING_2_SPEC_VERSION 1 +#define VK_QCOM_IMAGE_PROCESSING_2_EXTENSION_NAME "VK_QCOM_image_processing2" + +typedef enum VkBlockMatchWindowCompareModeQCOM { + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MIN_QCOM = 0, + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MAX_QCOM = 1, + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MAX_ENUM_QCOM = 0x7FFFFFFF +} VkBlockMatchWindowCompareModeQCOM; +typedef struct VkPhysicalDeviceImageProcessing2FeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 textureBlockMatch2; +} VkPhysicalDeviceImageProcessing2FeaturesQCOM; + +typedef struct VkPhysicalDeviceImageProcessing2PropertiesQCOM { + VkStructureType sType; + void* pNext; + VkExtent2D maxBlockMatchWindow; +} VkPhysicalDeviceImageProcessing2PropertiesQCOM; + +typedef struct VkSamplerBlockMatchWindowCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkExtent2D windowExtent; + VkBlockMatchWindowCompareModeQCOM windowCompareMode; +} VkSamplerBlockMatchWindowCreateInfoQCOM; + + + +// VK_QCOM_filter_cubic_weights is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_filter_cubic_weights 1 +#define VK_QCOM_FILTER_CUBIC_WEIGHTS_SPEC_VERSION 1 +#define VK_QCOM_FILTER_CUBIC_WEIGHTS_EXTENSION_NAME "VK_QCOM_filter_cubic_weights" + +typedef enum VkCubicFilterWeightsQCOM { + VK_CUBIC_FILTER_WEIGHTS_CATMULL_ROM_QCOM = 0, + VK_CUBIC_FILTER_WEIGHTS_ZERO_TANGENT_CARDINAL_QCOM = 1, + VK_CUBIC_FILTER_WEIGHTS_B_SPLINE_QCOM = 2, + VK_CUBIC_FILTER_WEIGHTS_MITCHELL_NETRAVALI_QCOM = 3, + VK_CUBIC_FILTER_WEIGHTS_MAX_ENUM_QCOM = 0x7FFFFFFF +} VkCubicFilterWeightsQCOM; +typedef struct VkPhysicalDeviceCubicWeightsFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 selectableCubicWeights; +} VkPhysicalDeviceCubicWeightsFeaturesQCOM; + +typedef struct VkSamplerCubicWeightsCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkCubicFilterWeightsQCOM cubicWeights; +} VkSamplerCubicWeightsCreateInfoQCOM; + +typedef struct VkBlitImageCubicWeightsInfoQCOM { + VkStructureType sType; + const void* pNext; + VkCubicFilterWeightsQCOM cubicWeights; +} VkBlitImageCubicWeightsInfoQCOM; + + + +// VK_QCOM_ycbcr_degamma is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_ycbcr_degamma 1 +#define VK_QCOM_YCBCR_DEGAMMA_SPEC_VERSION 1 +#define VK_QCOM_YCBCR_DEGAMMA_EXTENSION_NAME "VK_QCOM_ycbcr_degamma" +typedef struct VkPhysicalDeviceYcbcrDegammaFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 ycbcrDegamma; +} VkPhysicalDeviceYcbcrDegammaFeaturesQCOM; + +typedef struct VkSamplerYcbcrConversionYcbcrDegammaCreateInfoQCOM { + VkStructureType sType; + void* pNext; + VkBool32 enableYDegamma; + VkBool32 enableCbCrDegamma; +} VkSamplerYcbcrConversionYcbcrDegammaCreateInfoQCOM; + + + +// VK_QCOM_filter_cubic_clamp is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_filter_cubic_clamp 1 +#define VK_QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION 1 +#define VK_QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME "VK_QCOM_filter_cubic_clamp" +typedef struct VkPhysicalDeviceCubicClampFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 cubicRangeClamp; +} VkPhysicalDeviceCubicClampFeaturesQCOM; + + + +// VK_EXT_attachment_feedback_loop_dynamic_state is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_attachment_feedback_loop_dynamic_state 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_SPEC_VERSION 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_dynamic_state" +typedef struct VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 attachmentFeedbackLoopDynamicState; +} VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT)(VkCommandBuffer commandBuffer, VkImageAspectFlags aspectMask); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetAttachmentFeedbackLoopEnableEXT( + VkCommandBuffer commandBuffer, + VkImageAspectFlags aspectMask); +#endif + + +// VK_MSFT_layered_driver is a preprocessor guard. Do not pass it to API calls. +#define VK_MSFT_layered_driver 1 +#define VK_MSFT_LAYERED_DRIVER_SPEC_VERSION 1 +#define VK_MSFT_LAYERED_DRIVER_EXTENSION_NAME "VK_MSFT_layered_driver" + +typedef enum VkLayeredDriverUnderlyingApiMSFT { + VK_LAYERED_DRIVER_UNDERLYING_API_NONE_MSFT = 0, + VK_LAYERED_DRIVER_UNDERLYING_API_D3D12_MSFT = 1, + VK_LAYERED_DRIVER_UNDERLYING_API_MAX_ENUM_MSFT = 0x7FFFFFFF +} VkLayeredDriverUnderlyingApiMSFT; +typedef struct VkPhysicalDeviceLayeredDriverPropertiesMSFT { + VkStructureType sType; + void* pNext; + VkLayeredDriverUnderlyingApiMSFT underlyingAPI; +} VkPhysicalDeviceLayeredDriverPropertiesMSFT; + + + +// VK_NV_descriptor_pool_overallocation is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_descriptor_pool_overallocation 1 +#define VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_SPEC_VERSION 1 +#define VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME "VK_NV_descriptor_pool_overallocation" +typedef struct VkPhysicalDeviceDescriptorPoolOverallocationFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 descriptorPoolOverallocation; +} VkPhysicalDeviceDescriptorPoolOverallocationFeaturesNV; + + + +// VK_KHR_acceleration_structure is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_acceleration_structure 1 -VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureKHR) #define VK_KHR_ACCELERATION_STRUCTURE_SPEC_VERSION 13 #define VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME "VK_KHR_acceleration_structure" @@ -14603,30 +18869,13 @@ typedef enum VkBuildAccelerationStructureModeKHR { VK_BUILD_ACCELERATION_STRUCTURE_MODE_MAX_ENUM_KHR = 0x7FFFFFFF } VkBuildAccelerationStructureModeKHR; -typedef enum VkAccelerationStructureBuildTypeKHR { - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2, - VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF -} VkAccelerationStructureBuildTypeKHR; - -typedef enum VkAccelerationStructureCompatibilityKHR { - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR = 0, - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR = 1, - VK_ACCELERATION_STRUCTURE_COMPATIBILITY_MAX_ENUM_KHR = 0x7FFFFFFF -} VkAccelerationStructureCompatibilityKHR; - typedef enum VkAccelerationStructureCreateFlagBitsKHR { VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = 0x00000001, + VK_ACCELERATION_STRUCTURE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, VK_ACCELERATION_STRUCTURE_CREATE_MOTION_BIT_NV = 0x00000004, VK_ACCELERATION_STRUCTURE_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF } VkAccelerationStructureCreateFlagBitsKHR; typedef VkFlags VkAccelerationStructureCreateFlagsKHR; -typedef union VkDeviceOrHostAddressKHR { - VkDeviceAddress deviceAddress; - void* hostAddress; -} VkDeviceOrHostAddressKHR; - typedef struct VkAccelerationStructureBuildRangeInfoKHR { uint32_t primitiveCount; uint32_t primitiveOffset; @@ -14885,6 +19134,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureBuildSizesKHR( #endif +// VK_KHR_ray_tracing_pipeline is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_ray_tracing_pipeline 1 #define VK_KHR_RAY_TRACING_PIPELINE_SPEC_VERSION 1 #define VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME "VK_KHR_ray_tracing_pipeline" @@ -15021,6 +19271,7 @@ VKAPI_ATTR void VKAPI_CALL vkCmdSetRayTracingPipelineStackSizeKHR( #endif +// VK_KHR_ray_query is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_ray_query 1 #define VK_KHR_RAY_QUERY_SPEC_VERSION 1 #define VK_KHR_RAY_QUERY_EXTENSION_NAME "VK_KHR_ray_query" @@ -15032,6 +19283,7 @@ typedef struct VkPhysicalDeviceRayQueryFeaturesKHR { +// VK_EXT_mesh_shader is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_mesh_shader 1 #define VK_EXT_MESH_SHADER_SPEC_VERSION 1 #define VK_EXT_MESH_SHADER_EXTENSION_NAME "VK_EXT_mesh_shader" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_directfb.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_directfb.h index ab3504efaf..f06f80b70e 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_directfb.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_directfb.h @@ -2,7 +2,7 @@ #define VULKAN_DIRECTFB_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_EXT_directfb_surface is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_directfb_surface 1 #define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1 #define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_fuchsia.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_fuchsia.h index 61774ff9cb..f60907d10b 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_fuchsia.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_fuchsia.h @@ -2,7 +2,7 @@ #define VULKAN_FUCHSIA_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_FUCHSIA_imagepipe_surface is a preprocessor guard. Do not pass it to API calls. #define VK_FUCHSIA_imagepipe_surface 1 #define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1 #define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface" @@ -41,6 +42,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA( #endif +// VK_FUCHSIA_external_memory is a preprocessor guard. Do not pass it to API calls. #define VK_FUCHSIA_external_memory 1 #define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1 #define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory" @@ -81,6 +83,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA( #endif +// VK_FUCHSIA_external_semaphore is a preprocessor guard. Do not pass it to API calls. #define VK_FUCHSIA_external_semaphore 1 #define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 #define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore" @@ -115,6 +118,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA( #endif +// VK_FUCHSIA_buffer_collection is a preprocessor guard. Do not pass it to API calls. #define VK_FUCHSIA_buffer_collection 1 VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA) #define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 2 diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_ggp.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_ggp.h index 19dfd22617..0a8863a14b 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_ggp.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_ggp.h @@ -2,7 +2,7 @@ #define VULKAN_GGP_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_GGP_stream_descriptor_surface is a preprocessor guard. Do not pass it to API calls. #define VK_GGP_stream_descriptor_surface 1 #define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1 #define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface" @@ -41,6 +42,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP( #endif +// VK_GGP_frame_token is a preprocessor guard. Do not pass it to API calls. #define VK_GGP_frame_token 1 #define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1 #define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_ios.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_ios.h index 5792205439..22ed2c039a 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_ios.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_ios.h @@ -2,7 +2,7 @@ #define VULKAN_IOS_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_MVK_ios_surface is a preprocessor guard. Do not pass it to API calls. #define VK_MVK_ios_surface 1 #define VK_MVK_IOS_SURFACE_SPEC_VERSION 3 #define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_macos.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_macos.h index 8e197c7cff..a7f5613a05 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_macos.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_macos.h @@ -2,7 +2,7 @@ #define VULKAN_MACOS_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_MVK_macos_surface is a preprocessor guard. Do not pass it to API calls. #define VK_MVK_macos_surface 1 #define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3 #define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_metal.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_metal.h index 898d3f2985..badb45078a 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_metal.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_metal.h @@ -2,7 +2,7 @@ #define VULKAN_METAL_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_EXT_metal_surface is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_metal_surface 1 #ifdef __OBJC__ @class CAMetalLayer; @@ -55,6 +56,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT( #endif +// VK_EXT_metal_objects is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_metal_objects 1 #ifdef __OBJC__ @protocol MTLDevice; diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_screen.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_screen.h index f0ef40a6ca..7e84d4d965 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_screen.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_screen.h @@ -2,7 +2,7 @@ #define VULKAN_SCREEN_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_QNX_screen_surface is a preprocessor guard. Do not pass it to API calls. #define VK_QNX_screen_surface 1 #define VK_QNX_SCREEN_SURFACE_SPEC_VERSION 1 #define VK_QNX_SCREEN_SURFACE_EXTENSION_NAME "VK_QNX_screen_surface" @@ -47,6 +48,59 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceScreenPresentationSupportQNX( struct _screen_window* window); #endif + +// VK_QNX_external_memory_screen_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_QNX_external_memory_screen_buffer 1 +#define VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_SPEC_VERSION 1 +#define VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_EXTENSION_NAME "VK_QNX_external_memory_screen_buffer" +typedef struct VkScreenBufferPropertiesQNX { + VkStructureType sType; + void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeBits; +} VkScreenBufferPropertiesQNX; + +typedef struct VkScreenBufferFormatPropertiesQNX { + VkStructureType sType; + void* pNext; + VkFormat format; + uint64_t externalFormat; + uint64_t screenUsage; + VkFormatFeatureFlags formatFeatures; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkScreenBufferFormatPropertiesQNX; + +typedef struct VkImportScreenBufferInfoQNX { + VkStructureType sType; + const void* pNext; + struct _screen_buffer* buffer; +} VkImportScreenBufferInfoQNX; + +typedef struct VkExternalFormatQNX { + VkStructureType sType; + void* pNext; + uint64_t externalFormat; +} VkExternalFormatQNX; + +typedef struct VkPhysicalDeviceExternalMemoryScreenBufferFeaturesQNX { + VkStructureType sType; + void* pNext; + VkBool32 screenBufferImport; +} VkPhysicalDeviceExternalMemoryScreenBufferFeaturesQNX; + +typedef VkResult (VKAPI_PTR *PFN_vkGetScreenBufferPropertiesQNX)(VkDevice device, const struct _screen_buffer* buffer, VkScreenBufferPropertiesQNX* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetScreenBufferPropertiesQNX( + VkDevice device, + const struct _screen_buffer* buffer, + VkScreenBufferPropertiesQNX* pProperties); +#endif + #ifdef __cplusplus } #endif diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_vi.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_vi.h index 0355e7a162..c145f4a800 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_vi.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_vi.h @@ -2,7 +2,7 @@ #define VULKAN_VI_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_NN_vi_surface is a preprocessor guard. Do not pass it to API calls. #define VK_NN_vi_surface 1 #define VK_NN_VI_SURFACE_SPEC_VERSION 1 #define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_wayland.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_wayland.h index 9afd0b76d5..ec706a114b 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_wayland.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_wayland.h @@ -2,7 +2,7 @@ #define VULKAN_WAYLAND_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_KHR_wayland_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_wayland_surface 1 #define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 #define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_win32.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_win32.h index affe0c02ae..d7a0b2bab4 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_win32.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_win32.h @@ -2,7 +2,7 @@ #define VULKAN_WIN32_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_KHR_win32_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_win32_surface 1 #define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6 #define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" @@ -47,6 +48,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( #endif +// VK_KHR_external_memory_win32 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_memory_win32 1 #define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32" @@ -96,6 +98,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( #endif +// VK_KHR_win32_keyed_mutex is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_win32_keyed_mutex 1 #define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1 #define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex" @@ -113,6 +116,7 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR { +// VK_KHR_external_semaphore_win32 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_semaphore_win32 1 #define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32" @@ -165,6 +169,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( #endif +// VK_KHR_external_fence_win32 is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_external_fence_win32 1 #define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1 #define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32" @@ -208,6 +213,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( #endif +// VK_NV_external_memory_win32 is a preprocessor guard. Do not pass it to API calls. #define VK_NV_external_memory_win32 1 #define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 #define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" @@ -236,6 +242,7 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( #endif +// VK_NV_win32_keyed_mutex is a preprocessor guard. Do not pass it to API calls. #define VK_NV_win32_keyed_mutex 1 #define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2 #define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" @@ -253,6 +260,7 @@ typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { +// VK_EXT_full_screen_exclusive is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_full_screen_exclusive 1 #define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4 #define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive" @@ -308,6 +316,25 @@ VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT( VkDeviceGroupPresentModeFlagsKHR* pModes); #endif + +// VK_NV_acquire_winrt_display is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_acquire_winrt_display 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + uint32_t deviceRelativeId, + VkDisplayKHR* pDisplay); +#endif + #ifdef __cplusplus } #endif diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_xcb.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_xcb.h index 68e61b88f0..cdf6b5269f 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_xcb.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_xcb.h @@ -2,7 +2,7 @@ #define VULKAN_XCB_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_KHR_xcb_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_xcb_surface 1 #define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 #define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib.h index ea5360ab64..b3c3e27d77 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib.h @@ -2,7 +2,7 @@ #define VULKAN_XLIB_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_KHR_xlib_surface is a preprocessor guard. Do not pass it to API calls. #define VK_KHR_xlib_surface 1 #define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 #define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" diff --git a/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib_xrandr.h b/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib_xrandr.h index 8fc35cfc56..8e99190b4f 100644 --- a/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib_xrandr.h +++ b/vs/sdl2/src/video/khronos/vulkan/vulkan_xlib_xrandr.h @@ -2,7 +2,7 @@ #define VULKAN_XLIB_XRANDR_H_ 1 /* -** Copyright 2015-2022 The Khronos Group Inc. +** Copyright 2015-2024 The Khronos Group Inc. ** ** SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,7 @@ extern "C" { +// VK_EXT_acquire_xlib_display is a preprocessor guard. Do not pass it to API calls. #define VK_EXT_acquire_xlib_display 1 #define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 #define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.c index 15c0f0d390..750babbcde 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM #define DEBUG_DYNAMIC_KMSDRM 0 @@ -52,22 +52,22 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { fn = SDL_LoadFunction(kmsdrmlibs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_KMSDRM - if (fn != NULL) + if (fn) SDL_Log("KMSDRM: Found '%s' in %s (%p)\n", fnname, kmsdrmlibs[i].libname, fn); else SDL_Log("KMSDRM: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -101,7 +101,7 @@ void SDL_KMSDRM_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { SDL_UnloadObject(kmsdrmlibs[i].lib); kmsdrmlibs[i].lib = NULL; } @@ -122,7 +122,7 @@ int SDL_KMSDRM_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].libname != NULL) { + if (kmsdrmlibs[i].libname) { kmsdrmlibs[i].lib = SDL_LoadObject(kmsdrmlibs[i].libname); } } diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.h index 319e3f0e3d..e6da337921 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmdyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.c index 8a97c8798a..a52f1b6b16 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmevents.h" diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.h index 59226dd47a..74625e34fa 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,5 @@ #define SDL_kmsdrmevents_h_ extern void KMSDRM_PumpEvents(_THIS); -extern void KMSDRM_EventInit(_THIS); -extern void KMSDRM_EventQuit(_THIS); #endif /* SDL_kmsdrmevents_h_ */ diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.c index 955045a7e2..ec01004efc 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmmouse.h" @@ -152,7 +152,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) int i; int ret; - if (curdata == NULL || !dispdata->cursor_bo) { + if (!curdata || !dispdata->cursor_bo) { return SDL_SetError("Cursor or display not initialized properly."); } @@ -163,7 +163,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) ready_buffer = (uint8_t *)SDL_calloc(1, bufsize); - if (ready_buffer == NULL) { + if (!ready_buffer) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -241,12 +241,12 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = NULL; cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); goto cleanup; } curdata = (KMSDRM_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); goto cleanup; } @@ -282,7 +282,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = cursor; cleanup: - if (ret == NULL) { + if (!ret) { if (curdata) { if (curdata->buffer) { SDL_free(curdata->buffer); @@ -310,13 +310,13 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) /* Get the mouse focused window, if any. */ mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return SDL_SetError("No mouse."); } window = mouse->focus; - if (window == NULL || cursor == NULL) { + if (!window || !cursor) { /* If no window is focused by mouse or cursor is NULL, since we have no window (no mouse->focus) and hence diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.h index bcd89f2aca..0485abfb3e 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.c index 8dc2bfdc64..9b34d68961 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +21,10 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM #include "SDL_log.h" +#include "SDL_timer.h" #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmopengles.h" @@ -40,7 +41,7 @@ void KMSDRM_GLES_DefaultProfileConfig(_THIS, int *mask, int *major, int *minor) { /* if SDL was _also_ built with the Raspberry Pi driver (so we're definitely a Pi device), default to GLES2. */ -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI *mask = SDL_GL_CONTEXT_PROFILE_ES; *major = 2; *minor = 0; @@ -97,6 +98,13 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) even if you do async flips. */ uint32_t flip_flags = DRM_MODE_PAGE_FLIP_EVENT; + /* Skip the swap if we've switched away to another VT */ + if (windata->egl_surface == EGL_NO_SURFACE) { + /* Wait a bit, throttling to ~100 FPS */ + SDL_Delay(10); + return 0; + } + /* Recreate the GBM / EGL surfaces if the display mode has changed */ if (windata->egl_surface_dirty) { KMSDRM_CreateSurfaces(_this, window); @@ -117,7 +125,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) windata->bo = windata->next_bo; - /* Mark a buffer to becume the next front buffer. + /* Mark a buffer to become the next front buffer. This won't happen until pagelip completes. */ if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, windata->egl_surface))) { @@ -136,7 +144,7 @@ int KMSDRM_GLES_SwapWindow(_THIS, SDL_Window *window) /* Get an actual usable fb for the next front buffer. */ fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); - if (fb_info == NULL) { + if (!fb_info) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); return 0; } diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.h index 0f1ef8740a..63e548a335 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_kmsdrmopengles_h_ #define SDL_kmsdrmopengles_h_ -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmsym.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmsym.h index 8b9e7b2578..d1e856f4b7 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmsym.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +42,7 @@ 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,drmSetMaster,(int fd)) +SDL_KMSDRM_SYM(int,drmDropMaster,(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, @@ -62,7 +63,7 @@ SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId, 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)) + const uint16_t *red, const uint16_t *green, const 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, diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.c index ebe15fe9c0..bdcd2207ad 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_KMSDRM +#ifdef SDL_VIDEO_DRIVER_KMSDRM /* SDL internals */ #include "../SDL_sysvideo.h" @@ -77,6 +77,7 @@ static int get_driindex(void) int devindex = -1; DIR *folder; const char *hint; + struct dirent *res; hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX); if (hint && *hint) { @@ -89,14 +90,14 @@ static int get_driindex(void) SDL_strlcpy(device, kmsdrm_dri_path, sizeof(device)); folder = opendir(device); - if (folder == NULL) { + if (!folder) { SDL_SetError("Failed to open directory '%s'", device); return -ENOENT; } SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname, sizeof(device) - kmsdrm_dri_devnamesize); - for (struct dirent *res; (res = readdir(folder));) { + while((res = readdir(folder)) != NULL) { if (SDL_memcmp(res->d_name, kmsdrm_dri_devname, kmsdrm_dri_devnamesize) == 0) { SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize, @@ -127,7 +128,7 @@ static int get_driindex(void) KMSDRM_drmModeGetConnector( drm_fd, resources->connectors[i]); - if (conn == NULL) { + if (!conn) { continue; } @@ -241,13 +242,13 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) } device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } viddata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (viddata == NULL) { + if (!viddata) { SDL_OutOfMemory(); goto cleanup; } @@ -290,7 +291,7 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) device->GL_DeleteContext = KMSDRM_GLES_DeleteContext; device->GL_DefaultProfileConfig = KMSDRM_GLES_DefaultProfileConfig; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = KMSDRM_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = KMSDRM_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = KMSDRM_Vulkan_GetInstanceExtensions; @@ -315,7 +316,8 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) VideoBootStrap KMSDRM_bootstrap = { "KMSDRM", "KMS/DRM Video Driver", - KMSDRM_CreateDevice + KMSDRM_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) @@ -348,7 +350,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(_THIS, struct gbm_bo *bo) when the backing buffer is destroyed */ fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); - if (fb_info == NULL) { + if (!fb_info) { SDL_OutOfMemory(); return NULL; } @@ -677,7 +679,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re /* Reserve memory for the new display's driverdata. */ dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (dispdata == NULL) { + if (!dispdata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -698,7 +700,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -710,13 +712,13 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re encoder = NULL; } - if (encoder == NULL) { + 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]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -735,7 +737,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re } } - if (encoder == NULL) { + if (!encoder) { ret = SDL_SetError("No connected encoder found for connector."); goto cleanup; } @@ -745,7 +747,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re /* If no CRTC was connected to the encoder, find the first CRTC that is supported by the encoder, and use that. */ - if (crtc == NULL) { + if (!crtc) { for (i = 0; i < resources->count_crtcs; i++) { if (encoder->possible_crtcs & (1 << i)) { encoder->crtc_id = resources->crtcs[i]; @@ -755,7 +757,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re } } - if (crtc == NULL) { + if (!crtc) { ret = SDL_SetError("No CRTC found for connector."); goto cleanup; } @@ -840,7 +842,7 @@ static void KMSDRM_AddDisplay(_THIS, drmModeConnector *connector, drmModeRes *re There's no problem with it being still incomplete. */ modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -910,7 +912,7 @@ static int KMSDRM_InitDisplays(_THIS) /* Get all of the available connectors / devices / crtcs */ resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - if (resources == NULL) { + if (!resources) { ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); goto cleanup; } @@ -921,7 +923,7 @@ static int KMSDRM_InitDisplays(_THIS) drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]); - if (connector == NULL) { + if (!connector) { continue; } @@ -1206,6 +1208,38 @@ int KMSDRM_CreateSurfaces(_THIS, SDL_Window *window) return ret; } +#ifdef SDL_INPUT_LINUXEV +static void KMSDRM_ReleaseVT(void *userdata) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + SDL_VideoData *viddata = _this->driverdata; + int i; + + for (i = 0; i < viddata->num_windows; i++) { + SDL_Window *window = viddata->windows[i]; + if (!(window->flags & SDL_WINDOW_VULKAN)) { + KMSDRM_DestroySurfaces(_this, window); + } + } + KMSDRM_drmDropMaster(viddata->drm_fd); +} + +static void KMSDRM_AcquireVT(void *userdata) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + SDL_VideoData *viddata = _this->driverdata; + int i; + + KMSDRM_drmSetMaster(viddata->drm_fd); + for (i = 0; i < viddata->num_windows; i++) { + SDL_Window *window = viddata->windows[i]; + if (!(window->flags & SDL_WINDOW_VULKAN)) { + KMSDRM_CreateSurfaces(_this, window); + } + } +} +#endif /* defined SDL_INPUT_LINUXEV */ + int KMSDRM_VideoInit(_THIS) { int ret = 0; @@ -1226,6 +1260,7 @@ int KMSDRM_VideoInit(_THIS) #ifdef SDL_INPUT_LINUXEV SDL_EVDEV_Init(); + SDL_EVDEV_SetVTSwitchCallbacks(KMSDRM_ReleaseVT, _this, KMSDRM_AcquireVT, _this); #elif defined(SDL_INPUT_WSCONS) SDL_WSCONS_Init(); #endif @@ -1244,6 +1279,7 @@ void KMSDRM_VideoQuit(_THIS) KMSDRM_DeinitDisplays(_this); #ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_SetVTSwitchCallbacks(NULL, NULL, NULL, NULL); SDL_EVDEV_Quit(); #elif defined(SDL_INPUT_WSCONS) SDL_WSCONS_Quit(); @@ -1300,7 +1336,7 @@ int KMSDRM_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod return 0; } - if (modedata == NULL) { + if (!modedata) { return SDL_SetError("Mode doesn't have an associated index"); } @@ -1323,7 +1359,7 @@ void KMSDRM_DestroyWindow(_THIS, SDL_Window *window) SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; - if (windata == NULL) { + if (!windata) { return; } @@ -1407,7 +1443,7 @@ int KMSDRM_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (windata == NULL) { + if (!windata) { return SDL_OutOfMemory(); } @@ -1548,7 +1584,7 @@ int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window); SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata; Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16), 256); - if (tempRamp == NULL) + if (!tempRamp) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.h index b48f6ef70f..c9222f81a5 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 567bfc71d9..b5dc7b802f 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_KMSDRM +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_KMSDRM) #include "SDL_kmsdrmvideo.h" #include "SDL_kmsdrmdyn.h" @@ -56,10 +56,10 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } @@ -93,7 +93,7 @@ int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } diff --git a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.h b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.h index 76e865ad0b..01a582aaa1 100644 --- a/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.h +++ b/vs/sdl2/src/video/kmsdrm/SDL_kmsdrmvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_KMSDRM +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_KMSDRM) int KMSDRM_Vulkan_LoadLibrary(_THIS, const char *path); void KMSDRM_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsevents.c b/vs/sdl2/src/video/n3ds/SDL_n3dsevents.c index a5489fbf2c..c45bb80895 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsevents.c +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsevents_c.h b/vs/sdl2/src/video/n3ds/SDL_n3dsevents_c.h index f3b7b39487..2e75951fd9 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsevents_c.h +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer.c b/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer.c index 601e8bc0f9..784c2df44b 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ int SDL_N3DS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, FreePreviousWindowFramebuffer(window); framebuffer = CreateNewWindowFramebuffer(window); - if (framebuffer == NULL) { + if (!framebuffer) { return SDL_OutOfMemory(); } @@ -84,7 +84,7 @@ int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect * u32 bufsize; surface = (SDL_Surface *)SDL_GetWindowData(window, N3DS_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("%s: Unable to get the window surface.", __func__); } diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer_c.h b/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer_c.h index cd690748a9..19a9e95757 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer_c.h +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.c b/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.c index 9170a2ae97..9a35d272b6 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.c +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.h b/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.h index 86f6a096cf..04a355b29b 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.h +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsswkb.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dstouch.c b/vs/sdl2/src/video/n3ds/SDL_n3dstouch.c index 02e3b6f6fd..982c578ac1 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dstouch.c +++ b/vs/sdl2/src/video/n3ds/SDL_n3dstouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dstouch.h b/vs/sdl2/src/video/n3ds/SDL_n3dstouch.h index 4a99d62593..d99e5a3215 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dstouch.h +++ b/vs/sdl2/src/video/n3ds/SDL_n3dstouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.c b/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.c index 1668f9dece..fc875d3ce5 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.c +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +57,7 @@ static void N3DS_DeleteDevice(SDL_VideoDevice *device) static SDL_VideoDevice *N3DS_CreateDevice(void) { SDL_VideoDevice *device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -86,7 +86,7 @@ static SDL_VideoDevice *N3DS_CreateDevice(void) return device; } -VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice }; +VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice, NULL /* no ShowMessageBox implementation */ }; static int N3DS_VideoInit(_THIS) { @@ -108,7 +108,7 @@ AddN3DSDisplay(gfxScreen_t screen) SDL_DisplayMode mode; SDL_VideoDisplay display; DisplayDriverData *display_driver_data = SDL_calloc(1, sizeof(DisplayDriverData)); - if (display_driver_data == NULL) { + if (!display_driver_data) { SDL_OutOfMemory(); return; } @@ -150,7 +150,7 @@ static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { DisplayDriverData *driver_data = (DisplayDriverData *)display->driverdata; - if (driver_data == NULL) { + if (!driver_data) { return -1; } rect->x = 0; @@ -165,7 +165,7 @@ static int N3DS_CreateWindow(_THIS, SDL_Window *window) { DisplayDriverData *display_data; SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (window_data == NULL) { + if (!window_data) { return SDL_OutOfMemory(); } display_data = (DisplayDriverData *)SDL_GetDisplayDriverData(window->display_index); @@ -177,7 +177,7 @@ static int N3DS_CreateWindow(_THIS, SDL_Window *window) static void N3DS_DestroyWindow(_THIS, SDL_Window *window) { - if (window == NULL) { + if (!window) { return; } SDL_free(window->driverdata); diff --git a/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.h b/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.h index 05561b9b90..455eaf425e 100644 --- a/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.h +++ b/vs/sdl2/src/video/n3ds/SDL_n3dsvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/nacl/SDL_naclevents.c b/vs/sdl2/src/video/nacl/SDL_naclevents.c index ce03e525e5..6e7226e1ce 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclevents.c +++ b/vs/sdl2/src/video/nacl/SDL_naclevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL #include "SDL.h" #include "../../events/SDL_events_c.h" diff --git a/vs/sdl2/src/video/nacl/SDL_naclevents_c.h b/vs/sdl2/src/video/nacl/SDL_naclevents_c.h index fbf51fdcc9..4bf777a769 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclevents_c.h +++ b/vs/sdl2/src/video/nacl/SDL_naclevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/nacl/SDL_naclglue.c b/vs/sdl2/src/video/nacl/SDL_naclglue.c index 1146c68834..04b0823ab5 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclglue.c +++ b/vs/sdl2/src/video/nacl/SDL_naclglue.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,5 +20,5 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL #endif /* SDL_VIDEO_DRIVER_NACL */ diff --git a/vs/sdl2/src/video/nacl/SDL_naclopengles.c b/vs/sdl2/src/video/nacl/SDL_naclopengles.c index 5889839f3e..fd121b7114 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclopengles.c +++ b/vs/sdl2/src/video/nacl/SDL_naclopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL /* NaCl SDL video GLES 2 driver implementation */ diff --git a/vs/sdl2/src/video/nacl/SDL_naclopengles.h b/vs/sdl2/src/video/nacl/SDL_naclopengles.h index 62e90b1535..5ae394612a 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclopengles.h +++ b/vs/sdl2/src/video/nacl/SDL_naclopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/nacl/SDL_naclvideo.c b/vs/sdl2/src/video/nacl/SDL_naclvideo.c index ef89038076..53fc679b03 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclvideo.c +++ b/vs/sdl2/src/video/nacl/SDL_naclvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_instance.h" @@ -134,7 +134,8 @@ static SDL_VideoDevice *NACL_CreateDevice(void) { VideoBootStrap NACL_bootstrap = { NACLVID_DRIVER_NAME, "SDL Native Client Video Driver", - NACL_CreateDevice + NACL_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; int NACL_VideoInit(_THIS) { diff --git a/vs/sdl2/src/video/nacl/SDL_naclvideo.h b/vs/sdl2/src/video/nacl/SDL_naclvideo.h index b2a85588ed..504f4d622e 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclvideo.h +++ b/vs/sdl2/src/video/nacl/SDL_naclvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/nacl/SDL_naclwindow.c b/vs/sdl2/src/video/nacl/SDL_naclwindow.c index 3c22220511..200b345f9e 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclwindow.c +++ b/vs/sdl2/src/video/nacl/SDL_naclwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NACL +#ifdef SDL_VIDEO_DRIVER_NACL #include "../SDL_sysvideo.h" diff --git a/vs/sdl2/src/video/nacl/SDL_naclwindow.h b/vs/sdl2/src/video/nacl/SDL_naclwindow.h index 26f09cd3e4..9ac941c470 100644 --- a/vs/sdl2/src/video/nacl/SDL_naclwindow.h +++ b/vs/sdl2/src/video/nacl/SDL_naclwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/ngage/SDL_ngageevents.cpp b/vs/sdl2/src/video/ngage/SDL_ngageevents.cpp index d5b8b3abf6..3ecf164ef4 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngageevents.cpp +++ b/vs/sdl2/src/video/ngage/SDL_ngageevents.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NGAGE +#ifdef SDL_VIDEO_DRIVER_NGAGE /* Being a ngage driver, there's no event stream. We just define stubs for most of the API. */ diff --git a/vs/sdl2/src/video/ngage/SDL_ngageevents_c.h b/vs/sdl2/src/video/ngage/SDL_ngageevents_c.h index 1fa0ba76ce..e0ef5a0317 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngageevents_c.h +++ b/vs/sdl2/src/video/ngage/SDL_ngageevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/ngage/SDL_ngageframebuffer.cpp b/vs/sdl2/src/video/ngage/SDL_ngageframebuffer.cpp index 20b1857dc5..98fb495d4e 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/vs/sdl2/src/video/ngage/SDL_ngageframebuffer.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NGAGE +#ifdef SDL_VIDEO_DRIVER_NGAGE #include @@ -57,7 +57,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -149,7 +149,7 @@ int SDL_NGAGE_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, NGAGE_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find ngage surface for window"); } diff --git a/vs/sdl2/src/video/ngage/SDL_ngageframebuffer_c.h b/vs/sdl2/src/video/ngage/SDL_ngageframebuffer_c.h index adbfff510c..02c50efa3e 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngageframebuffer_c.h +++ b/vs/sdl2/src/video/ngage/SDL_ngageframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/ngage/SDL_ngagevideo.cpp b/vs/sdl2/src/video/ngage/SDL_ngagevideo.cpp index 4b5c692e6a..d18abc8378 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngagevideo.cpp +++ b/vs/sdl2/src/video/ngage/SDL_ngagevideo.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #endif #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NGAGE +#ifdef SDL_VIDEO_DRIVER_NGAGE #ifdef __cplusplus extern "C" { @@ -106,14 +106,14 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal N-Gage specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return 0; @@ -141,7 +141,8 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) VideoBootStrap NGAGE_bootstrap = { NGAGEVID_DRIVER_NAME, "SDL ngage video driver", - NGAGE_CreateDevice + NGAGE_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; int NGAGE_VideoInit(_THIS) diff --git a/vs/sdl2/src/video/ngage/SDL_ngagevideo.h b/vs/sdl2/src/video/ngage/SDL_ngagevideo.h index 3678141170..57386e1025 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngagevideo.h +++ b/vs/sdl2/src/video/ngage/SDL_ngagevideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/ngage/SDL_ngagewindow.cpp b/vs/sdl2/src/video/ngage/SDL_ngagewindow.cpp index 9d598b79f9..37a6be05c1 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngagewindow.cpp +++ b/vs/sdl2/src/video/ngage/SDL_ngagewindow.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_NGAGE +#ifdef SDL_VIDEO_DRIVER_NGAGE #include "../SDL_sysvideo.h" @@ -36,7 +36,7 @@ int NGAGE_CreateWindow(_THIS, SDL_Window *window) { NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window)); - if (ngage_window == NULL) { + if (!ngage_window) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/video/ngage/SDL_ngagewindow.h b/vs/sdl2/src/video/ngage/SDL_ngagewindow.h index 500d8dcd14..933ca8e9ee 100644 --- a/vs/sdl2/src/video/ngage/SDL_ngagewindow.h +++ b/vs/sdl2/src/video/ngage/SDL_ngagewindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenevents.c b/vs/sdl2/src/video/offscreen/SDL_offscreenevents.c index 57e12b473d..d825162b86 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenevents.c +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OFFSCREEN +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN /* Being a offscreen driver, there's no event stream. We just define stubs for most of the API. */ diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenevents_c.h b/vs/sdl2/src/video/offscreen/SDL_offscreenevents_c.h index de1d53093f..ccbef93f28 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenevents_c.h +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer.c b/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer.c index 4e27c72501..2b9337b111 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OFFSCREEN +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN #include "../SDL_sysvideo.h" #include "SDL_offscreenframebuffer_c.h" @@ -39,7 +39,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -58,7 +58,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_R SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, OFFSCREEN_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find offscreen surface for window"); } diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer_c.h b/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer_c.h index abad40f5e1..1151576f3b 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer_c.h +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.c b/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.c index 8185696773..a36cf51887 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.c +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_OFFSCREEN) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_offscreenopengles.h" #include "SDL_offscreenvideo.h" diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.h b/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.h index 12a068afcf..c8c23f1c03 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.h +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef _SDL_offscreenopengles_h #define _SDL_offscreenopengles_h -#if SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_OFFSCREEN) && defined(SDL_VIDEO_OPENGL_EGL) #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.c b/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.c index 2fd86d98fe..2d42374adb 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.c +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OFFSCREEN +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN /* Offscreen video driver is similar to dummy driver, however its purpose * is enabling applications to use some of the SDL video functionality @@ -58,7 +58,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -73,7 +73,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) device->DestroyWindowFramebuffer = SDL_OFFSCREEN_DestroyWindowFramebuffer; device->free = OFFSCREEN_DeleteDevice; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* GL context */ device->GL_SwapWindow = OFFSCREEN_GLES_SwapWindow; device->GL_MakeCurrent = OFFSCREEN_GLES_MakeCurrent; @@ -95,7 +95,8 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) VideoBootStrap OFFSCREEN_bootstrap = { OFFSCREENVID_DRIVER_NAME, "SDL offscreen video driver", - OFFSCREEN_CreateDevice + OFFSCREEN_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; int OFFSCREEN_VideoInit(_THIS) diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.h b/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.h index 7780f4909c..f4e3c8fe8c 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.h +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.c b/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.c index 03a14c390f..58fc2e95eb 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.c +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OFFSCREEN +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" @@ -31,7 +31,7 @@ int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window) { OFFSCREEN_Window *offscreen_window = SDL_calloc(1, sizeof(OFFSCREEN_Window)); - if (offscreen_window == NULL) { + if (!offscreen_window) { return SDL_OutOfMemory(); } @@ -47,7 +47,7 @@ int OFFSCREEN_CreateWindow(_THIS, SDL_Window *window) offscreen_window->sdl_window = window; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { if (!_this->egl_data) { @@ -73,7 +73,7 @@ void OFFSCREEN_DestroyWindow(_THIS, SDL_Window *window) OFFSCREEN_Window *offscreen_window = window->driverdata; if (offscreen_window) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL SDL_EGL_DestroySurface(_this, offscreen_window->egl_surface); #endif SDL_free(offscreen_window); diff --git a/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.h b/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.h index 692f5d5d60..aa189c0869 100644 --- a/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.h +++ b/vs/sdl2/src/video/offscreen/SDL_offscreenwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ typedef struct { SDL_Window *sdl_window; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif diff --git a/vs/sdl2/src/video/os2/SDL_os2dive.c b/vs/sdl2/src/video/os2/SDL_os2dive.c index 1b3eb13ba4..0cb8735320 100644 --- a/vs/sdl2/src/video/os2/SDL_os2dive.c +++ b/vs/sdl2/src/video/os2/SDL_os2dive.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -101,7 +101,7 @@ PVODATA voOpen(void) { PVODATA pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -277,7 +277,7 @@ static VOID voVideoBufFree(PVODATA pVOData) pVOData->ulDIVEBufNum = 0; } - if (pVOData->pBuffer != NULL) { + if (pVOData->pBuffer) { ulRC = DosFreeMem(pVOData->pBuffer); if (ulRC != NO_ERROR) { debug_os2("DosFreeMem(), rc = %u", ulRC); @@ -296,11 +296,11 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, return FALSE; } - if (pSDLRects != NULL) { + if (pSDLRects) { PBYTE pbLineMask; pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight); - if (pbLineMask == NULL) { + if (!pbLineMask) { debug_os2("Not enough stack size"); return FALSE; } diff --git a/vs/sdl2/src/video/os2/SDL_os2messagebox.c b/vs/sdl2/src/video/os2/SDL_os2messagebox.c index 83ac8775e7..e39463575c 100644 --- a/vs/sdl2/src/video/os2/SDL_os2messagebox.c +++ b/vs/sdl2/src/video/os2/SDL_os2messagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 /* Display a OS/2 message box */ @@ -206,9 +206,9 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cSDLBtnData = messageboxdata->numbuttons; PSZ pszTitle = OS2_UTF8ToSys(messageboxdata->title); - ULONG cbTitle = (pszTitle == NULL)? 1 : (SDL_strlen(pszTitle) + 1); + ULONG cbTitle = (!pszTitle)? 1 : (SDL_strlen(pszTitle) + 1); PSZ pszText = OS2_UTF8ToSys(messageboxdata->message); - ULONG cbText = (pszText == NULL)? 1 : (SDL_strlen(pszText) + 1); + ULONG cbText = (!pszText)? 1 : (SDL_strlen(pszText) + 1); PDLGTEMPLATE pTemplate; ULONG cbTemplate; @@ -219,7 +219,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cbBtnText; HWND hwnd; - const SDL_MessageBoxColor* pSDLColors = (messageboxdata->colorScheme == NULL)? + const SDL_MessageBoxColor* pSDLColors = (!messageboxdata->colorScheme)? NULL : messageboxdata->colorScheme->colors; const SDL_MessageBoxColor* pSDLColor; @@ -237,11 +237,11 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Button items datas - text for buttons. */ for (ulIdx = 0; ulIdx < cSDLBtnData; ulIdx++) { pszBtnText = (PSZ)pSDLBtnData[ulIdx].text; - cbTemplate += (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbTemplate += (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); } /* Presentation parameter space. */ - if (pSDLColors != NULL) { + if (pSDLColors) { cbTemplate += 26 /* PP for frame. */ + 26 /* PP for static text. */ + (48 * cSDLBtnData); /* PP for buttons. */ @@ -284,14 +284,14 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) } pcDlgData += pDlgItem->cchText; - pDlgItem->flStyle = WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | + pDlgItem->flStyle = WS_GROUP | WS_VISIBLE | WS_CLIPSIBLINGS | FS_DLGBORDER | WS_SAVEBITS; pDlgItem->x = 100; pDlgItem->y = 100; pDlgItem->cx = 175; pDlgItem->cy = 65; pDlgItem->id = DID_OK; /* An ID value? */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the frame - dialog colors. */ @@ -346,7 +346,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 62; /* It will be used. */ pDlgItem->id = IDD_TEXT_MESSAGE; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the static text - dialog colors. */ @@ -407,7 +407,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->offClassName = (USHORT)WC_BUTTON; pszBtnText = OS2_UTF8ToSys(pSDLBtnData[ulIdx].text); - cbBtnText = (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbBtnText = (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); pDlgItem->cchText = cbBtnText; pDlgItem->offText = pcDlgData - (PCHAR)pTemplate; /* Offset to the text. */ /* Copy text for the button into the dialog template. */ @@ -435,7 +435,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 15; pDlgItem->id = IDD_PB_FIRST + ulIdx; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the button - dialog colors. */ @@ -473,7 +473,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Create the dialog from template. */ stDlgData.cb = sizeof(MSGBOXDLGDATA); - stDlgData.hwndUnder = (messageboxdata->window != NULL && messageboxdata->window->driverdata != NULL)? + stDlgData.hwndUnder = (messageboxdata->window && messageboxdata->window->driverdata)? ((WINDATA *)messageboxdata->window->driverdata)->hwnd : HWND_DESKTOP; hwnd = WinCreateDlg(HWND_DESKTOP, /* Parent is desktop. */ diff --git a/vs/sdl2/src/video/os2/SDL_os2messagebox.h b/vs/sdl2/src/video/os2/SDL_os2messagebox.h index 92b94d98c2..453d035a7f 100644 --- a/vs/sdl2/src/video/os2/SDL_os2messagebox.h +++ b/vs/sdl2/src/video/os2/SDL_os2messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 extern int OS2_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/os2/SDL_os2mouse.c b/vs/sdl2/src/video/os2/SDL_os2mouse.c index 3ffdef917c..220766a4c1 100644 --- a/vs/sdl2/src/video/os2/SDL_os2mouse.c +++ b/vs/sdl2/src/video/os2/SDL_os2mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 #include "SDL_os2video.h" #include "../../events/SDL_mouse_c.h" @@ -46,7 +46,7 @@ static SDL_Cursor* OS2_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return NULL; pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -91,7 +91,7 @@ static SDL_Cursor* OS2_CreateSystemCursor(SDL_SystemCursor id) } pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -111,7 +111,7 @@ static void OS2_FreeCursor(SDL_Cursor *cursor) static int OS2_ShowCursor(SDL_Cursor *cursor) { - hptrCursor = (cursor != NULL)? (HPOINTER)cursor->driverdata : NULLHANDLE; + hptrCursor = (cursor)? (HPOINTER)cursor->driverdata : NULLHANDLE; return ((SDL_GetMouseFocus() == NULL) || WinSetPointer(HWND_DESKTOP, hptrCursor))? 0 : -1; } @@ -137,7 +137,7 @@ static int OS2_WarpMouseGlobal(int x, int y) static int OS2_CaptureMouse(SDL_Window *window) { - return WinSetCapture(HWND_DESKTOP, (window == NULL)? NULLHANDLE : + return WinSetCapture(HWND_DESKTOP, (!window)? NULLHANDLE : ((WINDATA *)window->driverdata)->hwnd)? 0 : -1; } @@ -182,7 +182,7 @@ void OS2_QuitMouse(_THIS) { SDL_Mouse *pSDLMouse = SDL_GetMouse(); - if (pSDLMouse->def_cursor != NULL) { + if (pSDLMouse->def_cursor) { SDL_free(pSDLMouse->def_cursor); pSDLMouse->def_cursor = NULL; pSDLMouse->cur_cursor = NULL; diff --git a/vs/sdl2/src/video/os2/SDL_os2mouse.h b/vs/sdl2/src/video/os2/SDL_os2mouse.h index e9c4d476d6..ccd99da7ae 100644 --- a/vs/sdl2/src/video/os2/SDL_os2mouse.h +++ b/vs/sdl2/src/video/os2/SDL_os2mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/os2/SDL_os2output.h b/vs/sdl2/src/video/os2/SDL_os2output.h index 284fc856c8..7115ab72da 100644 --- a/vs/sdl2/src/video/os2/SDL_os2output.h +++ b/vs/sdl2/src/video/os2/SDL_os2output.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/os2/SDL_os2util.c b/vs/sdl2/src/video/os2/SDL_os2util.c index e6a306fbf5..44450b6eb4 100644 --- a/vs/sdl2/src/video/os2/SDL_os2util.c +++ b/vs/sdl2/src/video/os2/SDL_os2util.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 #include "SDL_os2util.h" @@ -41,7 +41,7 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY) } pulBitmap = (PULONG) SDL_malloc(surface->h * surface->w * 2 * sizeof(ULONG)); - if (pulBitmap == NULL) { + if (!pulBitmap) { SDL_OutOfMemory(); return NULLHANDLE; } diff --git a/vs/sdl2/src/video/os2/SDL_os2util.h b/vs/sdl2/src/video/os2/SDL_os2util.h index 88f64c079b..5def7b6be7 100644 --- a/vs/sdl2/src/video/os2/SDL_os2util.h +++ b/vs/sdl2/src/video/os2/SDL_os2util.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/os2/SDL_os2video.c b/vs/sdl2/src/video/os2/SDL_os2video.c index 1fdd2c64f7..8da1f4f480 100644 --- a/vs/sdl2/src/video/os2/SDL_os2video.c +++ b/vs/sdl2/src/video/os2/SDL_os2video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_OS2 +#ifdef SDL_VIDEO_DRIVER_OS2 #include "SDL_video.h" #include "SDL_mouse.h" @@ -31,6 +31,7 @@ #include "SDL_os2video.h" #include "SDL_syswm.h" #include "SDL_os2util.h" +#include "SDL_os2messagebox.h" #define __MEERROR_H__ #define _MEERROR_H_ @@ -171,7 +172,7 @@ static SDL_DisplayMode *_getDisplayModeForSDLWindow(SDL_Window *window) { SDL_VideoDisplay *pSDLDisplay = SDL_GetDisplayForWindow(window); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return FALSE; } @@ -201,19 +202,19 @@ static VOID _setVisibleRegion(WINDATA *pWinData, BOOL fVisible) { SDL_VideoDisplay *pSDLDisplay; - if (! pWinData->pVOData) + if (!pWinData->pVOData) return; pSDLDisplay = (fVisible)? SDL_GetDisplayForWindow(pWinData->window) : NULL; pWinData->pOutput->SetVisibleRegion(pWinData->pVOData, pWinData->hwnd, - (pSDLDisplay == NULL) ? - NULL : &pSDLDisplay->current_mode, + (!pSDLDisplay) ? + NULL : &pSDLDisplay->current_mode, pWinData->hrgnShape, fVisible); } static VOID _wmPaint(WINDATA *pWinData, HWND hwnd) { - if (pWinData->pVOData == NULL || + if (!pWinData->pVOData || !pWinData->pOutput->Update(pWinData->pVOData, hwnd, NULL, 0)) { RECTL rectl; HPS hps; @@ -438,7 +439,7 @@ static MRESULT EXPENTRY wndFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp HWND hwndClient = WinQueryWindow(hwnd, QW_BOTTOM); WINDATA * pWinData = (WINDATA *)WinQueryWindowULong(hwndClient, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -544,7 +545,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { WINDATA *pWinData = (WINDATA *)WinQueryWindowULong(hwnd, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -565,7 +566,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_CLOSE: case WM_QUIT: SDL_SendWindowEvent(pWinData->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - if (pWinData->fnUserWndProc == NULL) + if (!pWinData->fnUserWndProc) return (MRESULT)FALSE; break; @@ -642,7 +643,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_TRANSLATEACCEL: /* ALT and acceleration keys not allowed (must be processed in WM_CHAR) */ - if (mp1 == NULL || ((PQMSG)mp1)->msg != WM_CHAR) + if (!mp1 || ((PQMSG)mp1)->msg != WM_CHAR) break; return (MRESULT)FALSE; @@ -690,7 +691,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) return _wmDrop(pWinData, (PDRAGINFO)PVOIDFROMMP(mp1)); } - return (pWinData->fnUserWndProc != NULL)? + return (pWinData->fnUserWndProc)? pWinData->fnUserWndProc(hwnd, msg, mp1, mp2) : WinDefWindowProc(hwnd, msg, mp1, mp2); } @@ -715,7 +716,7 @@ static WINDATA *_setupWindow(_THIS, SDL_Window *window, HWND hwndFrame, SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; WINDATA *pWinData = SDL_calloc(1, sizeof(WINDATA)); - if (pWinData == NULL) { + if (!pWinData) { SDL_OutOfMemory(); return NULL; } @@ -745,7 +746,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) ULONG ulSWPFlags = SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE; WINDATA *pWinData; - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* Create a PM window */ @@ -766,7 +767,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { WinDestroyWindow(hwndFrame); return -1; } @@ -809,7 +810,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) POINTL pointl; debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* User can accept client OR frame window handle. @@ -892,7 +893,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { SDL_free(window->title); window->title = NULL; return -1; @@ -911,7 +912,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData == NULL) + if (!pWinData) return; if (pWinData->hrgnShape != NULLHANDLE) { @@ -925,7 +926,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) window->shaper = NULL; } - if (pWinData->fnUserWndProc == NULL) { + if (!pWinData->fnUserWndProc) { /* Window was created by SDL (OS2_CreateWindow()), * not by user (OS2_CreateWindowFrom()) */ WinDestroyWindow(pWinData->hwndFrame); @@ -933,7 +934,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WinSetWindowULong(pWinData->hwnd, 0, 0); } - if ((pVData != NULL) && (pWinData->pVOData != NULL)) { + if ((pVData) && (pWinData->pVOData)) { pVData->pOutput->Close(pWinData->pVOData); pWinData->pVOData = NULL; } @@ -949,7 +950,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) static void OS2_SetWindowTitle(_THIS, SDL_Window *window) { - PSZ pszTitle = (window->title == NULL)? NULL : OS2_UTF8ToSys(window->title); + PSZ pszTitle = (!window->title)? NULL : OS2_UTF8ToSys(window->title); WinSetWindowText(((WINDATA *)window->driverdata)->hwndFrame, pszTitle); SDL_free(pszTitle); @@ -982,7 +983,7 @@ static void OS2_SetWindowPosition(_THIS, SDL_Window *window) SDL_DisplayMode *pSDLDisplayMode = _getDisplayModeForSDLWindow(window); debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; rectl.xLeft = 0; @@ -1102,7 +1103,7 @@ static void OS2_SetWindowFullscreen(_THIS, SDL_Window *window, debug_os2("Enter, fullscreen: %u", fullscreen); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; if (SDL_ShouldAllowTopmost() && @@ -1189,7 +1190,7 @@ static void _combineRectRegions(SDL_ShapeTree *node, void *closure) /* Expand rectangles list */ if ((pShapeRects->cRects & 0x0F) == 0) { pRect = SDL_realloc(pShapeRects->pRects, (pShapeRects->cRects + 0x10) * sizeof(RECTL)); - if (pRect == NULL) + if (!pRect) return; pShapeRects->pRects = pRect; } @@ -1235,13 +1236,13 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, HPS hps; debug_os2("Enter"); - if (shaper == NULL || shape == NULL || + if (!shaper || !shape || (shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey) || shape->w != shaper->window->w || shape->h != shaper->window->h) { return SDL_INVALID_SHAPE_ARGUMENT; } - if (shaper->driverdata != NULL) + if (shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)&shaper->driverdata); pShapeTree = SDL_CalculateShapeTree(*shape_mode, shape); @@ -1257,7 +1258,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, if (pWinData->hrgnShape != NULLHANDLE) GpiDestroyRegion(hps, pWinData->hrgnShape); - pWinData->hrgnShape = (stShapeRects.pRects == NULL) ? NULLHANDLE : + pWinData->hrgnShape = (!stShapeRects.pRects) ? NULLHANDLE : GpiCreateRegion(hps, stShapeRects.cRects, stShapeRects.pRects); WinReleasePS(hps); @@ -1270,11 +1271,11 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, static int OS2_ResizeWindowShape(SDL_Window *window) { debug_os2("Enter"); - if (window == NULL) + if (!window) return -1; if (window->x != -1000) { - if (window->shaper->driverdata != NULL) + if (window->shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)window->shaper->driverdata); if (window->shaper->hasshape == SDL_TRUE) { @@ -1295,7 +1296,7 @@ static void OS2_DestroyWindowFramebuffer(_THIS, SDL_Window *window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData != NULL && pWinData->pVOData != NULL) + if (pWinData && pWinData->pVOData) pWinData->pOutput->VideoBufFree(pWinData->pVOData); } @@ -1310,14 +1311,14 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, ULONG ulWidth, ulHeight; debug_os2("Enter"); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return -1; } pSDLDisplayMode = &pSDLDisplay->current_mode; pModeData = (MODEDATA *)pSDLDisplayMode->driverdata; - if (pModeData == NULL) + if (!pModeData) return SDL_SetError("No mode data for the display"); SDL_GetWindowSize(window, (int *)&ulWidth, (int *)&ulHeight); @@ -1326,7 +1327,7 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, *pixels = pWinData->pOutput->VideoBufAlloc( pWinData->pVOData, ulWidth, ulHeight, pModeData->ulDepth, pModeData->fccColorEncoding, (PULONG)pitch); - if (*pixels == NULL) + if (!*pixels) return -1; *format = pSDLDisplayMode->format; @@ -1353,13 +1354,13 @@ static int OS2_SetClipboardText(_THIS, const char *text) { SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; PSZ pszClipboard; - PSZ pszText = (text == NULL)? NULL : OS2_UTF8ToSys(text); + PSZ pszText = (!text)? NULL : OS2_UTF8ToSys(text); ULONG cbText; ULONG ulRC; BOOL fSuccess; debug_os2("Enter"); - if (pszText == NULL) + if (!pszText) return -1; cbText = SDL_strlen(pszText) + 1; @@ -1408,7 +1409,7 @@ static char *OS2_GetClipboardText(_THIS) WinCloseClipbrd(pVData->hab); } - return (pszClipboard == NULL) ? SDL_strdup("") : pszClipboard; + return (!pszClipboard) ? SDL_strdup("") : pszClipboard; } static SDL_bool OS2_HasClipboardText(_THIS) @@ -1438,7 +1439,7 @@ static int OS2_VideoInit(_THIS) /* Create SDL video driver private data */ pVData = SDL_calloc(1, sizeof(SDL_VideoData)); - if (pVData == NULL) + if (!pVData) return SDL_OutOfMemory(); /* Change process type code for use Win* API from VIO session */ @@ -1493,7 +1494,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplayMode.driverdata = NULL; pModeData = SDL_malloc(sizeof(MODEDATA)); - if (pModeData != NULL) { + if (pModeData) { pModeData->ulDepth = stVOInfo.ulBPP; pModeData->fccColorEncoding = stVOInfo.fccColorEncoding; pModeData->ulScanLineBytes = stVOInfo.ulScanLineSize; @@ -1507,7 +1508,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplay.num_display_modes = 0; pDisplayData = SDL_malloc(sizeof(DISPLAYDATA)); - if (pDisplayData != NULL) { + if (pDisplayData) { HPS hps = WinGetPS(HWND_DESKTOP); HDC hdc = GpiQueryDevice(hps); @@ -1566,14 +1567,14 @@ static int OS2_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, DISPLAYDATA *pDisplayData = (DISPLAYDATA *)display->driverdata; debug_os2("Enter"); - if (pDisplayData == NULL) + if (!pDisplayData) return -1; - if (ddpi != NULL) + if (ddpi) *hdpi = pDisplayData->ulDPIDiag; - if (hdpi != NULL) + if (hdpi) *hdpi = pDisplayData->ulDPIHor; - if (vdpi != NULL) + if (vdpi) *vdpi = pDisplayData->ulDPIVer; return 0; @@ -1683,12 +1684,14 @@ static SDL_VideoDevice *OS2VMAN_CreateDevice(void) VideoBootStrap OS2DIVE_bootstrap = { OS2DRIVER_NAME_DIVE, "OS/2 video driver", - OS2DIVE_CreateDevice + OS2DIVE_CreateDevice, + OS2_ShowMessageBox }; VideoBootStrap OS2VMAN_bootstrap = { OS2DRIVER_NAME_VMAN, "OS/2 video driver", - OS2VMAN_CreateDevice + OS2VMAN_CreateDevice, + OS2_ShowMessageBox }; #endif /* SDL_VIDEO_DRIVER_OS2 */ diff --git a/vs/sdl2/src/video/os2/SDL_os2video.h b/vs/sdl2/src/video/os2/SDL_os2video.h index da6afb6067..0f9f3799c0 100644 --- a/vs/sdl2/src/video/os2/SDL_os2video.h +++ b/vs/sdl2/src/video/os2/SDL_os2video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/os2/SDL_os2vman.c b/vs/sdl2/src/video/os2/SDL_os2vman.c index 00ae4bca2c..5945e8e4b9 100644 --- a/vs/sdl2/src/video/os2/SDL_os2vman.c +++ b/vs/sdl2/src/video/os2/SDL_os2vman.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -143,7 +143,7 @@ static PRECTL _getRectlArray(PVODATA pVOData, ULONG cRects) return pVOData->pRectl; pRectl = SDL_realloc(pVOData->pRectl, cRects * sizeof(RECTL)); - if (pRectl == NULL) + if (!pRectl) return NULL; pVOData->pRectl = pRectl; @@ -159,7 +159,7 @@ static PBLTRECT _getBltRectArray(PVODATA pVOData, ULONG cRects) return pVOData->pBltRect; pBltRect = SDL_realloc(pVOData->pBltRect, cRects * sizeof(BLTRECT)); - if (pBltRect == NULL) + if (!pBltRect) return NULL; pVOData->pBltRect = pBltRect; @@ -200,7 +200,7 @@ static PVODATA voOpen(void) return NULL; pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -210,10 +210,10 @@ static PVODATA voOpen(void) static VOID voClose(PVODATA pVOData) { - if (pVOData->pRectl != NULL) + if (pVOData->pRectl) SDL_free(pVOData->pRectl); - if (pVOData->pBltRect != NULL) + if (pVOData->pBltRect) SDL_free(pVOData->pBltRect); voVideoBufFree(pVOData); @@ -253,7 +253,7 @@ static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd, WinQueryWindowRect(hwnd, &pVOData->rectlWin); WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL)&pVOData->rectlWin, 2); - if (pSDLDisplayMode != NULL) { + if (pSDLDisplayMode) { pVOData->ulScreenHeight = pSDLDisplayMode->h; pVOData->ulScreenBytesPerLine = ((MODEDATA *)pSDLDisplayMode->driverdata)->ulScanLineBytes; @@ -302,7 +302,7 @@ static VOID voVideoBufFree(PVODATA pVOData) { ULONG ulRC; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return; ulRC = DosFreeMem(pVOData->pBuffer); @@ -329,7 +329,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, BITBLTINFO sBitbltInfo; ULONG ulIdx; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return FALSE; if (pVOData->hrgnVisible == NULLHANDLE) @@ -366,7 +366,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make list of destination rectangles (prectlDst) list from the source * list (prectl). */ prectlDst = _getRectlArray(pVOData, cSDLRects); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); return FALSE; } @@ -400,7 +400,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, } /* We don't need prectlDst, use it again to store update regions */ prectlDst = _getRectlArray(pVOData, rgnCtl.crcReturned); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); GpiDestroyRegion(hps, hrgnUpdate); WinReleasePS(hps); @@ -418,7 +418,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make lists for blitting from update regions */ pbrDst = _getBltRectArray(pVOData, cSDLRects); - if (pbrDst == NULL) { + if (!pbrDst) { debug_os2("Not enough memory"); return FALSE; } diff --git a/vs/sdl2/src/video/pandora/SDL_pandora.c b/vs/sdl2/src/video/pandora/SDL_pandora.c index 16debcb13b..35e062347f 100644 --- a/vs/sdl2/src/video/pandora/SDL_pandora.c +++ b/vs/sdl2/src/video/pandora/SDL_pandora.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PANDORA +#ifdef SDL_VIDEO_DRIVER_PANDORA /* SDL internals */ #include "../SDL_sysvideo.h" @@ -41,43 +41,30 @@ static NativeWindowType hNativeWnd = 0; /* A handle to the window we will create. */ #endif -static int PND_available(void) -{ - return 1; -} - static void PND_destroy(SDL_VideoDevice * device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } SDL_free(device); } -static SDL_VideoDevice *PND_create() +static SDL_VideoDevice *PND_create(void) { SDL_VideoDevice *device; SDL_VideoData *phdata; - int status; - - /* Check if pandora could be initialized */ - status = PND_available(); - if (status == 0) { - /* PND could not be used */ - return NULL; - } /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal Pandora specific data */ phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -139,8 +126,8 @@ VideoBootStrap PND_bootstrap = { "pandora", "SDL Pandora Video Driver", #endif - PND_available, - PND_create + PND_create, + NULL /* no ShowMessageBox implementation */ }; /*****************************************************************************/ @@ -196,7 +183,7 @@ int PND_createwindow(_THIS, SDL_Window * window) /* Allocate window internal data */ wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -297,15 +284,15 @@ SDL_bool PND_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *i int PND_gl_loadlibrary(_THIS, const char *path) { /* Check if OpenGL ES library is specified for GF driver */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGLES_LIBRARY"); } } /* Check if default library loading requested */ - if (path == NULL) { + if (!path) { /* Already linked with GF library which provides egl* subset of */ /* functions, use Common profile of OpenGL ES library by default */ #ifdef WIZ_GLES_LITE @@ -336,7 +323,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) /* Try to get function address through the egl interface */ function_address = eglGetProcAddress(proc); - if (function_address != NULL) { + if (function_address) { return function_address; } @@ -344,7 +331,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) if (_this->gl_config.dll_handle) { function_address = SDL_LoadFunction(_this->gl_config.dll_handle, proc); - if (function_address != NULL) { + if (function_address) { return function_address; } } @@ -586,16 +573,16 @@ SDL_GLContext PND_gl_createcontext(_THIS, SDL_Window * window) } #ifdef WIZ_GLES_LITE - if( !hNativeWnd ) { - hNativeWnd = (NativeWindowType)SDL_malloc(16*1024); - - if(!hNativeWnd) - printf( "Error: Wiz framebuffer allocatation failed\n" ); - else - printf( "SDL: Wiz framebuffer allocated: %X\n", hNativeWnd ); + if (!hNativeWnd) { + hNativeWnd = (NativeWindowType)SDL_malloc(16*1024); + if (!hNativeWnd) { + printf("Error: Wiz framebuffer allocatation failed\n"); + } else { + printf("SDL: Wiz framebuffer allocated: %X\n", hNativeWnd); + } } else { - printf( "SDL: Wiz framebuffer already allocated: %X\n", hNativeWnd ); + printf("SDL: Wiz framebuffer already allocated: %X\n", hNativeWnd); } wdata->gles_surface = @@ -683,7 +670,7 @@ int PND_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) return SDL_SetError("PND: GF initialization failed, no OpenGL ES support"); } - if ((window == NULL) && (context == NULL)) { + if ((!window) && (!context)) { status = eglMakeCurrent(phdata->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); @@ -787,11 +774,10 @@ void PND_gl_deletecontext(_THIS, SDL_GLContext context) } #ifdef WIZ_GLES_LITE - if( hNativeWnd != 0 ) - { + if (hNativeWnd != 0) { SDL_free(hNativeWnd); hNativeWnd = 0; - printf( "SDL: Wiz framebuffer released\n" ); + printf("SDL: Wiz framebuffer released\n"); } #endif diff --git a/vs/sdl2/src/video/pandora/SDL_pandora.h b/vs/sdl2/src/video/pandora/SDL_pandora.h index 66e5d220fa..43faa6a8c9 100644 --- a/vs/sdl2/src/video/pandora/SDL_pandora.h +++ b/vs/sdl2/src/video/pandora/SDL_pandora.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/pandora/SDL_pandora_events.c b/vs/sdl2/src/video/pandora/SDL_pandora_events.c index 906c758003..4d6ef6e8cb 100644 --- a/vs/sdl2/src/video/pandora/SDL_pandora_events.c +++ b/vs/sdl2/src/video/pandora/SDL_pandora_events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PANDORA +#ifdef SDL_VIDEO_DRIVER_PANDORA /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ diff --git a/vs/sdl2/src/video/pandora/SDL_pandora_events.h b/vs/sdl2/src/video/pandora/SDL_pandora_events.h index 98974b4ca0..4753ff11fc 100644 --- a/vs/sdl2/src/video/pandora/SDL_pandora_events.h +++ b/vs/sdl2/src/video/pandora/SDL_pandora_events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/ps2/SDL_ps2video.c b/vs/sdl2/src/video/ps2/SDL_ps2video.c index 490ea259e8..4e823fe2db 100644 --- a/vs/sdl2/src/video/ps2/SDL_ps2video.c +++ b/vs/sdl2/src/video/ps2/SDL_ps2video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PS2 +#ifdef SDL_VIDEO_DRIVER_PS2 /* PS2 SDL video driver implementation; this is just enough to make an * SDL-based application THINK it's got a working video driver, for @@ -107,7 +107,7 @@ static SDL_VideoDevice *PS2_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -126,7 +126,8 @@ static SDL_VideoDevice *PS2_CreateDevice(void) VideoBootStrap PS2_bootstrap = { "PS2", "PS2 Video Driver", - PS2_CreateDevice + PS2_CreateDevice, + NULL /* no ShowMessageBox implementation */ }; #endif /* SDL_VIDEO_DRIVER_PS2 */ diff --git a/vs/sdl2/src/video/ps2/SDL_ps2video.h b/vs/sdl2/src/video/ps2/SDL_ps2video.h index 70c2b85143..6bc13b81ec 100644 --- a/vs/sdl2/src/video/ps2/SDL_ps2video.h +++ b/vs/sdl2/src/video/ps2/SDL_ps2video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/psp/SDL_pspevents.c b/vs/sdl2/src/video/psp/SDL_pspevents.c index ebea736df9..44b487faf7 100644 --- a/vs/sdl2/src/video/psp/SDL_pspevents.c +++ b/vs/sdl2/src/video/psp/SDL_pspevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PSP +#ifdef SDL_VIDEO_DRIVER_PSP /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ @@ -237,7 +237,7 @@ void PSP_InitOSKeymap(_THIS) #endif } -void PSP_EventInit(_THIS) +int PSP_EventInit(_THIS) { #ifdef PSPIRKEYB int outputmode = PSP_IRKBD_OUTPUT_MODE_SCANCODE; @@ -251,14 +251,13 @@ void PSP_EventInit(_THIS) #endif /* Start thread to read data */ if ((event_sem = SDL_CreateSemaphore(1)) == NULL) { - SDL_SetError("Can't create input semaphore"); - return; + return SDL_SetError("Can't create input semaphore"); } running = 1; if ((thread = SDL_CreateThreadInternal(EventUpdate, "PSPInputThread", 4096, NULL)) == NULL) { - SDL_SetError("Can't create input thread"); - return; + return SDL_SetError("Can't create input thread"); } + return 0; } void PSP_EventQuit(_THIS) diff --git a/vs/sdl2/src/video/psp/SDL_pspevents_c.h b/vs/sdl2/src/video/psp/SDL_pspevents_c.h index 9183def4ca..fc9cd0e947 100644 --- a/vs/sdl2/src/video/psp/SDL_pspevents_c.h +++ b/vs/sdl2/src/video/psp/SDL_pspevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,5 +23,7 @@ extern void PSP_InitOSKeymap(_THIS); extern void PSP_PumpEvents(_THIS); +extern int PSP_EventInit(_THIS); +extern void PSP_EventQuit(_THIS); /* end of SDL_pspevents_c.h ... */ diff --git a/vs/sdl2/src/video/psp/SDL_pspgl.c b/vs/sdl2/src/video/psp/SDL_pspgl.c index a00e638e9b..7071091e7a 100644 --- a/vs/sdl2/src/video/psp/SDL_pspgl.c +++ b/vs/sdl2/src/video/psp/SDL_pspgl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PSP +#ifdef SDL_VIDEO_DRIVER_PSP #include #include diff --git a/vs/sdl2/src/video/psp/SDL_pspgl_c.h b/vs/sdl2/src/video/psp/SDL_pspgl_c.h index 00128d762c..b302c8e3fd 100644 --- a/vs/sdl2/src/video/psp/SDL_pspgl_c.h +++ b/vs/sdl2/src/video/psp/SDL_pspgl_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/psp/SDL_pspmouse.c b/vs/sdl2/src/video/psp/SDL_pspmouse.c index 774649adb9..57fc45cdd4 100644 --- a/vs/sdl2/src/video/psp/SDL_pspmouse.c +++ b/vs/sdl2/src/video/psp/SDL_pspmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PSP +#ifdef SDL_VIDEO_DRIVER_PSP #include diff --git a/vs/sdl2/src/video/psp/SDL_pspmouse_c.h b/vs/sdl2/src/video/psp/SDL_pspmouse_c.h index 3742738adc..a961232b55 100644 --- a/vs/sdl2/src/video/psp/SDL_pspmouse_c.h +++ b/vs/sdl2/src/video/psp/SDL_pspmouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/psp/SDL_pspvideo.c b/vs/sdl2/src/video/psp/SDL_pspvideo.c index 676196c01b..9631904bd1 100644 --- a/vs/sdl2/src/video/psp/SDL_pspvideo.c +++ b/vs/sdl2/src/video/psp/SDL_pspvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_PSP +#ifdef SDL_VIDEO_DRIVER_PSP /* SDL internals */ #include "../SDL_sysvideo.h" @@ -46,7 +46,7 @@ static void PSP_Destroy(SDL_VideoDevice *device) { /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ - if (device->driverdata != NULL) { + if (device->driverdata) { device->driverdata = NULL; } } @@ -59,21 +59,21 @@ static SDL_VideoDevice *PSP_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal PSP specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; } gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -134,7 +134,8 @@ static SDL_VideoDevice *PSP_Create() VideoBootStrap PSP_bootstrap = { "PSP", "PSP Video Driver", - PSP_Create + PSP_Create, + NULL /* no ShowMessageBox implementation */ }; /*****************************************************************************/ @@ -145,6 +146,10 @@ int PSP_VideoInit(_THIS) SDL_VideoDisplay display; SDL_DisplayMode current_mode; + if (PSP_EventInit(_this) == -1) { + return -1; /* error string would already be set */ + } + SDL_zero(current_mode); current_mode.w = 480; @@ -169,11 +174,13 @@ int PSP_VideoInit(_THIS) SDL_AddDisplayMode(&display, ¤t_mode); SDL_AddVideoDisplay(&display, SDL_FALSE); - return 1; + + return 0; } void PSP_VideoQuit(_THIS) { + PSP_EventQuit(_this); } void PSP_GetDisplayModes(_THIS, SDL_VideoDisplay *display) @@ -202,7 +209,7 @@ int PSP_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } diff --git a/vs/sdl2/src/video/psp/SDL_pspvideo.h b/vs/sdl2/src/video/psp/SDL_pspvideo.h index 1b9ae92877..442d3eae03 100644 --- a/vs/sdl2/src/video/psp/SDL_pspvideo.h +++ b/vs/sdl2/src/video/psp/SDL_pspvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/qnx/gl.c b/vs/sdl2/src/video/qnx/gl.c index cf487ed464..e6e999a607 100644 --- a/vs/sdl2/src/video/qnx/gl.c +++ b/vs/sdl2/src/video/qnx/gl.c @@ -84,7 +84,7 @@ int glGetConfig(EGLConfig *pconf, int *pformat) // Allocate enough memory for all configurations. egl_configs = SDL_malloc(egl_num_configs * sizeof(*egl_configs)); - if (egl_configs == NULL) { + if (!egl_configs) { return -1; } diff --git a/vs/sdl2/src/video/qnx/video.c b/vs/sdl2/src/video/qnx/video.c index cecd717d5b..924eaa3078 100644 --- a/vs/sdl2/src/video/qnx/video.c +++ b/vs/sdl2/src/video/qnx/video.c @@ -74,7 +74,7 @@ static int createWindow(_THIS, SDL_Window *window) int usage; impl = SDL_calloc(1, sizeof(*impl)); - if (impl == NULL) { + if (!impl) { return -1; } @@ -311,7 +311,7 @@ static SDL_VideoDevice *createDevice(int devindex) SDL_VideoDevice *device; device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { return NULL; } @@ -342,5 +342,6 @@ static SDL_VideoDevice *createDevice(int devindex) VideoBootStrap QNX_bootstrap = { "qnx", "QNX Screen", - createDevice + createDevice, + NULL /* no ShowMessageBox implementation */ }; diff --git a/vs/sdl2/src/video/raspberry/SDL_rpievents.c b/vs/sdl2/src/video/raspberry/SDL_rpievents.c index 9f2fccc0e5..5b9bdf0621 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpievents.c +++ b/vs/sdl2/src/video/raspberry/SDL_rpievents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI #include "../../events/SDL_events_c.h" #include "../../events/SDL_keyboard_c.h" diff --git a/vs/sdl2/src/video/raspberry/SDL_rpievents_c.h b/vs/sdl2/src/video/raspberry/SDL_rpievents_c.h index a4c349676f..e3b826c383 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpievents_c.h +++ b/vs/sdl2/src/video/raspberry/SDL_rpievents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,5 @@ #include "SDL_rpivideo.h" void RPI_PumpEvents(_THIS); -void RPI_EventInit(_THIS); -void RPI_EventQuit(_THIS); #endif /* SDL_rpievents_c_h_ */ diff --git a/vs/sdl2/src/video/raspberry/SDL_rpimouse.c b/vs/sdl2/src/video/raspberry/SDL_rpimouse.c index 2d9b884d91..ff35a7913c 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpimouse.c +++ b/vs/sdl2/src/video/raspberry/SDL_rpimouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI #include "SDL_surface.h" #include "SDL_hints.h" @@ -70,12 +70,12 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_assert(surface->pitch == surface->w * 4); cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); return NULL; } curdata = (RPI_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -119,12 +119,12 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) const char *env; mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return -1; } if (cursor != global_cursor) { - if (global_cursor != NULL) { + if (global_cursor) { curdata = (RPI_CursorData *)global_cursor->driverdata; if (curdata && curdata->element > DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); @@ -139,26 +139,26 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) global_cursor = cursor; } - if (cursor == NULL) { + if (!cursor) { return 0; } curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata == NULL) { + if (!curdata) { return -1; } - if (mouse->focus == NULL) { + if (!mouse->focus) { return -1; } display = SDL_GetDisplayForWindow(mouse->focus); - if (display == NULL) { + if (!display) { return -1; } data = (SDL_DisplayData *)display->driverdata; - if (data == NULL) { + if (!data) { return -1; } @@ -199,10 +199,10 @@ static void RPI_FreeCursor(SDL_Cursor *cursor) DISPMANX_UPDATE_HANDLE_T update; RPI_CursorData *curdata; - if (cursor != NULL) { + if (cursor) { curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->element != DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); SDL_assert(update); @@ -242,7 +242,7 @@ static int RPI_WarpMouseGlobal(int x, int y) VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } @@ -300,7 +300,7 @@ static int RPI_WarpMouseGlobalGraphicOnly(int x, int y) VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } diff --git a/vs/sdl2/src/video/raspberry/SDL_rpimouse.h b/vs/sdl2/src/video/raspberry/SDL_rpimouse.h index 895fa39a2a..8ff70dec67 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpimouse.h +++ b/vs/sdl2/src/video/raspberry/SDL_rpimouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/raspberry/SDL_rpiopengles.c b/vs/sdl2/src/video/raspberry/SDL_rpiopengles.c index bce27e2c41..27b4edffc4 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpiopengles.c +++ b/vs/sdl2/src/video/raspberry/SDL_rpiopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #include "SDL_hints.h" -#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_RPI) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_rpivideo.h" #include "SDL_rpiopengles.h" diff --git a/vs/sdl2/src/video/raspberry/SDL_rpiopengles.h b/vs/sdl2/src/video/raspberry/SDL_rpiopengles.h index cfe7a94731..15c6ab1faf 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpiopengles.h +++ b/vs/sdl2/src/video/raspberry/SDL_rpiopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_rpiopengles_h_ #define SDL_rpiopengles_h_ -#if SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_RPI) && defined(SDL_VIDEO_OPENGL_EGL) #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/raspberry/SDL_rpivideo.c b/vs/sdl2/src/video/raspberry/SDL_rpivideo.c index f56e23d95a..1442607b1c 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpivideo.c +++ b/vs/sdl2/src/video/raspberry/SDL_rpivideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RPI +#ifdef SDL_VIDEO_DRIVER_RPI /* References * http://elinux.org/RPi_VideoCore_APIs @@ -77,14 +77,14 @@ static SDL_VideoDevice *RPI_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -138,7 +138,8 @@ static SDL_VideoDevice *RPI_Create() VideoBootStrap RPI_bootstrap = { "RPI", "RPI Video Driver", - RPI_Create + RPI_Create, + NULL /* no ShowMessageBox implementation */ }; /*****************************************************************************/ @@ -179,7 +180,7 @@ static void AddDispManXDisplay(const int display_id) /* Allocate display internal data */ data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { vc_dispmanx_display_close(handle); return; /* oh well */ } @@ -256,7 +257,7 @@ int RPI_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } display = SDL_GetDisplayForWindow(window); @@ -350,7 +351,7 @@ void RPI_DestroyWindow(_THIS, SDL_Window *window) SDL_DestroyMutex(data->vsync_cond_mutex); } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); } diff --git a/vs/sdl2/src/video/raspberry/SDL_rpivideo.h b/vs/sdl2/src/video/raspberry/SDL_rpivideo.h index a0e9d21a6c..e2ffe6f9fc 100644 --- a/vs/sdl2/src/video/raspberry/SDL_rpivideo.h +++ b/vs/sdl2/src/video/raspberry/SDL_rpivideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ typedef struct SDL_DisplayData typedef struct SDL_WindowData { EGL_DISPMANX_WINDOW_T dispman_window; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif diff --git a/vs/sdl2/src/video/riscos/SDL_riscosdefs.h b/vs/sdl2/src/video/riscos/SDL_riscosdefs.h index 81c505856d..8a621c2094 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosdefs.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosdefs.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscosevents.c b/vs/sdl2/src/video/riscos/SDL_riscosevents.c index 77b3ba94de..cebb89f5bb 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosevents.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "../../events/SDL_events_c.h" @@ -152,7 +152,7 @@ int RISCOS_InitEvents(_THIS) SDL_ToggleModState(KMOD_NUM, (status & (1 << 2)) ? SDL_FALSE : SDL_TRUE); SDL_ToggleModState(KMOD_CAPS, (status & (1 << 4)) ? SDL_FALSE : SDL_TRUE); SDL_ToggleModState(KMOD_SCROLL, (status & (1 << 1)) ? SDL_TRUE : SDL_FALSE); - + _kernel_swi(OS_Mouse, ®s, ®s); driverdata->last_mouse_buttons = regs.r[2]; diff --git a/vs/sdl2/src/video/riscos/SDL_riscosevents_c.h b/vs/sdl2/src/video/riscos/SDL_riscosevents_c.h index 1acaca804c..6f16b193ca 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosevents_c.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscosframebuffer.c b/vs/sdl2/src/video/riscos/SDL_riscosframebuffer.c index 36ce340ef6..ae128d3513 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosframebuffer.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "../SDL_sysvideo.h" #include "SDL_riscosframebuffer_c.h" @@ -80,7 +80,7 @@ int RISCOS_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, vo regs.r[5] = h; regs.r[6] = sprite_mode; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(driverdata->fb_area); return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum); } @@ -106,7 +106,7 @@ int RISCOS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *re regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum); } diff --git a/vs/sdl2/src/video/riscos/SDL_riscosframebuffer_c.h b/vs/sdl2/src/video/riscos/SDL_riscosframebuffer_c.h index 3c304ab37c..e4f79ad3e7 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosframebuffer_c.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosframebuffer_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.c b/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.c index c2fe81b97c..9d44e07b48 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "SDL_messagebox.h" #include "SDL_riscosmessagebox.h" diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.h b/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.h index 4fbf6afa79..09f9c76b94 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS extern int RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmodes.c b/vs/sdl2/src/video/riscos/SDL_riscosmodes.c index 35a42e38e2..79f5fa39e5 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmodes.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosmodes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" @@ -166,7 +166,7 @@ static void *convert_mode_block(const int *block) } dst = SDL_malloc(40); - if (dst == NULL) { + if (!dst) { return NULL; } @@ -207,7 +207,7 @@ int RISCOS_InitModes(_THIS) regs.r[0] = 1; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum); } @@ -237,13 +237,13 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; } block = SDL_malloc(-regs.r[7]); - if (block == NULL) { + if (!block) { SDL_OutOfMemory(); return; } @@ -251,7 +251,7 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) regs.r[6] = (int)block; regs.r[7] = -regs.r[7]; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(block); SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; @@ -290,7 +290,7 @@ int RISCOS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mod regs.r[0] = 0; regs.r[1] = (int)mode->driverdata; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); } diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmodes.h b/vs/sdl2/src/video/riscos/SDL_riscosmodes.h index 7ff1f12e4b..f523dd4939 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmodes.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmouse.c b/vs/sdl2/src/video/riscos/SDL_riscosmouse.c index e4c42222b8..90c6de06b7 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmouse.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "../../events/SDL_mouse_c.h" diff --git a/vs/sdl2/src/video/riscos/SDL_riscosmouse.h b/vs/sdl2/src/video/riscos/SDL_riscosmouse.h index c0aec8077d..e675d84f43 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosmouse.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscosvideo.c b/vs/sdl2/src/video/riscos/SDL_riscosvideo.c index 05c7d925b0..1550139b70 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosvideo.c +++ b/vs/sdl2/src/video/riscos/SDL_riscosvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "SDL_video.h" #include "SDL_mouse.h" @@ -34,6 +34,7 @@ #include "SDL_riscosmouse.h" #include "SDL_riscosmodes.h" #include "SDL_riscoswindow.h" +#include "SDL_riscosmessagebox.h" #define RISCOSVID_DRIVER_NAME "riscos" @@ -56,14 +57,14 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -94,7 +95,8 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) VideoBootStrap RISCOS_bootstrap = { RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver", - RISCOS_CreateDevice + RISCOS_CreateDevice, + RISCOS_ShowMessageBox }; static int RISCOS_VideoInit(_THIS) diff --git a/vs/sdl2/src/video/riscos/SDL_riscosvideo.h b/vs/sdl2/src/video/riscos/SDL_riscosvideo.h index ffa6c7f535..d014458fa0 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscosvideo.h +++ b/vs/sdl2/src/video/riscos/SDL_riscosvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/SDL_riscoswindow.c b/vs/sdl2/src/video/riscos/SDL_riscoswindow.c index cf8e71dfa4..5a59c4994c 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscoswindow.c +++ b/vs/sdl2/src/video/riscos/SDL_riscoswindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_RISCOS +#ifdef SDL_VIDEO_DRIVER_RISCOS #include "SDL_version.h" #include "SDL_syswm.h" @@ -36,7 +36,7 @@ int RISCOS_CreateWindow(_THIS, SDL_Window *window) SDL_WindowData *driverdata; driverdata = (SDL_WindowData *)SDL_calloc(1, sizeof(*driverdata)); - if (driverdata == NULL) { + if (!driverdata) { return SDL_OutOfMemory(); } driverdata->window = window; @@ -54,7 +54,7 @@ void RISCOS_DestroyWindow(_THIS, SDL_Window *window) { SDL_WindowData *driverdata = (SDL_WindowData *)window->driverdata; - if (driverdata == NULL) { + if (!driverdata) { return; } diff --git a/vs/sdl2/src/video/riscos/SDL_riscoswindow.h b/vs/sdl2/src/video/riscos/SDL_riscoswindow.h index 154823747c..48d17baaac 100644 --- a/vs/sdl2/src/video/riscos/SDL_riscoswindow.h +++ b/vs/sdl2/src/video/riscos/SDL_riscoswindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/riscos/scancodes_riscos.h b/vs/sdl2/src/video/riscos/scancodes_riscos.h index 5e742e3278..1caa33af0e 100644 --- a/vs/sdl2/src/video/riscos/scancodes_riscos.h +++ b/vs/sdl2/src/video/riscos/scancodes_riscos.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/sdlgenblit.pl b/vs/sdl2/src/video/sdlgenblit.pl index 8ea89668e5..4afef7a0d0 100755 --- a/vs/sdl2/src/video/sdlgenblit.pl +++ b/vs/sdl2/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-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -518,15 +518,15 @@ sub output_copyfunc } if ( $scale ) { print FILE <<__EOF__; - int srcy, srcx; - Uint32 posy, posx; - int incy, incx; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; __EOF__ print FILE <<__EOF__; - incy = (info->src_h << 16) / info->dst_h; - incx = (info->src_w << 16) / info->dst_w; + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; posy = incy / 2; while (info->dst_h--) { diff --git a/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.h b/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.h index ac0a88ac9a..c40dae0795 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.m b/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.m index 1e27200e03..8fd4c71014 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitappdelegate.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "../SDL_sysvideo.h" #include "SDL_hints.h" @@ -408,7 +408,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( { NSBundle *bundle = [NSBundle mainBundle]; -#if SDL_IPHONE_LAUNCHSCREEN +#ifdef SDL_IPHONE_LAUNCHSCREEN /* The normal launch screen is displayed until didFinishLaunching returns, * but SDL_main is called after that happens and there may be a noticeable * delay between the start of SDL_main and when the first real frame is diff --git a/vs/sdl2/src/video/uikit/SDL_uikitclipboard.h b/vs/sdl2/src/video/uikit/SDL_uikitclipboard.h index 2e18a0eb66..ad26742932 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitclipboard.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitclipboard.m b/vs/sdl2/src/video/uikit/SDL_uikitclipboard.m index da475f3082..b025697e17 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitclipboard.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitclipboard.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL_uikitvideo.h" #include "../../events/SDL_clipboardevents_c.h" diff --git a/vs/sdl2/src/video/uikit/SDL_uikitevents.h b/vs/sdl2/src/video/uikit/SDL_uikitevents.h index f7cd77651b..fae375918b 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitevents.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitevents.m b/vs/sdl2/src/video/uikit/SDL_uikitevents.m index 68d38bcac8..938b70a7d7 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitevents.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitevents.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "../../events/SDL_events_c.h" @@ -146,7 +146,7 @@ touch events to get processed (which is important to get certain } while(result == kCFRunLoopRunHandledSource); /* See the comment in the function definition. */ -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) UIKit_GL_RestoreCurrentContext(); #endif } @@ -257,8 +257,33 @@ void SDL_QuitGCKeyboard(void) static id mouse_connect_observer = nil; static id mouse_disconnect_observer = nil; static bool mouse_relative_mode = SDL_FALSE; +static SDL_MouseWheelDirection mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; -static void UpdatePointerLock() +static void UpdateScrollDirection(void) +{ +#if 0 /* This code doesn't work for some reason */ + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + if ([userDefaults boolForKey:@"com.apple.swipescrolldirection"]) { + mouse_scroll_direction = SDL_MOUSEWHEEL_FLIPPED; + } else { + mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; + } +#else + Boolean keyExistsAndHasValidFormat = NO; + Boolean naturalScrollDirection = CFPreferencesGetAppBooleanValue(CFSTR("com.apple.swipescrolldirection"), kCFPreferencesAnyApplication, &keyExistsAndHasValidFormat); + if (!keyExistsAndHasValidFormat) { + /* Couldn't read the preference, assume natural scrolling direction */ + naturalScrollDirection = YES; + } + if (naturalScrollDirection) { + mouse_scroll_direction = SDL_MOUSEWHEEL_FLIPPED; + } else { + mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; + } +#endif +} + +static void UpdatePointerLock(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); SDL_Window *window; @@ -313,10 +338,22 @@ static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14 } }; - mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) - { - SDL_SendMouseWheel(SDL_GetMouseFocus(), 0, xValue, yValue, SDL_MOUSEWHEEL_NORMAL); + mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) { + /* Raw scroll values come in here, vertical values in the first axis, horizontal values in the second axis. + * The vertical values are negative moving the mouse wheel up and positive moving it down. + * The horizontal values are negative moving the mouse wheel left and positive moving it right. + * The vertical values are inverted compared to SDL, and the horizontal values are as expected. + */ + float vertical = -xValue; + float horizontal = yValue; + if (mouse_scroll_direction == SDL_MOUSEWHEEL_FLIPPED) { + /* Since these are raw values, we need to flip them ourselves */ + vertical = -vertical; + horizontal = -horizontal; + } + SDL_SendMouseWheel(SDL_GetMouseFocus(), mouseID, horizontal, vertical, mouse_scroll_direction); }; + UpdateScrollDirection(); dispatch_queue_t queue = dispatch_queue_create( "org.libsdl.input.mouse", DISPATCH_QUEUE_SERIAL ); dispatch_set_target_queue( queue, dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_HIGH, 0 ) ); diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.h b/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.h index c553c04591..8723983706 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT extern SDL_bool UIKit_ShowingMessageBox(void); diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.m b/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.m index 03e3f38039..b68c0657e0 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitmessagebox.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL.h" #include "SDL_uikitvideo.h" diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmetalview.h b/vs/sdl2/src/video/uikit/SDL_uikitmetalview.h index 3f9112368a..7a3060e7ea 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmetalview.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitmetalview.h @@ -1,15 +1,15 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga - + Copyright (C) 1997-2024 Sam Lantinga + 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 @@ -32,7 +32,7 @@ #include "../SDL_sysvideo.h" #include "SDL_uikitwindow.h" -#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) #import #import diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmetalview.m b/vs/sdl2/src/video/uikit/SDL_uikitmetalview.m index 6bb43eaa51..5c41aa5b84 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmetalview.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitmetalview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) #include "SDL_syswm.h" #include "../SDL_sysvideo.h" diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmodes.h b/vs/sdl2/src/video/uikit/SDL_uikitmodes.h index e3f3d22e79..38511a2991 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmodes.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitmodes.m b/vs/sdl2/src/video/uikit/SDL_uikitmodes.m index e60badaec6..47723070a1 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitmodes.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitmodes.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL_system.h" #include "SDL_uikitmodes.h" @@ -517,7 +517,7 @@ void UIKit_QuitModes(_THIS) } #if !TARGET_OS_TV -void SDL_OnApplicationDidChangeStatusBarOrientation() +void SDL_OnApplicationDidChangeStatusBarOrientation(void) { BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); SDL_VideoDisplay *display = SDL_GetDisplay(0); diff --git a/vs/sdl2/src/video/uikit/SDL_uikitopengles.h b/vs/sdl2/src/video/uikit/SDL_uikitopengles.h index 509c0c8851..00efc464ec 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitopengles.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #ifndef SDL_uikitopengles_ #define SDL_uikitopengles_ -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) #include "../SDL_sysvideo.h" @@ -37,7 +37,7 @@ extern int UIKit_GL_LoadLibrary(_THIS, const char *path); extern void UIKit_GL_RestoreCurrentContext(void); -#endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#endif // SDL_VIDEO_OPENGL_ES || defined(SDL_VIDEO_OPENGL_ES2) #endif /* SDL_uikitopengles_ */ diff --git a/vs/sdl2/src/video/uikit/SDL_uikitopengles.m b/vs/sdl2/src/video/uikit/SDL_uikitopengles.m index e0e7b5b383..8713ae3401 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitopengles.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitopengles.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2) +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)) #include "SDL_uikitopengles.h" #import "SDL_uikitopenglview.h" @@ -114,7 +114,7 @@ int UIKit_GL_SwapWindow(_THIS, SDL_Window * window) @autoreleasepool { SDLEAGLContext *context = (__bridge SDLEAGLContext *) SDL_GL_GetCurrentContext(); -#if SDL_POWER_UIKIT +#ifdef SDL_POWER_UIKIT /* Check once a frame to see if we should turn off the battery monitor. */ SDL_UIKit_UpdateBatteryMonitoring(); #endif diff --git a/vs/sdl2/src/video/uikit/SDL_uikitopenglview.h b/vs/sdl2/src/video/uikit/SDL_uikitopenglview.h index 15f1770a4a..d0eb0ac104 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitopenglview.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitopenglview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +19,7 @@ 3. This notice may not be removed or altered from any source distribution. */ -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) #import #import diff --git a/vs/sdl2/src/video/uikit/SDL_uikitopenglview.m b/vs/sdl2/src/video/uikit/SDL_uikitopenglview.m index 3e59f19bcf..145e8673fb 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitopenglview.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitopenglview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2) +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)) #include #include diff --git a/vs/sdl2/src/video/uikit/SDL_uikitvideo.h b/vs/sdl2/src/video/uikit/SDL_uikitvideo.h index 99e8b0fb2d..02a0110425 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitvideo.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitvideo.m b/vs/sdl2/src/video/uikit/SDL_uikitvideo.m index 8b16c23993..f3257ea3f5 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitvideo.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitvideo.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #import @@ -39,6 +39,7 @@ #include "SDL_uikitclipboard.h" #include "SDL_uikitvulkan.h" #include "SDL_uikitmetalview.h" +#include "SDL_uikitmessagebox.h" #define UIKITVID_DRIVER_NAME "uikit" @@ -99,7 +100,7 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) device->GetDisplayDPI = UIKit_GetDisplayDPI; device->GetWindowSizeInPixels = UIKit_GetWindowSizeInPixels; -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport; device->ShowScreenKeyboard = UIKit_ShowScreenKeyboard; device->HideScreenKeyboard = UIKit_HideScreenKeyboard; @@ -112,7 +113,7 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) device->HasClipboardText = UIKit_HasClipboardText; /* OpenGL (ES) functions */ -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) device->GL_MakeCurrent = UIKit_GL_MakeCurrent; device->GL_GetDrawableSize = UIKit_GL_GetDrawableSize; device->GL_SwapWindow = UIKit_GL_SwapWindow; @@ -123,7 +124,7 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) #endif device->free = UIKit_DeleteDevice; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = UIKit_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = UIKit_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions @@ -132,7 +133,7 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) device->Vulkan_GetDrawableSize = UIKit_Vulkan_GetDrawableSize; #endif -#if SDL_VIDEO_METAL +#ifdef SDL_VIDEO_METAL device->Metal_CreateView = UIKit_Metal_CreateView; device->Metal_DestroyView = UIKit_Metal_DestroyView; device->Metal_GetLayer = UIKit_Metal_GetLayer; @@ -147,7 +148,8 @@ static void UIKit_DeleteDevice(SDL_VideoDevice * device) VideoBootStrap UIKIT_bootstrap = { UIKITVID_DRIVER_NAME, "SDL UIKit video driver", - UIKit_CreateDevice + UIKit_CreateDevice, + UIKit_ShowMessageBox }; @@ -230,7 +232,7 @@ CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen) return frame; } -void UIKit_ForceUpdateHomeIndicator() +void UIKit_ForceUpdateHomeIndicator(void) { #if !TARGET_OS_TV /* Force the main SDL window to re-evaluate home indicator state */ diff --git a/vs/sdl2/src/video/uikit/SDL_uikitview.h b/vs/sdl2/src/video/uikit/SDL_uikitview.h index cdb2a4070b..c7fa8a8c31 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitview.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitview.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitview.m b/vs/sdl2/src/video/uikit/SDL_uikitview.m index b9c3326144..63afa0942b 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitview.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitview.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL_uikitview.h" @@ -38,7 +38,7 @@ #define MAX_MOUSE_BUTTONS 5 /* This is defined in SDL_sysjoystick.m */ -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED extern int SDL_AppleTVRemoteOpenedAsJoystick; #endif @@ -374,7 +374,7 @@ - (SDL_Scancode)scancodeFromPress:(UIPress*)press } #endif -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED /* Presses from Apple TV remote */ if (!SDL_AppleTVRemoteOpenedAsJoystick) { switch (press.type) { @@ -458,7 +458,7 @@ -(void)swipeGesture:(UISwipeGestureRecognizer *)gesture { /* Swipe gestures don't trigger begin states. */ if (gesture.state == UIGestureRecognizerStateEnded) { -#if !SDL_JOYSTICK_DISABLED +#ifndef SDL_JOYSTICK_DISABLED if (!SDL_AppleTVRemoteOpenedAsJoystick) { /* Send arrow key presses for now, as we don't have an external API * which better maps to swipe gestures. */ diff --git a/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.h b/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.h index 6fdcbecb03..660e11c4eb 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +33,11 @@ #define SDLRootViewController UIViewController #endif -#if SDL_IPHONE_KEYBOARD +@interface SDLUITextField : UITextField +- (BOOL)canPerformAction:(SEL)action withSender:(id)sender; +@end + +#ifdef SDL_IPHONE_KEYBOARD @interface SDL_uikitviewcontroller : SDLRootViewController #else @interface SDL_uikitviewcontroller : SDLRootViewController @@ -64,7 +68,7 @@ @property (nonatomic, assign) int homeIndicatorHidden; #endif -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD - (void)showKeyboard; - (void)hideKeyboard; - (void)initKeyboard; @@ -82,7 +86,7 @@ @end -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD SDL_bool UIKit_HasScreenKeyboardSupport(_THIS); void UIKit_ShowScreenKeyboard(_THIS, SDL_Window *window); void UIKit_HideScreenKeyboard(_THIS, SDL_Window *window); diff --git a/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.m b/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.m index b9ccf6b0f1..0d8052b7f0 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitviewcontroller.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL_video.h" #include "SDL_hints.h" @@ -64,14 +64,25 @@ } #endif +@implementation SDLUITextField : UITextField +- (BOOL)canPerformAction:(SEL)action withSender:(id)sender +{ + if (action == @selector(paste:)) { + return NO; + } + + return [super canPerformAction:action withSender:sender]; +} +@end + @implementation SDL_uikitviewcontroller { CADisplayLink *displayLink; int animationInterval; void (*animationCallback)(void*); void *animationCallbackParam; -#if SDL_IPHONE_KEYBOARD - UITextField *textField; +#ifdef SDL_IPHONE_KEYBOARD + SDLUITextField *textField; BOOL hardwareKeyboard; BOOL showingKeyboard; BOOL hidingKeyboard; @@ -88,7 +99,7 @@ - (instancetype)initWithSDLWindow:(SDL_Window *)_window if (self = [super initWithNibName:nil bundle:nil]) { self.window = _window; -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD [self initKeyboard]; hardwareKeyboard = NO; showingKeyboard = NO; @@ -113,7 +124,7 @@ - (instancetype)initWithSDLWindow:(SDL_Window *)_window - (void)dealloc { -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD [self deinitKeyboard]; #endif @@ -178,7 +189,7 @@ - (void)doLoop:(CADisplayLink*)sender /* Don't run the game loop while a messagebox is up */ if (!UIKit_ShowingMessageBox()) { /* See the comment in the function definition. */ -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) UIKit_GL_RestoreCurrentContext(); #endif @@ -249,7 +260,7 @@ - (BOOL)prefersPointerLocked /* ---- Keyboard related functionality below this line ---- */ -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD @synthesize textInputRect; @synthesize keyboardHeight; @@ -259,7 +270,7 @@ - (BOOL)prefersPointerLocked - (void)initKeyboard { obligateForBackspace = @" "; /* 64 space */ - textField = [[UITextField alloc] initWithFrame:CGRectZero]; + textField = [[SDLUITextField alloc] initWithFrame:CGRectZero]; textField.delegate = self; /* placeholder so there is something to delete! */ textField.text = obligateForBackspace; @@ -491,9 +502,11 @@ - (void)textFieldTextDidChange:(NSNotification *)notification - (void)updateKeyboard { + SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata; + CGAffineTransform t = self.view.transform; CGPoint offset = CGPointMake(0.0, 0.0); - CGRect frame = UIKit_ComputeViewFrame(window, self.view.window.screen); + CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); if (self.keyboardHeight) { int rectbottom = self.textInputRect.y + self.textInputRect.h; @@ -551,7 +564,7 @@ - (BOOL)textFieldShouldReturn:(UITextField*)_textField @end /* iPhone keyboard addition functions */ -#if SDL_IPHONE_KEYBOARD +#ifdef SDL_IPHONE_KEYBOARD static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window * window) { diff --git a/vs/sdl2/src/video/uikit/SDL_uikitvulkan.h b/vs/sdl2/src/video/uikit/SDL_uikitvulkan.h index d8dd9183da..fe558f91ae 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitvulkan.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_UIKIT +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_UIKIT) int UIKit_Vulkan_LoadLibrary(_THIS, const char *path); void UIKit_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/uikit/SDL_uikitvulkan.m b/vs/sdl2/src/video/uikit/SDL_uikitvulkan.m index 892de1e0c9..c0dfd29d2c 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitvulkan.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitvulkan.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_UIKIT +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_UIKIT) #include "SDL_uikitvideo.h" #include "SDL_uikitwindow.h" diff --git a/vs/sdl2/src/video/uikit/SDL_uikitwindow.h b/vs/sdl2/src/video/uikit/SDL_uikitwindow.h index 70fb0464fb..bf79ee159d 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitwindow.h +++ b/vs/sdl2/src/video/uikit/SDL_uikitwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/uikit/SDL_uikitwindow.m b/vs/sdl2/src/video/uikit/SDL_uikitwindow.m index d696179832..ff3cb859db 100644 --- a/vs/sdl2/src/video/uikit/SDL_uikitwindow.m +++ b/vs/sdl2/src/video/uikit/SDL_uikitwindow.m @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #include "SDL_hints.h" #include "SDL_mouse.h" @@ -114,14 +114,6 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo #if !TARGET_OS_TV if (displaydata.uiscreen == [UIScreen mainScreen]) { - /* SDL_CreateWindow sets the window w&h to the display's bounds if the - * fullscreen flag is set. But the display bounds orientation might not - * match what we want, and GetSupportedOrientations call below uses the - * window w&h. They're overridden below anyway, so we'll just set them - * to the requested size for the purposes of determining orientation. */ - window->w = window->windowed.w; - window->h = window->windowed.h; - NSUInteger orients = UIKit_GetSupportedOrientations(window); BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskPortraitUpsideDown)) != 0; @@ -392,7 +384,7 @@ SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) /* These struct members were added in SDL 2.0.4. */ if (versionnum >= SDL_VERSIONNUM(2,0,4)) { -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) if ([data.viewcontroller.view isKindOfClass:[SDL_uikitopenglview class]]) { SDL_uikitopenglview *glview = (SDL_uikitopenglview *)data.viewcontroller.view; info->info.uikit.framebuffer = glview.drawableFramebuffer; @@ -459,10 +451,10 @@ NSUInteger UIKit_GetSupportedOrientations(SDL_Window * window) } if (orientationMask == 0) { - if (window->w >= window->h) { + if (window->windowed.w >= window->windowed.h) { orientationMask |= UIInterfaceOrientationMaskLandscape; } - if (window->h >= window->w) { + if (window->windowed.h >= window->windowed.w) { orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); } } diff --git a/vs/sdl2/src/video/vita/SDL_vitaframebuffer.c b/vs/sdl2/src/video/vita/SDL_vitaframebuffer.c index 43b657bd36..56069b29cc 100644 --- a/vs/sdl2/src/video/vita/SDL_vitaframebuffer.c +++ b/vs/sdl2/src/video/vita/SDL_vitaframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #include "SDL_vitavideo.h" @@ -103,7 +103,7 @@ void VITA_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/vs/sdl2/src/video/vita/SDL_vitaframebuffer.h b/vs/sdl2/src/video/vita/SDL_vitaframebuffer.h index 8b0a53e61d..495d51b813 100644 --- a/vs/sdl2/src/video/vita/SDL_vitaframebuffer.h +++ b/vs/sdl2/src/video/vita/SDL_vitaframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitagl_pvr.c b/vs/sdl2/src/video/vita/SDL_vitagl_pvr.c index ea920ad5a2..5e148f967f 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagl_pvr.c +++ b/vs/sdl2/src/video/vita/SDL_vitagl_pvr.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR && SDL_VIDEO_VITA_PVR_OGL +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PVR) && defined(SDL_VIDEO_VITA_PVR_OGL) #include #include #include @@ -53,8 +53,8 @@ int VITA_GL_LoadLibrary(_THIS, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value - if (override != NULL) { + if (!skip_init) { // we don't care about actual value + if (override) { default_path = override; } diff --git a/vs/sdl2/src/video/vita/SDL_vitagl_pvr_c.h b/vs/sdl2/src/video/vita/SDL_vitagl_pvr_c.h index 33ee642ee9..fee3d30fb5 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagl_pvr_c.h +++ b/vs/sdl2/src/video/vita/SDL_vitagl_pvr_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitagles.c b/vs/sdl2/src/video/vita/SDL_vitagles.c index 89f29d36a7..1944112f7f 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagles.c +++ b/vs/sdl2/src/video/vita/SDL_vitagles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PIB +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PIB) #include #include diff --git a/vs/sdl2/src/video/vita/SDL_vitagles_c.h b/vs/sdl2/src/video/vita/SDL_vitagles_c.h index 4e4545b785..6dcc651472 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagles_c.h +++ b/vs/sdl2/src/video/vita/SDL_vitagles_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitagles_pvr.c b/vs/sdl2/src/video/vita/SDL_vitagles_pvr.c index 711d1ddd34..cf917af720 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagles_pvr.c +++ b/vs/sdl2/src/video/vita/SDL_vitagles_pvr.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PVR) #include #include #include @@ -42,9 +42,9 @@ int VITA_GLES_LoadLibrary(_THIS, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value + if (!skip_init) { // we don't care about actual value - if (override != NULL) { + if (override) { default_path = override; } diff --git a/vs/sdl2/src/video/vita/SDL_vitagles_pvr_c.h b/vs/sdl2/src/video/vita/SDL_vitagles_pvr_c.h index 6cf2fa4c6e..2815057b1e 100644 --- a/vs/sdl2/src/video/vita/SDL_vitagles_pvr_c.h +++ b/vs/sdl2/src/video/vita/SDL_vitagles_pvr_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitakeyboard.c b/vs/sdl2/src/video/vita/SDL_vitakeyboard.c index 56be9e6fa6..038e0ff37f 100644 --- a/vs/sdl2/src/video/vita/SDL_vitakeyboard.c +++ b/vs/sdl2/src/video/vita/SDL_vitakeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #include #include @@ -50,7 +50,7 @@ void VITA_InitKeyboard(void) void VITA_PollKeyboard(void) { // We skip polling keyboard if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/vs/sdl2/src/video/vita/SDL_vitakeyboard.h b/vs/sdl2/src/video/vita/SDL_vitakeyboard.h index fd0f13734e..3ea646592e 100644 --- a/vs/sdl2/src/video/vita/SDL_vitakeyboard.h +++ b/vs/sdl2/src/video/vita/SDL_vitakeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitamessagebox.c b/vs/sdl2/src/video/vita/SDL_vitamessagebox.c index 358271349e..6811748c80 100644 --- a/vs/sdl2/src/video/vita/SDL_vitamessagebox.c +++ b/vs/sdl2/src/video/vita/SDL_vitamessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #include "SDL_vitavideo.h" #include "SDL_vitamessagebox.h" diff --git a/vs/sdl2/src/video/vita/SDL_vitamessagebox.h b/vs/sdl2/src/video/vita/SDL_vitamessagebox.h index f119275b66..15aeb6d1ee 100644 --- a/vs/sdl2/src/video/vita/SDL_vitamessagebox.h +++ b/vs/sdl2/src/video/vita/SDL_vitamessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #ifndef SDL_vitamessagebox_h_ #define SDL_vitamessagebox_h_ -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA extern int VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/vita/SDL_vitamouse.c b/vs/sdl2/src/video/vita/SDL_vitamouse.c index b14690fc2a..47fa095bbf 100644 --- a/vs/sdl2/src/video/vita/SDL_vitamouse.c +++ b/vs/sdl2/src/video/vita/SDL_vitamouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #include #include @@ -45,7 +45,7 @@ void VITA_InitMouse(void) void VITA_PollMouse(void) { // We skip polling mouse if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/vs/sdl2/src/video/vita/SDL_vitamouse_c.h b/vs/sdl2/src/video/vita/SDL_vitamouse_c.h index b676a7084d..281a611cc7 100644 --- a/vs/sdl2/src/video/vita/SDL_vitamouse_c.h +++ b/vs/sdl2/src/video/vita/SDL_vitamouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitatouch.c b/vs/sdl2/src/video/vita/SDL_vitatouch.c index 87939b322a..07cbedebec 100644 --- a/vs/sdl2/src/video/vita/SDL_vitatouch.c +++ b/vs/sdl2/src/video/vita/SDL_vitatouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #include #include @@ -86,7 +86,7 @@ void VITA_PollTouch(void) int port; // We skip polling touch if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/vs/sdl2/src/video/vita/SDL_vitatouch.h b/vs/sdl2/src/video/vita/SDL_vitatouch.h index d48999cdc4..29369dcea6 100644 --- a/vs/sdl2/src/video/vita/SDL_vitatouch.h +++ b/vs/sdl2/src/video/vita/SDL_vitatouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/vita/SDL_vitavideo.c b/vs/sdl2/src/video/vita/SDL_vitavideo.c index 9e823996e0..9b8839d2c9 100644 --- a/vs/sdl2/src/video/vita/SDL_vitavideo.c +++ b/vs/sdl2/src/video/vita/SDL_vitavideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA /* SDL internals */ #include "../SDL_sysvideo.h" @@ -39,6 +39,7 @@ #include "SDL_vitakeyboard.h" #include "SDL_vitamouse_c.h" #include "SDL_vitaframebuffer.h" +#include "SDL_vitamessagebox.h" #if defined(SDL_VIDEO_VITA_PIB) #include "SDL_vitagles_c.h" @@ -71,27 +72,27 @@ static SDL_VideoDevice *VITA_Create() { SDL_VideoDevice *device; SDL_VideoData *phdata; -#if SDL_VIDEO_VITA_PIB +#ifdef SDL_VIDEO_VITA_PIB SDL_GLDriverData *gldata; #endif /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal VITA specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; } -#if SDL_VIDEO_VITA_PIB +#ifdef SDL_VIDEO_VITA_PIB gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -175,7 +176,8 @@ static SDL_VideoDevice *VITA_Create() VideoBootStrap VITA_bootstrap = { "VITA", "VITA Video Driver", - VITA_Create + VITA_Create, + VITA_ShowMessageBox }; /*****************************************************************************/ @@ -258,7 +260,7 @@ int VITA_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -266,7 +268,7 @@ int VITA_CreateWindow(_THIS, SDL_Window *window) window->driverdata = wdata; // Vita can only have one window - if (Vita_Window != NULL) { + if (Vita_Window) { return SDL_SetError("Only one window supported"); } diff --git a/vs/sdl2/src/video/vita/SDL_vitavideo.h b/vs/sdl2/src/video/vita/SDL_vitavideo.h index bafee68f37..5f23459160 100644 --- a/vs/sdl2/src/video/vita/SDL_vitavideo.h +++ b/vs/sdl2/src/video/vita/SDL_vitavideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +86,7 @@ void VITA_DestroyWindow(_THIS, SDL_Window *window); SDL_bool VITA_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); -#if SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_DRIVER_VITA #if defined(SDL_VIDEO_VITA_PVR_OGL) /* OpenGL functions */ int VITA_GL_LoadLibrary(_THIS, const char *path); diff --git a/vs/sdl2/src/video/vivante/SDL_vivanteopengles.c b/vs/sdl2/src/video/vivante/SDL_vivanteopengles.c index 9d9c6388b8..e088cf470f 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivanteopengles.c +++ b/vs/sdl2/src/video/vivante/SDL_vivanteopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_vivanteopengles.h" #include "SDL_vivantevideo.h" diff --git a/vs/sdl2/src/video/vivante/SDL_vivanteopengles.h b/vs/sdl2/src/video/vivante/SDL_vivanteopengles.h index 8e420a1a5f..7dc55c2232 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivanteopengles.h +++ b/vs/sdl2/src/video/vivante/SDL_vivanteopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_vivanteopengles_h_ #define SDL_vivanteopengles_h_ -#if SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL) #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/vivante/SDL_vivanteplatform.c b/vs/sdl2/src/video/vivante/SDL_vivanteplatform.c index 8d3aff3df4..cf4b5ac457 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivanteplatform.c +++ b/vs/sdl2/src/video/vivante/SDL_vivanteplatform.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VIVANTE +#ifdef SDL_VIDEO_DRIVER_VIVANTE #include "SDL_vivanteplatform.h" diff --git a/vs/sdl2/src/video/vivante/SDL_vivanteplatform.h b/vs/sdl2/src/video/vivante/SDL_vivanteplatform.h index 69ce9bd1fe..19e8e3e602 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivanteplatform.h +++ b/vs/sdl2/src/video/vivante/SDL_vivanteplatform.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_vivanteplatform_h_ #define SDL_vivanteplatform_h_ -#if SDL_VIDEO_DRIVER_VIVANTE +#ifdef SDL_VIDEO_DRIVER_VIVANTE #include "SDL_vivantevideo.h" diff --git a/vs/sdl2/src/video/vivante/SDL_vivantevideo.c b/vs/sdl2/src/video/vivante/SDL_vivantevideo.c index aaf645c459..a501f65b60 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivantevideo.c +++ b/vs/sdl2/src/video/vivante/SDL_vivantevideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_VIVANTE +#ifdef SDL_VIDEO_DRIVER_VIVANTE /* SDL internals */ #include "../SDL_sysvideo.h" @@ -41,7 +41,7 @@ static void VIVANTE_Destroy(SDL_VideoDevice *device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } @@ -54,14 +54,14 @@ static SDL_VideoDevice *VIVANTE_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -89,7 +89,7 @@ static SDL_VideoDevice *VIVANTE_Create() device->DestroyWindow = VIVANTE_DestroyWindow; device->GetWindowWMInfo = VIVANTE_GetWindowWMInfo; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary; device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress; device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary; @@ -101,7 +101,7 @@ static SDL_VideoDevice *VIVANTE_Create() device->GL_DeleteContext = VIVANTE_GLES_DeleteContext; #endif -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = VIVANTE_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = VIVANTE_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = VIVANTE_Vulkan_GetInstanceExtensions; @@ -116,7 +116,8 @@ static SDL_VideoDevice *VIVANTE_Create() VideoBootStrap VIVANTE_bootstrap = { "vivante", "Vivante EGL Video Driver", - VIVANTE_Create + VIVANTE_Create, + NULL /* no ShowMessageBox implementation */ }; /*****************************************************************************/ @@ -133,12 +134,12 @@ static int VIVANTE_AddVideoDisplays(_THIS) unsigned long pixels = 0; data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } SDL_zero(current_mode); -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK data->native_display = vdkGetDisplay(videodata->vdk_private); vdkGetDisplayInfo(data->native_display, ¤t_mode.w, ¤t_mode.h, &pixels, &pitch, &bpp); @@ -173,7 +174,7 @@ int VIVANTE_VideoInit(_THIS) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK videodata->vdk_private = vdkInitialize(); if (!videodata->vdk_private) { return SDL_SetError("vdkInitialize() failed"); @@ -231,7 +232,7 @@ void VIVANTE_VideoQuit(_THIS) VIVANTE_CleanupPlatform(_this); -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK if (videodata->vdk_private) { vdkExit(videodata->vdk_private); videodata->vdk_private = NULL; @@ -265,14 +266,14 @@ int VIVANTE_CreateWindow(_THIS, SDL_Window *window) /* Allocate window internal data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } /* Setup driver data for this window */ window->driverdata = data; -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); #else data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); @@ -281,7 +282,7 @@ int VIVANTE_CreateWindow(_THIS, SDL_Window *window) return SDL_SetError("VIVANTE: Can't create native window"); } -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (window->flags & SDL_WINDOW_OPENGL) { data->egl_surface = SDL_EGL_CreateSurface(_this, data->native_window); if (data->egl_surface == EGL_NO_SURFACE) { @@ -303,14 +304,14 @@ void VIVANTE_DestroyWindow(_THIS, SDL_Window *window) data = window->driverdata; if (data) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface != EGL_NO_SURFACE) { SDL_EGL_DestroySurface(_this, data->egl_surface); } #endif if (data->native_window) { -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK vdkDestroyWindow(data->native_window); #else videodata->fbDestroyWindow(data->native_window); @@ -324,7 +325,7 @@ void VIVANTE_DestroyWindow(_THIS, SDL_Window *window) void VIVANTE_SetWindowTitle(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; vdkSetWindowTitle(data->native_window, window->title); #endif @@ -342,7 +343,7 @@ void VIVANTE_SetWindowSize(_THIS, SDL_Window *window) void VIVANTE_ShowWindow(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; vdkShowWindow(data->native_window); #endif @@ -352,10 +353,12 @@ void VIVANTE_ShowWindow(_THIS, SDL_Window *window) void VIVANTE_HideWindow(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK SDL_WindowData *data = window->driverdata; vdkHideWindow(data->native_window); #endif + SDL_SetMouseFocus(NULL); + SDL_SetKeyboardFocus(NULL); } /*****************************************************************************/ diff --git a/vs/sdl2/src/video/vivante/SDL_vivantevideo.h b/vs/sdl2/src/video/vivante/SDL_vivantevideo.h index f68f0f9254..03dcb7e9ed 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivantevideo.h +++ b/vs/sdl2/src/video/vivante/SDL_vivantevideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_egl.h" -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK #include #else #include @@ -35,7 +35,7 @@ typedef struct SDL_VideoData { -#if SDL_VIDEO_DRIVER_VIVANTE_VDK +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK vdkPrivate vdk_private; #else void *egl_handle; /* EGL shared library handle */ diff --git a/vs/sdl2/src/video/vivante/SDL_vivantevulkan.c b/vs/sdl2/src/video/vivante/SDL_vivantevulkan.c index 8e4c867c64..ce1e80cad0 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivantevulkan.c +++ b/vs/sdl2/src/video/vivante/SDL_vivantevulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_VIVANTE +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE) #include "SDL_vivantevideo.h" @@ -47,10 +47,10 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { /* If no path set, try Vivante fb vulkan driver explicitly */ path = "libvulkan-fb.so"; _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -84,7 +84,7 @@ int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/vs/sdl2/src/video/vivante/SDL_vivantevulkan.h b/vs/sdl2/src/video/vivante/SDL_vivantevulkan.h index 1b0500c215..4fb6964183 100644 --- a/vs/sdl2/src/video/vivante/SDL_vivantevulkan.h +++ b/vs/sdl2/src/video/vivante/SDL_vivantevulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_VIVANTE +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE) int VIVANTE_Vulkan_LoadLibrary(_THIS, const char *path); void VIVANTE_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/wayland/SDL_waylandclipboard.c b/vs/sdl2/src/video/wayland/SDL_waylandclipboard.c index bf4dca44a0..fc3d285cfb 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandclipboard.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "SDL_waylanddatamanager.h" #include "SDL_waylandevents_c.h" @@ -33,11 +33,11 @@ int Wayland_SetClipboardText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; if (text[0] != '\0') { SDL_WaylandDataSource *source = Wayland_data_source_create(_this); @@ -64,11 +64,11 @@ int Wayland_SetPrimarySelectionText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; if (text[0] != '\0') { SDL_WaylandPrimarySelectionSource *source = Wayland_primary_selection_source_create(_this); @@ -97,11 +97,11 @@ char *Wayland_GetClipboardText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; /* Prefer own selection, if not canceled */ if (Wayland_data_source_has_mime( @@ -116,7 +116,7 @@ char *Wayland_GetClipboardText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -131,11 +131,11 @@ char *Wayland_GetPrimarySelectionText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; /* Prefer own selection, if not canceled */ if (Wayland_primary_selection_source_has_mime( @@ -150,7 +150,7 @@ char *Wayland_GetPrimarySelectionText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -163,11 +163,11 @@ SDL_bool Wayland_HasClipboardText(_THIS) SDL_WaylandDataDevice *data_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; result = result || Wayland_data_source_has_mime(data_device->selection_source, TEXT_MIME) || @@ -183,11 +183,11 @@ SDL_bool Wayland_HasPrimarySelectionText(_THIS) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; result = result || Wayland_primary_selection_source_has_mime( diff --git a/vs/sdl2/src/video/wayland/SDL_waylandclipboard.h b/vs/sdl2/src/video/wayland/SDL_waylandclipboard.h index 67e27d961b..012bf82220 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandclipboard.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.c b/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.c index 3d580ce6c9..8839e235c9 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.c +++ b/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include #include @@ -55,7 +55,7 @@ static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_ sigemptyset(&sig_set); sigaddset(&sig_set, SIGPIPE); -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED sigprocmask(SIG_BLOCK, &sig_set, &old_sig_set); #else pthread_sigmask(SIG_BLOCK, &sig_set, &old_sig_set); @@ -77,7 +77,7 @@ static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_ sigtimedwait(&sig_set, 0, &zerotime); -#if SDL_THREADS_DISABLED +#ifdef SDL_THREADS_DISABLED sigprocmask(SIG_SETMASK, &old_sig_set, NULL); #else pthread_sigmask(SIG_SETMASK, &old_sig_set, NULL); @@ -115,13 +115,13 @@ static ssize_t read_pipe(int fd, void **buffer, size_t *total_length, SDL_bool n new_buffer_length = *total_length; } - if (*buffer == NULL) { + if (!*buffer) { output_buffer = SDL_malloc(new_buffer_length); } else { output_buffer = SDL_realloc(*buffer, new_buffer_length); } - if (output_buffer == NULL) { + if (!output_buffer) { bytes_read = SDL_OutOfMemory(); } else { SDL_memcpy((Uint8 *)output_buffer + pos, temp, bytes_read); @@ -186,9 +186,9 @@ static int mime_data_list_add(struct wl_list *list, SDL_MimeDataList *mime_data = NULL; void *internal_buffer = NULL; - if (buffer != NULL) { + if (buffer) { internal_buffer = SDL_malloc(length); - if (internal_buffer == NULL) { + if (!internal_buffer) { return SDL_OutOfMemory(); } SDL_memcpy(internal_buffer, buffer, length); @@ -196,16 +196,16 @@ static int mime_data_list_add(struct wl_list *list, mime_data = mime_data_list_find(list, mime_type); - if (mime_data == NULL) { + if (!mime_data) { mime_data = SDL_calloc(1, sizeof(*mime_data)); - if (mime_data == NULL) { + if (!mime_data) { status = SDL_OutOfMemory(); } else { WAYLAND_wl_list_insert(list, &(mime_data->link)); mime_type_length = SDL_strlen(mime_type) + 1; mime_data->mime_type = SDL_malloc(mime_type_length); - if (mime_data->mime_type == NULL) { + if (!mime_data->mime_type) { status = SDL_OutOfMemory(); } else { SDL_memcpy(mime_data->mime_type, mime_type, mime_type_length); @@ -213,8 +213,8 @@ static int mime_data_list_add(struct wl_list *list, } } - if (mime_data != NULL && buffer != NULL && length > 0) { - if (mime_data->data != NULL) { + if (mime_data && buffer && length > 0) { + if (mime_data->data) { SDL_free(mime_data->data); } mime_data->data = internal_buffer; @@ -233,10 +233,10 @@ static void mime_data_list_free(struct wl_list *list) wl_list_for_each_safe(mime_data, next, list, link) { - if (mime_data->data != NULL) { + if (mime_data->data) { SDL_free(mime_data->data); } - if (mime_data->mime_type != NULL) { + if (mime_data->mime_type) { SDL_free(mime_data->mime_type); } SDL_free(mime_data); @@ -248,7 +248,7 @@ static ssize_t Wayland_source_send(SDL_MimeDataList *mime_data, const char *mime size_t written_bytes = 0; ssize_t status = 0; - if (mime_data == NULL || mime_data->data == NULL) { + if (!mime_data || !mime_data->data) { status = SDL_SetError("Invalid mime type"); close(fd); } else { @@ -306,7 +306,7 @@ SDL_bool Wayland_data_source_has_mime(SDL_WaylandDataSource *source, { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -317,7 +317,7 @@ SDL_bool Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSo { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -329,14 +329,14 @@ static void *Wayland_source_get_data(SDL_MimeDataList *mime_data, { void *buffer = NULL; - if (mime_data != NULL && mime_data->length > 0) { + if (mime_data && mime_data->length > 0) { size_t buffer_length = mime_data->length; if (null_terminate == SDL_TRUE) { ++buffer_length; } buffer = SDL_malloc(buffer_length); - if (buffer == NULL) { + if (!buffer) { *length = SDL_OutOfMemory(); } else { *length = mime_data->length; @@ -358,7 +358,7 @@ void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, void *buffer = NULL; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid data source"); } else { mime_data = mime_data_list_find(&source->mimes, mime_type); @@ -376,7 +376,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc void *buffer = NULL; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid primary selection source"); } else { mime_data = mime_data_list_find(&source->mimes, mime_type); @@ -388,7 +388,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc void Wayland_data_source_destroy(SDL_WaylandDataSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *)source->data_device; if (data_device && (data_device->selection_source == source)) { data_device->selection_source = NULL; @@ -401,7 +401,7 @@ void Wayland_data_source_destroy(SDL_WaylandDataSource *source) void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *)source->primary_selection_device; if (primary_selection_device && (primary_selection_device->selection_source == source)) { primary_selection_device->selection_source = NULL; @@ -422,12 +422,12 @@ void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } data_device = offer->data_device; - if (data_device == NULL) { + if (!data_device) { SDL_SetError("Data device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -456,12 +456,12 @@ void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer * void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } primary_selection_device = offer->primary_selection_device; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { SDL_SetError("Primary selection device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -497,7 +497,7 @@ SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -508,7 +508,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -516,7 +516,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) { - if (offer != NULL) { + if (offer) { wl_data_offer_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -525,7 +525,7 @@ void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) { - if (offer != NULL) { + if (offer) { zwp_primary_selection_offer_v1_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -536,9 +536,9 @@ int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) { int status = 0; - if (data_device == NULL || data_device->data_device == NULL) { + if (!data_device || !data_device->data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (data_device->selection_source != NULL) { + } else if (data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, NULL, 0); Wayland_data_source_destroy(data_device->selection_source); data_device->selection_source = NULL; @@ -550,9 +550,9 @@ int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelection { int status = 0; - if (primary_selection_device == NULL || primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device || !primary_selection_device->primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (primary_selection_device->selection_source != NULL) { + } else if (primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, NULL, 0); Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); @@ -568,9 +568,9 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, size_t num_offers = 0; size_t index = 0; - if (data_device == NULL) { + if (!data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { SDL_MimeDataList *mime_data = NULL; @@ -601,7 +601,7 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, source->source, data_device->selection_serial); } - if (data_device->selection_source != NULL) { + if (data_device->selection_source) { Wayland_data_source_destroy(data_device->selection_source); } data_device->selection_source = source; @@ -619,9 +619,9 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe size_t num_offers = 0; size_t index = 0; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { SDL_MimeDataList *mime_data = NULL; @@ -652,7 +652,7 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe source->source, primary_selection_device->selection_serial); } - if (primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_source) { Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); } primary_selection_device->selection_source = source; @@ -667,11 +667,11 @@ int Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, uint32_t serial) { int status = -1; - if (data_device != NULL) { + if (data_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (data_device->selection_serial == 0 && data_device->selection_source != NULL) { + if (data_device->selection_serial == 0 && data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, data_device->selection_source->source, data_device->selection_serial); @@ -687,11 +687,11 @@ int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevic uint32_t serial) { int status = -1; - if (primary_selection_device != NULL) { + if (primary_selection_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, primary_selection_device->selection_source->source, primary_selection_device->selection_serial); diff --git a/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.h b/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.h index 7f0cb7e5ad..496de21dfd 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.h +++ b/vs/sdl2/src/video/wayland/SDL_waylanddatamanager.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +29,7 @@ #define TEXT_MIME "text/plain;charset=utf-8" #define FILE_MIME "text/uri-list" +#define FILE_PORTAL_MIME "application/vnd.portal.filetransfer" typedef struct { diff --git a/vs/sdl2/src/video/wayland/SDL_waylanddyn.c b/vs/sdl2/src/video/wayland/SDL_waylanddyn.c index a8223b2fc7..f7d501ac7f 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylanddyn.c +++ b/vs/sdl2/src/video/wayland/SDL_waylanddyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #define DEBUG_DYNAMIC_WAYLAND 0 @@ -37,48 +37,45 @@ typedef struct const char *libname; } waylanddynlib; -#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL -#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL NULL -#endif -#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR -#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR NULL -#endif -#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON -#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON NULL -#endif -#ifndef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR -#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR NULL -#endif - static waylanddynlib waylandlibs[] = { { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC }, +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL }, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR }, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON }, - { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR } +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR }, +#endif + { NULL, NULL } }; static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool required) { - int i; void *fn = NULL; - for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].lib != NULL) { - fn = SDL_LoadFunction(waylandlibs[i].lib, fnname); - if (fn != NULL) { + waylanddynlib *dynlib; + for (dynlib = waylandlibs; dynlib->libname; dynlib++) { + if (dynlib->lib) { + fn = SDL_LoadFunction(dynlib->lib, fnname); + if (fn) { break; } } } #if DEBUG_DYNAMIC_WAYLAND - if (fn != NULL) - SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, waylandlibs[i].libname, fn); - else + if (fn) { + SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, dynlib->libname, fn); + } else { SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname); + } #endif - if (fn == NULL && required) { + if (!fn && required) { *pHasModule = 0; /* kill this module. */ } @@ -118,7 +115,7 @@ void SDL_WAYLAND_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].lib != NULL) { + if (waylandlibs[i].lib) { SDL_UnloadObject(waylandlibs[i].lib); waylandlibs[i].lib = NULL; } @@ -139,7 +136,7 @@ int SDL_WAYLAND_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].libname != NULL) { + if (waylandlibs[i].libname) { waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname); } } diff --git a/vs/sdl2/src/video/wayland/SDL_waylanddyn.h b/vs/sdl2/src/video/wayland/SDL_waylanddyn.h index 36f4fde041..6feb343912 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylanddyn.h +++ b/vs/sdl2/src/video/wayland/SDL_waylanddyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylandevents.c b/vs/sdl2/src/video/wayland/SDL_waylandevents.c index 160185ffc1..9e9c393402 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandevents.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "SDL_stdinc.h" #include "SDL_timer.h" @@ -163,6 +163,21 @@ static void touch_del(SDL_TouchID id, wl_fixed_t *x, wl_fixed_t *y, struct wl_su } } +static SDL_bool Wayland_SurfaceHasActiveTouches(struct wl_surface *surface) +{ + struct SDL_WaylandTouchPoint *tp = touch_points.head; + + while (tp) { + if (tp->surface == surface) { + return SDL_TRUE; + } + + tp = tp->next; + } + + return SDL_FALSE; +} + /* Returns SDL_TRUE if a key repeat event was due */ static SDL_bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t elapsed) { @@ -269,7 +284,7 @@ int Wayland_WaitEventTimeout(_THIS, int timeout) WAYLAND_wl_display_flush(d->display); #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -338,7 +353,7 @@ void Wayland_PumpEvents(_THIS) int err; #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -410,7 +425,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer, struct SDL_WaylandInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -448,12 +463,17 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, { struct SDL_WaylandInput *input = data; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } if (input->pointer_focus) { - SDL_SetMouseFocus(NULL); + /* A pointer leave event may be emitted if the compositor hides the pointer in response to receiving a touch event. + * Don't relinquish focus if the surface has active touches, as the compositor is just transitioning from mouse to touch mode. + */ + if (!Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } input->pointer_focus = NULL; } } @@ -820,6 +840,8 @@ static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t seri const float x = dblx / window_data->sdlwindow->w; const float y = dbly / window_data->sdlwindow->h; + SDL_SetMouseFocus(window_data->sdlwindow); + SDL_SendTouch((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id, window_data->sdlwindow, SDL_TRUE, x, y, 1.0f); } @@ -829,6 +851,7 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial uint32_t timestamp, int id) { wl_fixed_t fx = 0, fy = 0; + struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; struct wl_surface *surface = NULL; touch_del(id, &fx, &fy, &surface); @@ -844,6 +867,14 @@ static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial SDL_SendTouch((SDL_TouchID)(intptr_t)touch, (SDL_FingerID)id, window_data->sdlwindow, SDL_FALSE, x, y, 1.0f); + + /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window curently + * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost. + */ + if (!input->pointer_focus && input->keyboard_focus != window_data && + SDL_GetMouseFocus() == window_data->sdlwindow && !Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } } } } @@ -947,7 +978,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, char *map_str; const char *locale; - if (data == NULL) { + if (!data) { close(fd); return; } @@ -963,6 +994,13 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, return; } + if (input->xkb.keymap != NULL) { + /* if there's already a keymap loaded, throw it away rather than leaking it before + * parsing the new one + */ + WAYLAND_xkb_keymap_unref(input->xkb.keymap); + input->xkb.keymap = NULL; + } input->xkb.keymap = WAYLAND_xkb_keymap_new_from_string(input->display->xkb_context, map_str, XKB_KEYMAP_FORMAT_TEXT_V1, @@ -985,6 +1023,13 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, input->xkb.idx_caps = 1 << GET_MOD_INDEX(CAPS); #undef GET_MOD_INDEX + if (input->xkb.state != NULL) { + /* if there's already a state, throw it away rather than leaking it before + * trying to create a new one with the new keymap. + */ + WAYLAND_xkb_state_unref(input->xkb.state); + input->xkb.state = NULL; + } input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap); if (!input->xkb.state) { SDL_SetError("failed to create XKB state\n"); @@ -1019,21 +1064,29 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, /* Look up the preferred locale, falling back to "C" as default */ locale = SDL_getenv("LC_ALL"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LC_CTYPE"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LANG"); - if (locale == NULL) { + if (!locale) { locale = "C"; } } } /* Set up XKB compose table */ + if (input->xkb.compose_table != NULL) { + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + input->xkb.compose_table = NULL; + } 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 */ + if (input->xkb.compose_state != NULL) { + WAYLAND_xkb_compose_state_unref(input->xkb.compose_state); + input->xkb.compose_state = NULL; + } input->xkb.compose_state = WAYLAND_xkb_compose_state_new(input->xkb.compose_table, XKB_COMPOSE_STATE_NO_FLAGS); if (!input->xkb.compose_state) { @@ -1087,7 +1140,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, SDL_WindowData *window; uint32_t *key; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -1113,7 +1166,8 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, const SDL_Scancode scancode = Wayland_get_scancode_from_key(input, *key + 8); if (scancode != SDL_SCANCODE_UNKNOWN) { - for (uint32_t i = 0; i < SDL_arraysize(mod_scancodes); ++i) { + uint32_t i; + for (i = 0; i < SDL_arraysize(mod_scancodes); ++i) { if (mod_scancodes[i] == scancode) { SDL_SendKeyboardKey(SDL_PRESSED, scancode); break; @@ -1127,15 +1181,18 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface) { struct SDL_WaylandInput *input = data; - SDL_WindowData *window; + SDL_WindowData *wind; + SDL_Window *window = NULL; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } - window = wl_surface_get_user_data(surface); - if (window) { - window->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; + wind = wl_surface_get_user_data(surface); + if (wind) { + wind->keyboard_device = NULL; + window = wind->sdlwindow; + window->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; } /* Stop key repeat before clearing keyboard focus */ @@ -1143,12 +1200,20 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, /* This will release any keys still pressed */ SDL_SetKeyboardFocus(NULL); + input->keyboard_focus = NULL; #ifdef SDL_USE_IME if (!input->text_input) { SDL_IME_SetFocus(SDL_FALSE); } #endif + + /* If the surface had a pointer leave event while still having active touch events, it retained mouse focus. + * Clear it now if all touch events are raised. + */ + if (!input->pointer_focus && SDL_GetMouseFocus() == window && !Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } } static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, Uint8 state, SDL_bool *handled_by_ime) @@ -1157,7 +1222,7 @@ static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandIn const xkb_keysym_t *syms; xkb_keysym_t sym; - if (window == NULL || window->keyboard_device != input || !input->xkb.state) { + if (!window || window->keyboard_device != input || !input->xkb.state) { return SDL_FALSE; } @@ -1233,10 +1298,11 @@ static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, SDL_SendKeyboardKey(state == WL_KEYBOARD_KEY_STATE_PRESSED ? SDL_PRESSED : SDL_RELEASED, scancode); } + Wayland_data_device_set_serial(input->data_device, serial); + Wayland_primary_selection_device_set_serial(input->primary_selection_device, serial); + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { if (has_text && !(SDL_GetModState() & KMOD_CTRL)) { - Wayland_data_device_set_serial(input->data_device, serial); - Wayland_primary_selection_device_set_serial(input->primary_selection_device, serial); if (!handled_by_ime) { SDL_SendKeyboardText(text); } @@ -1256,6 +1322,12 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, Wayland_Keymap keymap; const uint32_t modstate = (mods_depressed | mods_latched | mods_locked); + if (input->xkb.state == NULL) { + /* if we get a modifier notification before the keymap, there's nothing we can do with the information + */ + return; + } + WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); @@ -1426,21 +1498,21 @@ SDL_WaylandDataSource *Wayland_data_source_create(_THIS) SDL_VideoData *driver_data = NULL; struct wl_data_source *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->data_device_manager != NULL) { + if (driver_data->data_device_manager) { id = wl_data_device_manager_create_data_source( driver_data->data_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create data source"); } else { data_source = SDL_calloc(1, sizeof(*data_source)); - if (data_source == NULL) { + if (!data_source) { SDL_OutOfMemory(); wl_data_source_destroy(id); } else { @@ -1461,21 +1533,21 @@ SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(_THIS SDL_VideoData *driver_data = NULL; struct zwp_primary_selection_source_v1 *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->primary_selection_device_manager != NULL) { + if (driver_data->primary_selection_device_manager) { id = zwp_primary_selection_device_manager_v1_create_source( driver_data->primary_selection_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create primary selection source"); } else { primary_selection_source = SDL_calloc(1, sizeof(*primary_selection_source)); - if (primary_selection_source == NULL) { + if (!primary_selection_source) { SDL_OutOfMemory(); zwp_primary_selection_source_v1_destroy(id); } else { @@ -1529,7 +1601,7 @@ static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_ SDL_WaylandDataOffer *data_offer = NULL; data_offer = SDL_calloc(1, sizeof(*data_offer)); - if (data_offer == NULL) { + if (!data_offer) { SDL_OutOfMemory(); } else { data_offer->offer = id; @@ -1550,20 +1622,27 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ data_device->drag_serial = serial; - if (id != NULL) { + if (id) { data_device->drag_offer = wl_data_offer_get_user_data(id); /* TODO: SDL Support more mime types */ - has_mime = Wayland_data_offer_has_mime( - data_device->drag_offer, FILE_MIME); - - /* If drag_mime is NULL this will decline the offer */ - wl_data_offer_accept(id, serial, - (has_mime == SDL_TRUE) ? FILE_MIME : NULL); +#ifdef SDL_USE_LIBDBUS + if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { + has_mime = SDL_TRUE; + wl_data_offer_accept(id, serial, FILE_PORTAL_MIME); + } +#endif + if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_MIME)) { + has_mime = SDL_TRUE; + wl_data_offer_accept(id, serial, FILE_MIME); + } /* SDL only supports "copy" style drag and drop */ - if (has_mime == SDL_TRUE) { + if (has_mime) { dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; + } else { + /* drag_mime is NULL this will decline the offer */ + wl_data_offer_accept(id, serial, NULL); } if (wl_data_offer_get_version(data_device->drag_offer->offer) >= 3) { wl_data_offer_set_actions(data_device->drag_offer->offer, @@ -1583,11 +1662,10 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) { SDL_WaylandDataDevice *data_device = data; - SDL_WaylandDataOffer *offer = NULL; - if (data_device->selection_offer != NULL) { - data_device->selection_offer = NULL; - Wayland_data_offer_destroy(offer); + if (data_device->drag_offer) { + Wayland_data_offer_destroy(data_device->drag_offer); + data_device->drag_offer = NULL; } } @@ -1615,7 +1693,7 @@ static int Wayland_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -1693,7 +1771,7 @@ static char *Wayland_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -1721,24 +1799,65 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL) { + if (data_device->drag_offer) { /* TODO: SDL Support more mime types */ size_t length; - void *buffer = Wayland_data_offer_receive(data_device->drag_offer, - &length, FILE_MIME, SDL_TRUE); - if (buffer) { - char *saveptr = NULL; - char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); - while (token != NULL) { - char *fn = Wayland_URIToLocal(token); - if (fn) { - SDL_SendDropFile(data_device->dnd_window, fn); + SDL_bool drop_handled = SDL_FALSE; +#ifdef SDL_USE_LIBDBUS + if (Wayland_data_offer_has_mime( + data_device->drag_offer, FILE_PORTAL_MIME)) { + void *buffer = Wayland_data_offer_receive(data_device->drag_offer, + &length, FILE_PORTAL_MIME, SDL_TRUE); + if (buffer) { + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + if (dbus) { + int path_count = 0; + char **paths = SDL_DBus_DocumentsPortalRetrieveFiles(buffer, &path_count); + /* If dropped files contain a directory the list is empty */ + if (paths && path_count > 0) { + int i; + for (i = 0; i < path_count; i++) { + SDL_SendDropFile(data_device->dnd_window, paths[i]); + } + dbus->free_string_array(paths); + SDL_SendDropComplete(data_device->dnd_window); + drop_handled = SDL_TRUE; + } } - token = SDL_strtokr(NULL, "\r\n", &saveptr); + SDL_free(buffer); } - SDL_SendDropComplete(data_device->dnd_window); - SDL_free(buffer); } +#endif + /* If XDG document portal fails fallback. + * When running a flatpak sandbox this will most likely be a list of + * non paths that are not visible to the application + */ + if (!drop_handled && Wayland_data_offer_has_mime( + data_device->drag_offer, FILE_MIME)) { + void *buffer = Wayland_data_offer_receive(data_device->drag_offer, + &length, FILE_MIME, SDL_TRUE); + if (buffer) { + char *saveptr = NULL; + char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); + while (token) { + char *fn = Wayland_URIToLocal(token); + if (fn) { + SDL_SendDropFile(data_device->dnd_window, fn); + } + token = SDL_strtokr(NULL, "\r\n", &saveptr); + } + SDL_SendDropComplete(data_device->dnd_window); + SDL_free(buffer); + drop_handled = SDL_TRUE; + } + } + + if (drop_handled && wl_data_offer_get_version(data_device->drag_offer->offer) >= + WL_DATA_OFFER_FINISH_SINCE_VERSION) { + wl_data_offer_finish(data_device->drag_offer->offer); + } + Wayland_data_offer_destroy(data_device->drag_offer); + data_device->drag_offer = NULL; } } @@ -1748,7 +1867,7 @@ static void data_device_handle_selection(void *data, struct wl_data_device *wl_d SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = wl_data_offer_get_user_data(id); } @@ -1775,7 +1894,7 @@ static void primary_selection_device_handle_offer(void *data, struct zwp_primary SDL_WaylandPrimarySelectionOffer *primary_selection_offer = NULL; primary_selection_offer = SDL_calloc(1, sizeof(*primary_selection_offer)); - if (primary_selection_offer == NULL) { + if (!primary_selection_offer) { SDL_OutOfMemory(); } else { primary_selection_offer->offer = id; @@ -1792,7 +1911,7 @@ static void primary_selection_device_handle_selection(void *data, struct zwp_pri SDL_WaylandPrimarySelectionDevice *primary_selection_device = data; SDL_WaylandPrimarySelectionOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = zwp_primary_selection_offer_v1_get_user_data(id); } @@ -1915,8 +2034,13 @@ static void Wayland_create_data_device(SDL_VideoData *d) { SDL_WaylandDataDevice *data_device = NULL; + if (!d->input->seat) { + /* No seat yet, will be initialized later. */ + return; + } + data_device = SDL_calloc(1, sizeof(*data_device)); - if (data_device == NULL) { + if (!data_device) { return; } @@ -1924,7 +2048,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) d->data_device_manager, d->input->seat); data_device->video_data = d; - if (data_device->data_device == NULL) { + if (!data_device->data_device) { SDL_free(data_device); } else { wl_data_device_set_user_data(data_device->data_device, data_device); @@ -1938,8 +2062,13 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + if (!d->input->seat) { + /* No seat yet, will be initialized later. */ + return; + } + primary_selection_device = SDL_calloc(1, sizeof(*primary_selection_device)); - if (primary_selection_device == NULL) { + if (!primary_selection_device) { return; } @@ -1947,7 +2076,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) d->primary_selection_device_manager, d->input->seat); primary_selection_device->video_data = d; - if (primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device->primary_selection_device) { SDL_free(primary_selection_device); } else { zwp_primary_selection_device_v1_set_user_data(primary_selection_device->primary_selection_device, @@ -1962,15 +2091,20 @@ static void Wayland_create_text_input(SDL_VideoData *d) { SDL_WaylandTextInput *text_input = NULL; + if (!d->input->seat) { + /* No seat yet, will be initialized later. */ + return; + } + text_input = SDL_calloc(1, sizeof(*text_input)); - if (text_input == NULL) { + if (!text_input) { return; } text_input->text_input = zwp_text_input_manager_v3_get_text_input( d->text_input_manager, d->input->seat); - if (text_input->text_input == NULL) { + if (!text_input->text_input) { SDL_free(text_input); } else { zwp_text_input_v3_set_user_data(text_input->text_input, text_input); @@ -1984,7 +2118,7 @@ void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t ver { d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); - if (d->input != NULL) { + if (d->input) { Wayland_create_data_device(d); } } @@ -1993,7 +2127,7 @@ void Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, { d->primary_selection_device_manager = wl_registry_bind(d->registry, id, &zwp_primary_selection_device_manager_v1_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_primary_selection_device(d); } } @@ -2002,7 +2136,7 @@ void Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t vers { d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_text_input(d); } } @@ -2042,7 +2176,7 @@ static void tablet_tool_handle_proximity_in(void *data, struct zwp_tablet_tool_v struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { return; } @@ -2099,7 +2233,7 @@ static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window = input->tool_focus; input->is_down = SDL_TRUE; - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2117,7 +2251,7 @@ static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 *tool) input->is_down = SDL_FALSE; - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2233,7 +2367,7 @@ struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void *object struct SDL_WaylandTabletObjectListNode *node; node = SDL_calloc(1, sizeof(*node)); - if (node == NULL) { + if (!node) { return NULL; } @@ -2245,7 +2379,7 @@ struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void *object void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode *head, void *object) { - if (head->object == NULL) { + if (!head->object) { head->object = object; return; } @@ -2303,12 +2437,12 @@ void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_Wayland { struct SDL_WaylandTabletInput *tablet_input; - if (tablet_manager == NULL || input == NULL || !input->seat) { + if (!tablet_manager || !input->seat) { return; } tablet_input = SDL_calloc(1, sizeof(*tablet_input)); - if (tablet_input == NULL) { + if (!tablet_input) { return; } @@ -2338,27 +2472,17 @@ void Wayland_input_destroy_tablet(struct SDL_WaylandInput *input) void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) { - struct SDL_WaylandInput *input; - - input = SDL_calloc(1, sizeof(*input)); - if (input == NULL) { - return; - } + struct SDL_WaylandInput *input = d->input; - input->display = d; input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(SDL_WL_SEAT_VERSION, version)); - input->sx_w = wl_fixed_from_int(0); - input->sy_w = wl_fixed_from_int(0); - input->xkb.current_group = XKB_GROUP_INVALID; - d->input = input; - if (d->data_device_manager != NULL) { + if (d->data_device_manager) { Wayland_create_data_device(d); } - if (d->primary_selection_device_manager != NULL) { + if (d->primary_selection_device_manager) { Wayland_create_primary_selection_device(d); } - if (d->text_input_manager != NULL) { + if (d->text_input_manager) { Wayland_create_text_input(d); } @@ -2376,32 +2500,32 @@ void Wayland_display_destroy_input(SDL_VideoData *d) { struct SDL_WaylandInput *input = d->input; - if (input == NULL) { + if (!input) { return; } - if (input->data_device != NULL) { + if (input->data_device) { Wayland_data_device_clear_selection(input->data_device); - if (input->data_device->selection_offer != NULL) { + if (input->data_device->selection_offer) { Wayland_data_offer_destroy(input->data_device->selection_offer); } - if (input->data_device->drag_offer != NULL) { + if (input->data_device->drag_offer) { Wayland_data_offer_destroy(input->data_device->drag_offer); } - if (input->data_device->data_device != NULL) { + if (input->data_device->data_device) { wl_data_device_release(input->data_device->data_device); } SDL_free(input->data_device); } - if (input->primary_selection_device != NULL) { - if (input->primary_selection_device->selection_offer != NULL) { + if (input->primary_selection_device) { + if (input->primary_selection_device->selection_offer) { Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer); } SDL_free(input->primary_selection_device); } - if (input->text_input != NULL) { + if (input->text_input) { zwp_text_input_v3_destroy(input->text_input->text_input); SDL_free(input->text_input); } @@ -2534,6 +2658,10 @@ static void lock_pointer_to_window(SDL_Window *window, SDL_VideoData *d = input->display; struct zwp_locked_pointer_v1 *locked_pointer; + if (!d->pointer_constraints || !input->pointer) { + return; + } + if (w->locked_pointer) { return; } @@ -2621,8 +2749,10 @@ int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input) w->locked_pointer = NULL; } - zwp_relative_pointer_v1_destroy(input->relative_pointer); - input->relative_pointer = NULL; + if (input->relative_pointer) { + zwp_relative_pointer_v1_destroy(input->relative_pointer); + input->relative_pointer = NULL; + } d->relative_mouse_mode = 0; @@ -2708,7 +2838,7 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi &confined_pointer_listener, window); - if (confine_rect != NULL) { + if (confine_rect) { wl_region_destroy(confine_rect); } diff --git a/vs/sdl2/src/video/wayland/SDL_waylandevents_c.h b/vs/sdl2/src/video/wayland/SDL_waylandevents_c.h index 3b8f92ab84..d69888c822 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandevents_c.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.c b/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.c index d8cf07579b..df0f865c0b 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "../SDL_sysvideo.h" #include "SDL_waylandvideo.h" @@ -32,7 +32,7 @@ int Wayland_InitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Init(); } #endif @@ -45,7 +45,7 @@ void Wayland_QuitKeyboard(_THIS) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Quit(); } #endif @@ -57,7 +57,7 @@ void Wayland_StartTextInput(_THIS) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { const SDL_Rect *rect = &input->text_input->cursor_rect; /* Don't re-enable if we're already enabled. */ @@ -98,7 +98,7 @@ void Wayland_StopTextInput(_THIS) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { zwp_text_input_v3_disable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); input->text_input->is_enabled = SDL_FALSE; @@ -116,14 +116,14 @@ void Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *driverdata = _this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { if (!SDL_RectEquals(rect, &input->text_input->cursor_rect)) { SDL_copyp(&input->text_input->cursor_rect, rect); zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, diff --git a/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.h b/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.h index 98e42eec35..6a0fccda1f 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandkeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.c b/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.c index 24bc21a6f3..2fea3deceb 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "SDL.h" #include /* fgets */ @@ -89,7 +89,7 @@ static int get_zenity_version(int *major, int *minor) { int tmp; outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { close(fd_pipe[0]); return SDL_SetError("failed to open pipe for reading: %s", strerror(errno)); } @@ -194,7 +194,7 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button char *output = NULL; char *tmp = NULL; - if (buttonid == NULL) { + if (!buttonid) { /* if we don't need buttonid, we can return immediately */ close(fd_pipe[0]); return 0; /* success */ @@ -202,14 +202,14 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button *buttonid = -1; output = SDL_malloc(output_len + 1); - if (output == NULL) { + if (!output) { close(fd_pipe[0]); return SDL_OutOfMemory(); } output[0] = '\0'; outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { SDL_free(output); close(fd_pipe[0]); return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno)); @@ -217,20 +217,20 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button tmp = fgets(output, output_len + 1, outputfp); (void)fclose(outputfp); - if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) { + if ((!tmp) || (*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) { + if (tmp) { *tmp = '\0'; } /* Check which button got pressed */ for (i = 0; i < messageboxdata->numbuttons; i += 1) { - if (messageboxdata->buttons[i].text != NULL) { + if (messageboxdata->buttons[i].text) { if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { *buttonid = messageboxdata->buttons[i].buttonid; break; diff --git a/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.h b/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.h index 2775774194..2193a6bf8f 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #ifndef SDL_waylandmessagebox_h_ #define SDL_waylandmessagebox_h_ -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND extern int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/wayland/SDL_waylandmouse.c b/vs/sdl2/src/video/wayland/SDL_waylandmouse.c index adc91271e2..4b7264588d 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandmouse.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +21,14 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND -#include #include #include #include #include +#include +#include #include "../SDL_sysvideo.h" @@ -58,6 +59,7 @@ typedef struct */ SDL_SystemCursor system_cursor; void *shm_data; + size_t shm_data_size; } Wayland_CursorData; #ifdef SDL_USE_LIBDBUS @@ -115,7 +117,7 @@ static SDL_bool wayland_dbus_read_cursor_size(int *size) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || size == NULL) { + if (!dbus || !size) { return SDL_FALSE; } @@ -137,7 +139,7 @@ static SDL_bool wayland_dbus_read_cursor_theme(char **theme) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || theme == NULL) { + if (!dbus || !theme) { return SDL_FALSE; } @@ -156,10 +158,35 @@ static SDL_bool wayland_dbus_read_cursor_theme(char **theme) #endif + +static const char *GetLegacyCursorName(SDL_SystemCursor system_cursor) +{ + switch (system_cursor) { + case SDL_SYSTEM_CURSOR_ARROW: return "left_ptr"; + case SDL_SYSTEM_CURSOR_IBEAM: return "xterm"; + case SDL_SYSTEM_CURSOR_WAIT: return "watch"; + case SDL_SYSTEM_CURSOR_CROSSHAIR: return "tcross"; + case SDL_SYSTEM_CURSOR_WAITARROW: return "watch"; + case SDL_SYSTEM_CURSOR_SIZENWSE: return "top_left_corner"; + case SDL_SYSTEM_CURSOR_SIZENESW: return "top_right_corner"; + case SDL_SYSTEM_CURSOR_SIZEWE: return "sb_h_double_arrow"; + case SDL_SYSTEM_CURSOR_SIZENS: return "sb_v_double_arrow"; + case SDL_SYSTEM_CURSOR_SIZEALL: return "fleur"; + case SDL_SYSTEM_CURSOR_NO: return "pirate"; + case SDL_SYSTEM_CURSOR_HAND: return "hand2"; + case SDL_NUM_SYSTEM_CURSORS: break; /* so the compiler might notice if an enum value is missing here. */ + } + + SDL_assert(0); + return NULL; +} + static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorData *cdata, float *scale) { struct wl_cursor_theme *theme = NULL; struct wl_cursor *cursor; + const char *cssname = NULL; + const char *fallback_name = NULL; char *xcursor_size; int size = 0; @@ -179,7 +206,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa if ((xcursor_size = SDL_getenv("XCURSOR_SIZE"))) { size = SDL_atoi(xcursor_size); } -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS if (size <= 0) { wayland_dbus_read_cursor_size(&size); } @@ -189,7 +216,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa } /* First, find the appropriate theme based on the current scale... */ focus = SDL_GetMouse()->focus; - if (focus == NULL) { + if (!focus) { /* Nothing to see here, bail. */ return SDL_FALSE; } @@ -204,19 +231,19 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa break; } } - if (theme == NULL) { + if (!theme) { char *xcursor_theme = NULL; SDL_bool free_theme_str = SDL_FALSE; vdata->cursor_themes = SDL_realloc(vdata->cursor_themes, sizeof(SDL_WaylandCursorTheme) * (vdata->num_cursor_themes + 1)); - if (vdata->cursor_themes == NULL) { + if (!vdata->cursor_themes) { SDL_OutOfMemory(); return SDL_FALSE; } xcursor_theme = SDL_getenv("XCURSOR_THEME"); -#if SDL_USE_LIBDBUS - if (xcursor_theme == NULL) { +#ifdef SDL_USE_LIBDBUS + if (!xcursor_theme) { /* Allocates the string with SDL_strdup, which must be freed. */ free_theme_str = wayland_dbus_read_cursor_theme(&xcursor_theme); } @@ -231,54 +258,28 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa } /* Next, find the cursor from the theme... */ - switch (cdata->system_cursor) { - case SDL_SYSTEM_CURSOR_ARROW: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); - break; - case SDL_SYSTEM_CURSOR_IBEAM: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "xterm"); - break; - case SDL_SYSTEM_CURSOR_WAIT: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "watch"); - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "tcross"); - break; - case SDL_SYSTEM_CURSOR_WAITARROW: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "watch"); - break; - case SDL_SYSTEM_CURSOR_SIZENWSE: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "top_left_corner"); - break; - case SDL_SYSTEM_CURSOR_SIZENESW: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "top_right_corner"); - break; - case SDL_SYSTEM_CURSOR_SIZEWE: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "sb_h_double_arrow"); - break; - case SDL_SYSTEM_CURSOR_SIZENS: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "sb_v_double_arrow"); - break; - case SDL_SYSTEM_CURSOR_SIZEALL: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "fleur"); - break; - case SDL_SYSTEM_CURSOR_NO: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "pirate"); - break; - case SDL_SYSTEM_CURSOR_HAND: - cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "hand2"); - break; - default: - SDL_assert(0); - return SDL_FALSE; + cssname = SDL_GetCSSCursorName(cdata->system_cursor, &fallback_name); + + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, cssname); + if (!cursor && fallback_name) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, fallback_name); + } + + /* try the legacy name if the fancy new CSS name doesn't work... */ + if (!cursor) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, GetLegacyCursorName(cdata->system_cursor)); } /* Fallback to the default cursor if the chosen one wasn't found */ + if (!cursor) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "default"); + } + /* Try the old X11 name as a last resort */ if (!cursor) { cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); - if (!cursor) { - return SDL_FALSE; - } + } + if (!cursor) { + return SDL_FALSE; } /* ... Set the cursor data, finally. */ @@ -290,27 +291,72 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa return SDL_TRUE; } -static int wayland_create_tmp_file(off_t size) +static int set_tmp_file_size(int fd, off_t size) { - static const char template[] = "/sdl-shared-XXXXXX"; - char *xdg_path; - char tmp_path[PATH_MAX]; - int fd; +#ifdef HAVE_POSIX_FALLOCATE + sigset_t set, old_set; + int ret; - xdg_path = SDL_getenv("XDG_RUNTIME_DIR"); - if (xdg_path == NULL) { - return -1; - } + /* SIGALRM can potentially block a large posix_fallocate() operation + * from succeeding, so block it. + */ + sigemptyset(&set); + sigaddset(&set, SIGALRM); + sigprocmask(SIG_BLOCK, &set, &old_set); - SDL_strlcpy(tmp_path, xdg_path, PATH_MAX); - SDL_strlcat(tmp_path, template, PATH_MAX); + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); - fd = mkostemp(tmp_path, O_CLOEXEC); - if (fd < 0) { + sigprocmask(SIG_SETMASK, &old_set, NULL); + + if (ret == 0) { + return 0; + } + else if (ret != EINVAL && errno != EOPNOTSUPP) { return -1; } +#endif if (ftruncate(fd, size) < 0) { + return -1; + } + return 0; +} + +static int wayland_create_tmp_file(off_t size) +{ + int fd; + +#ifdef HAVE_MEMFD_CREATE + fd = memfd_create("SDL", MFD_CLOEXEC | MFD_ALLOW_SEALING); + if (fd >= 0) { + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL); + } else +#endif + { + static const char template[] = "/sdl-shared-XXXXXX"; + char *xdg_path; + char tmp_path[PATH_MAX]; + + xdg_path = SDL_getenv("XDG_RUNTIME_DIR"); + if (!xdg_path) { + return -1; + } + + SDL_strlcpy(tmp_path, xdg_path, PATH_MAX); + SDL_strlcat(tmp_path, template, PATH_MAX); + + fd = mkostemp(tmp_path, O_CLOEXEC); + if (fd < 0) { + return -1; + } + + /* Need to manually unlink the temp files, or they can persist after close and fill up the temp storage. */ + unlink(tmp_path); + } + + if (set_tmp_file_size(fd, size) < 0) { close(fd); return -1; } @@ -334,19 +380,18 @@ static int create_buffer_from_shm(Wayland_CursorData *d, SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *data = (SDL_VideoData *)vd->driverdata; struct wl_shm_pool *shm_pool; + int shm_fd; int stride = width * 4; - int size = stride * height; + d->shm_data_size = stride * height; - int shm_fd; - - shm_fd = wayland_create_tmp_file(size); + shm_fd = wayland_create_tmp_file(d->shm_data_size); if (shm_fd < 0) { return SDL_SetError("Creating mouse cursor buffer failed."); } d->shm_data = mmap(NULL, - size, + d->shm_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, @@ -359,7 +404,7 @@ static int create_buffer_from_shm(Wayland_CursorData *d, SDL_assert(d->shm_data != NULL); - shm_pool = wl_shm_create_pool(data->shm, shm_fd, size); + shm_pool = wl_shm_create_pool(data->shm, shm_fd, d->shm_data_size); d->buffer = wl_shm_pool_create_buffer(shm_pool, 0, width, @@ -385,7 +430,7 @@ static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *wd = (SDL_VideoData *)vd->driverdata; Wayland_CursorData *data = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -429,7 +474,7 @@ static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { Wayland_CursorData *cdata = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (cdata == NULL) { + if (!cdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -460,6 +505,7 @@ static void Wayland_FreeCursorData(Wayland_CursorData *d) if (d->buffer) { if (d->shm_data) { wl_buffer_destroy(d->buffer); + munmap(d->shm_data, d->shm_data_size); } d->buffer = NULL; } @@ -472,7 +518,7 @@ static void Wayland_FreeCursorData(Wayland_CursorData *d) static void Wayland_FreeCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { return; } @@ -483,7 +529,6 @@ static void Wayland_FreeCursor(SDL_Cursor *cursor) Wayland_FreeCursorData((Wayland_CursorData *)cursor->driverdata); - /* Not sure what's meant to happen to shm_data */ SDL_free(cursor->driverdata); SDL_free(cursor); } @@ -496,7 +541,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) struct wl_pointer *pointer = d->pointer; float scale = 1.0f; - if (pointer == NULL) { + if (!pointer) { return -1; } @@ -504,7 +549,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) Wayland_CursorData *data = cursor->driverdata; /* TODO: High-DPI custom cursors? -flibit */ - if (data->shm_data == NULL) { + if (!data->shm_data) { if (!wayland_get_system_cursor(d, data, &scale)) { return -1; } diff --git a/vs/sdl2/src/video/wayland/SDL_waylandmouse.h b/vs/sdl2/src/video/wayland/SDL_waylandmouse.h index dd3e8f83d9..4f3296d0e2 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandmouse.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #include "SDL_mouse.h" #include "SDL_waylandvideo.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND extern void Wayland_InitMouse(void); extern void Wayland_FiniMouse(SDL_VideoData *data); diff --git a/vs/sdl2/src/video/wayland/SDL_waylandopengles.c b/vs/sdl2/src/video/wayland/SDL_waylandopengles.c index 41e84fbafe..22311a63e6 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandopengles.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_WAYLAND) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_timer.h" #include "../../core/unix/SDL_poll.h" @@ -125,8 +125,8 @@ int Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; struct wl_display *display = videodata->display; SDL_VideoDisplay *sdldisplay = SDL_GetDisplayForWindow(window); - /* ~10 frames (or 1 sec), so we'll progress even if throttled to zero. */ - const Uint32 max_wait = SDL_GetTicks() + (sdldisplay->current_mode.refresh_rate ? (10000 / sdldisplay->current_mode.refresh_rate) : 1000); + /* 1/3 speed (or 20hz), so we'll progress even if throttled to zero. */ + const Uint32 max_wait = SDL_GetTicks() + (sdldisplay && sdldisplay->current_mode.refresh_rate ? (3000 / sdldisplay->current_mode.refresh_rate) : 50); while (SDL_AtomicGet(&data->swap_interval_ready) == 0) { Uint32 now; diff --git a/vs/sdl2/src/video/wayland/SDL_waylandopengles.h b/vs/sdl2/src/video/wayland/SDL_waylandopengles.h index deb7dd1097..772a80a04f 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandopengles.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylandsym.h b/vs/sdl2/src/video/wayland/SDL_waylandsym.h index c59bb30c9c..1b02b01c66 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandsym.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandsym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -219,10 +219,10 @@ SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int)) #if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || defined(SDL_HAVE_LIBDECOR_GET_MIN_MAX) /* Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. */ -SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (struct libdecor_frame *,\ +SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (const struct libdecor_frame *,\ int *,\ int *)) -SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (struct libdecor_frame *,\ +SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (const struct libdecor_frame *,\ int *,\ int *)) #endif diff --git a/vs/sdl2/src/video/wayland/SDL_waylandtouch.c b/vs/sdl2/src/video/wayland/SDL_waylandtouch.c index 7c7a300d72..7a6b7fcd0d 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandtouch.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandtouch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -99,7 +99,7 @@ static void touch_handle_touch(void *data, /* FIXME: This should be the window the given wayland surface is associated * with, but how do we get the wayland surface? */ window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { window = SDL_GetKeyboardFocus(); } diff --git a/vs/sdl2/src/video/wayland/SDL_waylandtouch.h b/vs/sdl2/src/video/wayland/SDL_waylandtouch.h index 5a542e2dd8..ed260ea39b 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandtouch.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandtouch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +94,7 @@ static inline struct qt_extended_surface *qt_surface_extension_get_extended_surf id = wl_proxy_create((struct wl_proxy *)qt_surface_extension, &qt_extended_surface_interface); - if (id == NULL) + if (!id) return NULL; WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_surface_extension, diff --git a/vs/sdl2/src/video/wayland/SDL_waylandvideo.c b/vs/sdl2/src/video/wayland/SDL_waylandvideo.c index 8fd65813a1..9b593cc917 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandvideo.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "SDL_video.h" #include "SDL_mouse.h" @@ -37,6 +37,7 @@ #include "SDL_waylandtouch.h" #include "SDL_waylandclipboard.h" #include "SDL_waylandvulkan.h" +#include "SDL_waylandmessagebox.h" #include "SDL_hints.h" #include @@ -171,33 +172,58 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) { SDL_VideoDevice *device; SDL_VideoData *data; + struct SDL_WaylandInput *input; struct wl_display *display; + /* Are we trying to connect to or are currently in a Wayland session? */ + if (!getenv("WAYLAND_DISPLAY")) { + const char *session = getenv("XDG_SESSION_TYPE"); + if (session && SDL_strcasecmp(session, "wayland")) { + return NULL; + } + } + if (!SDL_WAYLAND_LoadSymbols()) { return NULL; } display = WAYLAND_wl_display_connect(NULL); - if (display == NULL) { + if (!display) { SDL_WAYLAND_UnloadSymbols(); return NULL; } data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { + WAYLAND_wl_display_disconnect(display); + SDL_WAYLAND_UnloadSymbols(); + SDL_OutOfMemory(); + return NULL; + } + + input = SDL_calloc(1, sizeof(*input)); + if (!input) { + SDL_free(data); WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); return NULL; } + input->display = data; + input->sx_w = wl_fixed_from_int(0); + input->sy_w = wl_fixed_from_int(0); + input->xkb.current_group = XKB_GROUP_INVALID; + data->initializing = SDL_TRUE; data->display = display; + data->input = input; /* Initialize all variables that we clean on shutdown */ device = SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_free(data); + SDL_free(input); WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); @@ -219,7 +245,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) device->WaitEventTimeout = Wayland_WaitEventTimeout; device->SendWakeupEvent = Wayland_SendWakeupEvent; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL device->GL_SwapWindow = Wayland_GLES_SwapWindow; device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval; device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval; @@ -265,7 +291,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) device->StopTextInput = Wayland_StopTextInput; device->SetTextInputRect = Wayland_SetTextInputRect; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions; @@ -282,7 +308,8 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) VideoBootStrap Wayland_bootstrap = { WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver", - Wayland_CreateDevice + Wayland_CreateDevice, + Wayland_ShowMessageBox }; static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, @@ -348,7 +375,7 @@ static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg if (driverdata->index == -1) { /* xdg-output descriptions, if available, supersede wl-output model names. */ - if (driverdata->placeholder.name != NULL) { + if (driverdata->placeholder.name) { SDL_free(driverdata->placeholder.name); } @@ -451,17 +478,8 @@ static void display_handle_geometry(void *data, { SDL_WaylandOutputData *driverdata = data; - SDL_VideoDisplay *display; - int i; if (driverdata->wl_output_done_count) { - /* Clear the wl_output ref so Reset doesn't free it */ - display = SDL_GetDisplay(driverdata->index); - for (i = 0; i < display->num_display_modes; i += 1) { - display->display_modes[i].driverdata = NULL; - } - - /* Okay, now it's safe to reset */ SDL_ResetDisplayModes(driverdata->index); /* The display has officially started over. */ @@ -477,7 +495,7 @@ static void display_handle_geometry(void *data, driverdata->physical_height = physical_height; /* The output name is only set if xdg-output hasn't provided a description. */ - if (driverdata->index == -1 && driverdata->placeholder.name == NULL) { + if (driverdata->index == -1 && !driverdata->placeholder.name) { driverdata->placeholder.name = SDL_strdup(model); } @@ -573,7 +591,6 @@ static void display_handle_done(void *data, native_mode.h = driverdata->native_height; } native_mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */ - native_mode.driverdata = driverdata->output; /* The scaled desktop mode */ SDL_zero(desktop_mode); @@ -595,13 +612,12 @@ static void display_handle_done(void *data, desktop_mode.h = driverdata->width; } desktop_mode.refresh_rate = (int)SDL_round(driverdata->refresh / 1000.0); /* mHz to Hz */ - desktop_mode.driverdata = driverdata->output; /* * The native display mode is only exposed separately from the desktop size if the * desktop is scaled and the wp_viewporter protocol is supported. */ - if (driverdata->scale_factor > 1.0f && video->viewporter != NULL) { + if (driverdata->scale_factor > 1.0f && video->viewporter) { if (driverdata->index > -1) { SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &native_mode); } else { @@ -611,17 +627,17 @@ static void display_handle_done(void *data, /* Calculate the display DPI */ if (driverdata->transform & WL_OUTPUT_TRANSFORM_90) { - 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, + driverdata->hdpi = driverdata->physical_height ? (((float)driverdata->native_height) * 25.4f / driverdata->physical_height) : 0.0f; + driverdata->vdpi = driverdata->physical_width ? (((float)driverdata->native_width) * 25.4f / driverdata->physical_width) : 0.0f; + driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->native_height, + driverdata->native_width, ((float)driverdata->physical_height) / 25.4f, ((float)driverdata->physical_width) / 25.4f); } else { - 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, + driverdata->hdpi = driverdata->physical_width ? (((float)driverdata->native_width) * 25.4f / driverdata->physical_width) : 0.0f; + driverdata->vdpi = driverdata->physical_height ? (((float)driverdata->native_height) * 25.4f / driverdata->physical_height) : 0.0f; + driverdata->ddpi = SDL_ComputeDiagonalDPI(driverdata->native_width, + driverdata->native_height, ((float)driverdata->physical_width) / 25.4f, ((float)driverdata->physical_height) / 25.4f); } @@ -677,7 +693,7 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WaylandOutputData *data; output = wl_registry_bind(d->registry, id, &wl_output_interface, 2); - if (output == NULL) { + if (!output) { SDL_SetError("Failed to retrieve output."); return; } @@ -693,10 +709,10 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WAYLAND_register_output(output); /* Keep a list of outputs for deferred xdg-output initialization. */ - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; - while (node->next != NULL) { + while (node->next) { node = node->next; } @@ -722,15 +738,15 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) display = SDL_GetDisplay(i); data = (SDL_WaylandOutputData *)display->driverdata; if (data->registry_id == id) { - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; if (node == data) { d->output_list = node->next; } else { - while (node->next != data && node->next != NULL) { + while (node->next != data && node->next) { node = node->next; } - if (node->next != NULL) { + if (node->next) { node->next = node->next->next; } } @@ -758,7 +774,7 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) static void Wayland_init_xdg_output(SDL_VideoData *d) { SDL_WaylandOutputData *node; - for (node = d->output_list; node != NULL; node = node->next) { + for (node = d->output_list; node; node = node->next) { node->xdg_output = zxdg_output_manager_v1_get_xdg_output(node->videodata->xdg_output_manager, node->output); zxdg_output_v1_add_listener(node->xdg_output, &xdg_output_listener, node); } @@ -841,9 +857,7 @@ static void display_handle_global(void *data, struct wl_registry *registry, uint d->decoration_manager = wl_registry_bind(d->registry, id, &zxdg_decoration_manager_v1_interface, 1); } else if (SDL_strcmp(interface, "zwp_tablet_manager_v2") == 0) { d->tablet_manager = wl_registry_bind(d->registry, id, &zwp_tablet_manager_v2_interface, 1); - if (d->input) { - Wayland_input_add_tablet(d->input, d->tablet_manager); - } + Wayland_input_add_tablet(d->input, d->tablet_manager); } else if (SDL_strcmp(interface, "zxdg_output_manager_v1") == 0) { version = SDL_min(version, 3); /* Versions 1 through 3 are supported. */ d->xdg_output_manager = wl_registry_bind(d->registry, id, &zxdg_output_manager_v1_interface, version); @@ -929,7 +943,7 @@ int Wayland_VideoInit(_THIS) } data->registry = wl_display_get_registry(data->display); - if (data->registry == NULL) { + if (!data->registry) { return SDL_SetError("Failed to get the Wayland registry"); } @@ -989,7 +1003,7 @@ static int Wayland_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *dd static void Wayland_VideoCleanup(_THIS) { SDL_VideoData *data = _this->driverdata; - int i, j; + int i; Wayland_QuitWin(data); Wayland_FiniMouse(data); @@ -1005,10 +1019,6 @@ static void Wayland_VideoCleanup(_THIS) SDL_free(display->driverdata); display->driverdata = NULL; - for (j = display->num_display_modes; j--;) { - display->display_modes[j].driverdata = NULL; - } - display->desktop_mode.driverdata = NULL; SDL_DelVideoDisplay(i); } data->output_list = NULL; diff --git a/vs/sdl2/src/video/wayland/SDL_waylandvideo.h b/vs/sdl2/src/video/wayland/SDL_waylandvideo.h index 2f3eb4c82d..b7b3348c6d 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandvideo.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/wayland/SDL_waylandvulkan.c b/vs/sdl2/src/video/wayland/SDL_waylandvulkan.c index 59427dedb1..af956dad2e 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandvulkan.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WAYLAND +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WAYLAND) #include "SDL_waylandvideo.h" #include "SDL_waylandwindow.h" @@ -53,10 +53,10 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -81,7 +81,7 @@ int Wayland_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/vs/sdl2/src/video/wayland/SDL_waylandvulkan.h b/vs/sdl2/src/video/wayland/SDL_waylandvulkan.h index c22e34df6c..f42ed8e3b7 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandvulkan.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WAYLAND +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WAYLAND) int Wayland_Vulkan_LoadLibrary(_THIS, const char *path); void Wayland_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/wayland/SDL_waylandwindow.c b/vs/sdl2/src/video/wayland/SDL_waylandwindow.c index 303f5982b7..c8d55def17 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandwindow.c +++ b/vs/sdl2/src/video/wayland/SDL_waylandwindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WAYLAND +#ifdef SDL_VIDEO_DRIVER_WAYLAND #include "../SDL_sysvideo.h" #include "../../events/SDL_windowevents_c.h" @@ -145,7 +145,7 @@ static SDL_bool NeedViewport(SDL_Window *window) * - A fullscreen mode is being emulated and the mode does not match the logical desktop dimensions. * - The desktop uses fractional scaling and the high-DPI flag is set. */ - if (video->viewporter != NULL) { + if (video->viewporter) { if (FullscreenModeEmulation(window)) { GetFullScreenDimensions(window, &fs_width, &fs_height, NULL, NULL); if (fs_width != output_width || fs_height != output_height) { @@ -198,11 +198,11 @@ static void SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_he SDL_VideoData *video = wind->waylandData; if (video->viewporter) { - if (wind->draw_viewport == NULL) { + if (!wind->draw_viewport) { wind->draw_viewport = wp_viewporter_get_viewport(video->viewporter, wind->surface); } - wp_viewport_set_source(wind->draw_viewport, wl_fixed_from_int(0), wl_fixed_from_int(0), wl_fixed_from_int(src_width), wl_fixed_from_int(src_height)); + wp_viewport_set_source(wind->draw_viewport, wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1)); wp_viewport_set_destination(wind->draw_viewport, dst_width, dst_height); } } @@ -295,7 +295,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) if (window_size_changed) { /* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */ if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR && - viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + viddata->shell.xdg && data->shell_surface.xdg.surface) { xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->window_width, data->window_height); } @@ -360,7 +360,7 @@ static void SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_min_content_size(wind->shell_surface.libdecor.frame, @@ -404,7 +404,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (output) { @@ -755,11 +755,10 @@ static void handle_configure_zxdg_decoration(void *data, WAYLAND_wl_display_roundtrip(driverdata->waylandData->display); Wayland_HideWindow(device, window); + SDL_zero(driverdata->shell_surface); driverdata->shell_surface_type = WAYLAND_SURFACE_LIBDECOR; - if (!window->is_hiding && !(window->flags & SDL_WINDOW_HIDDEN)) { - Wayland_ShowWindow(device, window); - } + Wayland_ShowWindow(device, window); } } @@ -782,7 +781,7 @@ static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { static void OverrideLibdecorLimits(SDL_Window *window) { #if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) - if (libdecor_frame_get_min_content_size == NULL) { + if (!libdecor_frame_get_min_content_size) { SetMinMaxDimensions(window, SDL_FALSE); } #elif !defined(SDL_HAVE_LIBDECOR_GET_MIN_MAX) @@ -1209,7 +1208,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame != NULL) { + if (data->shell_surface.libdecor.frame) { info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); if (version >= SDL_VERSIONNUM(2, 0, 17)) { info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); @@ -1224,7 +1223,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf } } else #endif - if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + if (viddata->shell.xdg && data->shell_surface.xdg.surface) { info->info.wl.xdg_surface = data->shell_surface.xdg.surface; if (version >= SDL_VERSIONNUM(2, 0, 17)) { SDL_bool popup = data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP; @@ -1270,10 +1269,10 @@ int Wayland_SetWindowModalFor(_THIS, SDL_Window *modal_window, SDL_Window *paren #ifdef HAVE_LIBDECOR_H if (viddata->shell.libdecor) { - if (modal_data->shell_surface.libdecor.frame == NULL) { + if (!modal_data->shell_surface.libdecor.frame) { return SDL_SetError("Modal window was hidden"); } - if (parent_data->shell_surface.libdecor.frame == NULL) { + if (!parent_data->shell_surface.libdecor.frame) { return SDL_SetError("Parent window was hidden"); } libdecor_frame_set_parent(modal_data->shell_surface.libdecor.frame, @@ -1322,21 +1321,15 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) /* Create the shell surface and map the toplevel/popup */ #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame) { - /* If the frame already exists, just set the visibility. */ - libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true); - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, + data->surface, + &libdecor_frame_interface, + data); + if (!data->shell_surface.libdecor.frame) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); } else { - data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, - data->surface, - &libdecor_frame_interface, - data); - if (data->shell_surface.libdecor.frame == NULL) { - SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); - } else { - libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); - libdecor_frame_map(data->shell_surface.libdecor.frame); - } + libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); + libdecor_frame_map(data->shell_surface.libdecor.frame); } } else #endif @@ -1380,6 +1373,8 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window) 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); + + SetMinMaxDimensions(window, SDL_FALSE); } } @@ -1493,11 +1488,11 @@ static void Wayland_ReleasePopup(_THIS, SDL_Window *popup) SDL_WindowData *popupdata; /* Basic sanity checks to weed out the weird popup closures */ - if (popup == NULL || popup->magic != &_this->window_magic) { + if (!popup || popup->magic != &_this->window_magic) { return; } popupdata = popup->driverdata; - if (popupdata == NULL) { + if (!popupdata) { return; } @@ -1540,8 +1535,8 @@ void Wayland_HideWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (wind->shell_surface.libdecor.frame) { - libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false); - libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname); + libdecor_frame_unref(wind->shell_surface.libdecor.frame); + wind->shell_surface.libdecor.frame = NULL; } } else #endif @@ -1608,7 +1603,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, uint32_t serial, struct wl_seat *seat) { if (data->activation_manager) { - if (wind->activation_token != NULL) { + if (wind->activation_token) { /* We're about to overwrite this with a new request */ xdg_activation_token_v1_destroy(wind->activation_token); } @@ -1625,10 +1620,10 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, * * -flibit */ - if (surface != NULL) { + if (surface) { xdg_activation_token_v1_set_surface(wind->activation_token, surface); } - if (seat != NULL) { + if (seat) { xdg_activation_token_v1_set_serial(wind->activation_token, serial, seat); } xdg_activation_token_v1_commit(wind->activation_token); @@ -1702,20 +1697,20 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * { "inverted-landscape", QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION } }; - if (name == NULL) { + if (!name) { return; } if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION) == 0) { int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION; - if (newValue != NULL) { + if (newValue) { const char *value_attempt = newValue; orientation = 0; - while (value_attempt != NULL && *value_attempt != 0) { + while (value_attempt && *value_attempt != 0) { const char *value_attempt_end = SDL_strchr(value_attempt, ','); - size_t value_attempt_len = (value_attempt_end != NULL) ? (value_attempt_end - value_attempt) + size_t value_attempt_len = (value_attempt_end) ? (value_attempt_end - value_attempt) : SDL_strlen(value_attempt); for (i = 0; i < SDL_arraysize(orientations); i += 1) { @@ -1726,7 +1721,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } } - value_attempt = (value_attempt_end != NULL) ? (value_attempt_end + 1) : NULL; + value_attempt = (value_attempt_end) ? (value_attempt_end + 1) : NULL; } } @@ -1734,7 +1729,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } else if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_WINDOW_FLAGS) == 0) { uint32_t flags = 0; - if (newValue != NULL) { + if (newValue) { char *tmp = SDL_strdup(newValue); char *saveptr = NULL; @@ -1824,7 +1819,7 @@ void Wayland_RestoreWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); @@ -1869,7 +1864,7 @@ void Wayland_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable) const SDL_WindowData *wind = window->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (resizable) { @@ -1904,7 +1899,7 @@ void Wayland_MaximizeWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); @@ -1931,7 +1926,7 @@ void Wayland_MinimizeWindow(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); @@ -1994,7 +1989,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) SDL_VideoData *c; data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -2073,7 +2068,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) if (window->flags & SDL_WINDOW_OPENGL) { data->egl_window = WAYLAND_wl_egl_window_create(data->surface, data->drawable_width, data->drawable_height); -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Create the GLES window surface */ data->egl_surface = SDL_EGL_CreateSurface(_this, (NativeWindowType)data->egl_window); @@ -2212,7 +2207,7 @@ void Wayland_SetWindowTitle(_THIS, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title); @@ -2232,7 +2227,7 @@ void Wayland_SuspendScreenSaver(_THIS) { SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { return; } @@ -2271,7 +2266,7 @@ void Wayland_DestroyWindow(_THIS, SDL_Window *window) SDL_WindowData *wind = window->driverdata; if (data) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (wind->egl_surface) { SDL_EGL_DestroySurface(_this, wind->egl_surface); } @@ -2336,7 +2331,7 @@ static void EGLTransparencyChangedCallback(void *userdata, const char *name, con viddata->egl_transparency_enabled = newval; /* Iterate over all windows and update the surface opaque regions */ - for (window = dev->windows; window != NULL; window = window->next) { + for (window = dev->windows; window; window = window->next) { SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; if (!newval) { diff --git a/vs/sdl2/src/video/wayland/SDL_waylandwindow.h b/vs/sdl2/src/video/wayland/SDL_waylandwindow.h index 89f0d77661..36600a4d27 100644 --- a/vs/sdl2/src/video/wayland/SDL_waylandwindow.h +++ b/vs/sdl2/src/video/wayland/SDL_waylandwindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +78,7 @@ typedef struct struct wl_egl_window *egl_window; struct SDL_WaylandInput *keyboard_device; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif struct zwp_locked_pointer_v1 *locked_pointer; diff --git a/vs/sdl2/src/video/windows/SDL_msctf.h b/vs/sdl2/src/video/windows/SDL_msctf.h index 5f6829a071..738696f017 100644 --- a/vs/sdl2/src/video/windows/SDL_msctf.h +++ b/vs/sdl2/src/video/windows/SDL_msctf.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_vkeys.h b/vs/sdl2/src/video/windows/SDL_vkeys.h index 12f3440d92..fb4d27de91 100644 --- a/vs/sdl2/src/video/windows/SDL_vkeys.h +++ b/vs/sdl2/src/video/windows/SDL_vkeys.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsclipboard.c b/vs/sdl2/src/video/windows/SDL_windowsclipboard.c index df8a404a76..24bc5abef3 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsclipboard.c +++ b/vs/sdl2/src/video/windows/SDL_windowsclipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" @@ -129,7 +129,7 @@ char *WIN_GetClipboardText(_THIS) SDL_Delay(10); } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } return text; diff --git a/vs/sdl2/src/video/windows/SDL_windowsclipboard.h b/vs/sdl2/src/video/windows/SDL_windowsclipboard.h index d91eefe429..3db9bb9362 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsclipboard.h +++ b/vs/sdl2/src/video/windows/SDL_windowsclipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsevents.c b/vs/sdl2/src/video/windows/SDL_windowsevents.c index 84da361b80..35bae2596a 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsevents.c +++ b/vs/sdl2/src/video/windows/SDL_windowsevents.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS #include "SDL_windowsvideo.h" #include "SDL_windowsshape.h" @@ -43,7 +43,7 @@ #include /* For WM_TABLET_QUERYSYSTEMGESTURESTATUS et. al. */ -#if HAVE_TPCSHRD_H +#ifdef HAVE_TPCSHRD_H #include #endif /* HAVE_TPCSHRD_H */ @@ -99,6 +99,9 @@ #ifndef WM_GETDPISCALEDSIZE #define WM_GETDPISCALEDSIZE 0x02E4 #endif +#ifndef TOUCHEVENTF_PEN +#define TOUCHEVENTF_PEN 0x0040 +#endif #ifndef IS_HIGH_SURROGATE #define IS_HIGH_SURROGATE(x) (((x) >= 0xd800) && ((x) <= 0xdbff)) @@ -110,6 +113,10 @@ #define IS_SURROGATE_PAIR(h, l) (IS_HIGH_SURROGATE(h) && IS_LOW_SURROGATE(l)) #endif +#ifndef USER_TIMER_MINIMUM +#define USER_TIMER_MINIMUM 0x0000000A +#endif + static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) { switch (vkey) { @@ -121,6 +128,10 @@ static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) return SDL_SCANCODE_RIGHT; case VK_DOWN: return SDL_SCANCODE_DOWN; + case VK_CONTROL: + return SDL_SCANCODE_LCTRL; + case VK_V: + return SDL_SCANCODE_V; default: return SDL_SCANCODE_UNKNOWN; @@ -130,6 +141,11 @@ static SDL_Scancode VKeytoScancodeFallback(WPARAM vkey) static SDL_Scancode VKeytoScancode(WPARAM vkey) { switch (vkey) { + case VK_BACK: + return SDL_SCANCODE_BACKSPACE; + case VK_CAPITAL: + return SDL_SCANCODE_CAPSLOCK; + case VK_MODECHANGE: return SDL_SCANCODE_MODE; case VK_SELECT: @@ -185,7 +201,7 @@ static SDL_Scancode VKeytoScancode(WPARAM vkey) case VK_BROWSER_HOME: return SDL_SCANCODE_AC_HOME; case VK_VOLUME_MUTE: - return SDL_SCANCODE_AUDIOMUTE; + return SDL_SCANCODE_MUTE; case VK_VOLUME_DOWN: return SDL_SCANCODE_VOLUMEDOWN; case VK_VOLUME_UP: @@ -364,7 +380,7 @@ static void WIN_CheckWParamMouseButtons(WPARAM wParam, SDL_WindowData *data, SDL } } -static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID) +static void WIN_CheckRawMouseButtons(HANDLE hDevice, ULONG rawButtons, SDL_WindowData *data, SDL_MouseID mouseID) { // Add a flag to distinguish raw mouse buttons from wParam above rawButtons |= 0x8000000; @@ -372,6 +388,10 @@ static void WIN_CheckRawMouseButtons(ULONG rawButtons, SDL_WindowData *data, SDL if (rawButtons != data->mouse_button_flags) { Uint32 mouseFlags = SDL_GetMouseState(NULL, NULL); SDL_bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + if (swapButtons && hDevice == NULL) { + /* Touchpad, already has buttons swapped */ + swapButtons = SDL_FALSE; + } if (rawButtons & RI_MOUSE_BUTTON_1_DOWN) { WIN_CheckWParamMouseButton((rawButtons & RI_MOUSE_BUTTON_1_DOWN), mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID); } @@ -496,7 +516,7 @@ static void WIN_UpdateFocus(SDL_Window *window, SDL_bool expect_focus) SDL_ToggleModState(KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? SDL_TRUE : SDL_FALSE); SDL_ToggleModState(KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? SDL_TRUE : SDL_FALSE); SDL_ToggleModState(KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? SDL_TRUE : SDL_FALSE); - + WIN_UpdateWindowICCProfile(data->window, SDL_TRUE); } else { RECT rect; @@ -572,7 +592,7 @@ typedef enum SDL_MOUSE_EVENT_SOURCE_PEN, } SDL_MOUSE_EVENT_SOURCE; -static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource() +static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource(void) { LPARAM extrainfo = GetMessageExtraInfo(); /* Mouse data (ignoring synthetic mouse events generated for touchscreens) */ @@ -618,6 +638,10 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) if (nCode < 0 || nCode != HC_ACTION) { return CallNextHookEx(NULL, nCode, wParam, lParam); } + if (hookData->scanCode == 0x21d) { + // Skip fake LCtrl when RAlt is pressed + return 1; + } switch (hookData->vkCode) { case VK_LWIN: @@ -672,9 +696,43 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ + +// Return 1 if spruious LCtrl is pressed +// LCtrl is sent when RAltGR is pressed +int skip_bad_lcrtl(WPARAM wParam, LPARAM lParam) +{ + MSG next_msg; + DWORD msg_time; + if (wParam != VK_CONTROL) { + return 0; + } + // Is this an extended key (i.e. right key)? + if (lParam & 0x01000000) + return 0; + + // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only + // want the RALT message, so we try to see if the next message + // is a RALT message. In that case, this is a false LCTRL! + msg_time = GetMessageTime(); + if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) { + if (next_msg.message == WM_KEYDOWN || + next_msg.message == WM_SYSKEYDOWN) { + if (next_msg.wParam == VK_MENU && + (next_msg.lParam & 0x01000000) && + next_msg.time == msg_time) { + // Next message is a RALT down message, which + // means that this is NOT a proper LCTRL message! + return 1; + } + } + } + return 0; +} + LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { + static SDL_bool s_ModalMoveResizeLoop; SDL_WindowData *data; LRESULT returnCode = -1; @@ -694,12 +752,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - if (data == NULL) { + if (!data) { /* Fallback */ data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); } #endif - if (data == NULL) { + if (!data) { return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); } @@ -845,7 +903,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_MouseID mouseID; RAWMOUSE *rawmouse; if (SDL_GetNumTouchDevices() > 0 && - (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x82) == 0x82)) { + (GetMouseMessageSource() == SDL_MOUSE_EVENT_SOURCE_TOUCH || (GetMessageExtraInfo() & 0x80) == 0x80)) { break; } /* We do all of our mouse state checking against mouse ID 0 @@ -929,7 +987,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) data->last_raw_mouse_position.x = x; data->last_raw_mouse_position.y = y; } - WIN_CheckRawMouseButtons(rawmouse->usButtonFlags, data, mouseID); + WIN_CheckRawMouseButtons(inp.header.hDevice, rawmouse->usButtonFlags, data, mouseID); } } break; @@ -988,6 +1046,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + if (skip_bad_lcrtl(wParam, lParam)) { + returnCode = 0; + break; + } + /* Detect relevant keyboard shortcuts */ if (keyboardState[SDL_SCANCODE_LALT] == SDL_PRESSED || keyboardState[SDL_SCANCODE_RALT] == SDL_PRESSED) { /* ALT+F4: Close window */ @@ -996,8 +1059,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } - //if (code != SDL_SCANCODE_UNKNOWN) { - if(wParam != VK_PROCESSKEY && code != SDL_SCANCODE_UNKNOWN) { //Changed for DOSBox-X + if (code != SDL_SCANCODE_UNKNOWN) { SDL_SendKeyboardKey(SDL_PRESSED, code); } } @@ -1011,6 +1073,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam); const Uint8 *keyboardState = SDL_GetKeyboardState(NULL); + if (skip_bad_lcrtl(wParam, lParam)) { + returnCode = 0; + break; + } + if (code != SDL_SCANCODE_UNKNOWN) { if (code == SDL_SCANCODE_PRINTSCREEN && keyboardState[code] == SDL_RELEASED) { @@ -1254,6 +1321,27 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } break; + case WM_ENTERSIZEMOVE: + case WM_ENTERMENULOOP: + { + SetTimer(hwnd, (UINT_PTR)&s_ModalMoveResizeLoop, USER_TIMER_MINIMUM, NULL); + } break; + + case WM_TIMER: + { + if (wParam == (UINT_PTR)&s_ModalMoveResizeLoop) { + // Send an expose event so the application can redraw + SDL_SendWindowEvent(data->window, SDL_WINDOWEVENT_EXPOSED, 0, 0); + return 0; + } + } break; + + case WM_EXITSIZEMOVE: + case WM_EXITMENULOOP: + { + KillTimer(hwnd, (UINT_PTR)&s_ModalMoveResizeLoop); + } break; + case WM_SIZE: { switch (wParam) { @@ -1371,7 +1459,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* TODO: Can we use GetRawInputDeviceInfo and HID info to determine if this is a direct or indirect touch device? */ - if (SDL_AddTouch(touchId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { + if (SDL_AddTouch(touchId, SDL_TOUCH_DEVICE_DIRECT, (input->dwFlags & TOUCHEVENTF_PEN) == TOUCHEVENTF_PEN ? "pen" : "touch") < 0) { continue; } @@ -1397,7 +1485,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } break; -#if HAVE_TPCSHRD_H +#ifdef HAVE_TPCSHRD_H case WM_TABLET_QUERYSYSTEMGESTURESTATUS: /* See https://msdn.microsoft.com/en-us/library/windows/desktop/bb969148(v=vs.85).aspx . @@ -1770,8 +1858,19 @@ void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) int WIN_WaitEventTimeout(_THIS, int timeout) { - MSG msg; if (g_WindowsEnableMessageLoop) { +#if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + DWORD dwMilliseconds, ret; + dwMilliseconds = timeout < 0 ? INFINITE : (DWORD)timeout; + ret = MsgWaitForMultipleObjects(0, NULL, FALSE, dwMilliseconds, QS_ALLINPUT); + if (ret == WAIT_OBJECT_0) { + return 1; + } else { + return 0; + } +#else + /* MsgWaitForMultipleObjects is desktop-only. */ + MSG msg; BOOL message_result; UINT_PTR timer_id = 0; if (timeout > 0) { @@ -1784,7 +1883,7 @@ int WIN_WaitEventTimeout(_THIS, int timeout) message_result = GetMessage(&msg, 0, 0, 0); } if (message_result) { - if (msg.message == WM_TIMER && msg.hwnd == NULL && msg.wParam == timer_id) { + if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) { return 0; } if (g_WindowsMessageHook) { @@ -1797,6 +1896,7 @@ int WIN_WaitEventTimeout(_THIS, int timeout) } else { return 0; } +#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ } else { /* Fail the wait so the caller falls back to polling */ return -1; @@ -1873,7 +1973,7 @@ void WIN_PumpEvents(_THIS) not grabbing the keyboard. Note: If we *are* grabbing the keyboard, GetKeyState() will return inaccurate results for VK_LWIN and VK_RWIN but we don't need it anyway. */ focusWindow = SDL_GetKeyboardFocus(); - if (focusWindow == NULL || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) { SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LGUI); } @@ -1913,13 +2013,26 @@ static void WIN_CleanRegisterApp(WNDCLASSEX wcex) SDL_Appname = NULL; } +static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG_PTR lParam) +{ + WNDCLASSEX *wcex = (WNDCLASSEX *)lParam; + + (void)lpType; /* We already know that the resource type is RT_GROUP_ICON. */ + + /* We leave hIconSm as NULL as it will allow Windows to automatically + choose the appropriate small icon size to suit the current DPI. */ + wcex->hIcon = LoadIcon(hModule, lpName); + + /* Do not bother enumerating any more. */ + return FALSE; +} + /* Register the class for this application */ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) { WNDCLASSEX wcex; #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) const char *hint; - TCHAR path[MAX_PATH]; #endif /* Only do this once... */ @@ -1927,8 +2040,8 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) ++app_registered; return 0; } - SDL_assert(SDL_Appname == NULL); - if (name == NULL) { + SDL_assert(!SDL_Appname); + if (!name) { name = "SDL_app"; #if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC) style = (CS_BYTEALIGNCLIENT | CS_OWNDC); @@ -1962,9 +2075,8 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) wcex.hIconSm = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); } } else { - /* Use the first icon as a default icon, like in the Explorer */ - GetModuleFileName(SDL_Instance, path, MAX_PATH); - ExtractIconEx(path, 0, &wcex.hIcon, &wcex.hIconSm, 1); + /* Use the first icon as a default icon, like in the Explorer. */ + EnumResourceNames(SDL_Instance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex); } #endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/ diff --git a/vs/sdl2/src/video/windows/SDL_windowsevents.h b/vs/sdl2/src/video/windows/SDL_windowsevents.h index 98a45add22..3e337d0929 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsevents.h +++ b/vs/sdl2/src/video/windows/SDL_windowsevents.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsframebuffer.c b/vs/sdl2/src/video/windows/SDL_windowsframebuffer.c index 82483526d3..423462222f 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsframebuffer.c +++ b/vs/sdl2/src/video/windows/SDL_windowsframebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" @@ -114,7 +114,7 @@ void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/vs/sdl2/src/video/windows/SDL_windowsframebuffer.h b/vs/sdl2/src/video/windows/SDL_windowsframebuffer.h index fa626b8c97..adcac8a35d 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsframebuffer.h +++ b/vs/sdl2/src/video/windows/SDL_windowsframebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowskeyboard.c b/vs/sdl2/src/video/windows/SDL_windowskeyboard.c index acbb83ffb5..1ae4fe00bc 100644 --- a/vs/sdl2/src/video/windows/SDL_windowskeyboard.c +++ b/vs/sdl2/src/video/windows/SDL_windowskeyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_hints.h" @@ -32,8 +32,6 @@ #include #ifndef SDL_DISABLE_WINDOWS_IME -static Uint32 end_ticks = 0; // added for DOSBox-X -static SDL_bool ime_incompos; // added for DOSBox-X static void IME_Init(SDL_VideoData *videodata, HWND hwnd); static void IME_Enable(SDL_VideoData *videodata, HWND hwnd); static void IME_Disable(SDL_VideoData *videodata, HWND hwnd); @@ -168,18 +166,6 @@ void WIN_QuitKeyboard(_THIS) #endif /* !SDL_DISABLE_WINDOWS_IME */ } -#if 1 // Added for DOSBox-X -SDL_bool SDL_IM_Composition(int more) { - (void)more; -#ifndef SDL_DISABLE_WINDOWS_IME -#define IME_END_CR_WAIT 50 - return ime_incompos || end_ticks && (GetTickCount() - end_ticks < IME_END_CR_WAIT) ? SDL_TRUE : SDL_FALSE; -#else - return SDL_FALSE; -#endif -} -#endif - void WIN_ResetDeadKeys() { /* @@ -253,7 +239,7 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; HIMC himc = 0; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } @@ -263,7 +249,6 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) himc = ImmGetContext(videodata->ime_hwnd_current); if (himc) { - /* //reverted for DOSBox-X COMPOSITIONFORM cof; CANDIDATEFORM caf; @@ -285,12 +270,7 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) caf.rcArea.top = videodata->ime_rect.y; caf.rcArea.bottom = (LONG)videodata->ime_rect.y + videodata->ime_rect.h; ImmSetCandidateWindow(himc, &caf); - */ - COMPOSITIONFORM cf; - cf.ptCurrentPos.x = videodata->ime_rect.x; - cf.ptCurrentPos.y = videodata->ime_rect.y; - cf.dwStyle = CFS_FORCE_POSITION; - ImmSetCompositionWindow(himc, &cf); + ImmReleaseContext(videodata->ime_hwnd_current, himc); } #endif /* !SDL_DISABLE_WINDOWS_IME */ @@ -435,14 +415,11 @@ static void IME_Init(SDL_VideoData *videodata, HWND hwnd) videodata->ime_available = SDL_TRUE; IME_UpdateInputLocale(videodata); IME_SetupAPI(videodata); - // Disabled because the candidate window will not be displayed. (for DOSBox-X) - /* if (WIN_ShouldShowNativeUI()) { videodata->ime_uiless = SDL_FALSE; } else { videodata->ime_uiless = UILess_SetupSinks(videodata); } - */ IME_UpdateInputLocale(videodata); IME_Disable(videodata, hwnd); } @@ -721,7 +698,7 @@ static void IME_SetupAPI(SDL_VideoData *videodata) } hime = SDL_LoadObject(ime_file); - if (hime == NULL) { + if (!hime) { return; } @@ -804,7 +781,7 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD length = ImmGetCompositionStringW(himc, string, NULL, 0); if (length > 0 && videodata->ime_composition_length < length) { - if (videodata->ime_composition != NULL) { + if (videodata->ime_composition) { SDL_free(videodata->ime_composition); } @@ -996,11 +973,11 @@ static int IME_ShowCandidateList(SDL_VideoData *videodata) videodata->ime_candcount = 0; candidates = SDL_realloc(videodata->ime_candidates, MAX_CANDSIZE); - if (candidates != NULL) { + if (candidates) { videodata->ime_candidates = (WCHAR *)candidates; } - if (videodata->ime_candidates == NULL) { + if (!videodata->ime_candidates) { return -1; } @@ -1041,37 +1018,17 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S case WM_INPUTLANGCHANGE: IME_InputLangChanged(videodata); break; -#if 1 // added for DOSBox-X - case WM_IME_CHAR: - if(wParam == 0x20) { - // enable IME input space - PostMessage(hwnd, WM_KEYDOWN, 0x20, 0x390001); - } - else if(wParam == 0x3000) { - // input Zenkaku space - videodata->ime_composition[0] = 0x3000; - videodata->ime_composition[1] = 0; - IME_SendEditingEvent(videodata); - IME_SendInputEvent(videodata); - } - trap = SDL_TRUE; - break; -#endif case WM_IME_SETCONTEXT: - // Disabled because the string being converted will not be displayed. (for DOSBox-X) - /* if (videodata->ime_uiless) { *lParam = 0; } - */ break; case WM_IME_STARTCOMPOSITION: videodata->ime_suppress_endcomposition_event = SDL_FALSE; - ime_incompos = 1; /* added for DOSBox-X */ - //trap = SDL_TRUE; /* disabled for DOSBox-X */ + trap = SDL_TRUE; break; case WM_IME_COMPOSITION: - //trap = SDL_TRUE; /* disabled for DOSBox-X */ + trap = SDL_TRUE; himc = ImmGetContext(hwnd); if (*lParam & GCS_RESULTSTR) { videodata->ime_suppress_endcomposition_event = SDL_TRUE; @@ -1090,7 +1047,6 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S ImmReleaseContext(hwnd, himc); break; case WM_IME_ENDCOMPOSITION: - ime_incompos = 0; /* added for DOSBox-X */ videodata->ime_uicontext = 0; videodata->ime_composition[0] = 0; videodata->ime_readingstring[0] = 0; @@ -1235,7 +1191,7 @@ TSFSink_Release(TSFSink *sink) STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } @@ -1272,7 +1228,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1297,7 +1253,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1323,7 +1279,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1345,7 +1301,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } @@ -1365,9 +1321,9 @@ STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) STDMETHODIMP IPPASink_OnActivated(TSFSink *sink, DWORD dwProfileType, LANGID langid, REFCLSID clsid, REFGUID catid, REFGUID guidProfile, HKL hkl, DWORD dwFlags) { - static const GUID TF_PROFILE_DAYI = { 0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A } }; + static const GUID SDL_TF_PROFILE_DAYI = { 0x037B2C25, 0x480C, 0x4D7F, { 0xB0, 0x27, 0xD6, 0xCA, 0x6B, 0x69, 0x78, 0x8A } }; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - videodata->ime_candlistindexbase = WIN_IsEqualGUID(&TF_PROFILE_DAYI, guidProfile) ? 0 : 1; + videodata->ime_candlistindexbase = WIN_IsEqualGUID(&SDL_TF_PROFILE_DAYI, guidProfile) ? 0 : 1; if (WIN_IsEqualIID(catid, &GUID_TFCAT_TIP_KEYBOARD) && (dwFlags & TF_IPSINK_FLAG_ACTIVE)) { IME_InputLangChanged((SDL_VideoData *)sink->data); } diff --git a/vs/sdl2/src/video/windows/SDL_windowskeyboard.h b/vs/sdl2/src/video/windows/SDL_windowskeyboard.h index 876a722f31..3eb2398ea8 100644 --- a/vs/sdl2/src/video/windows/SDL_windowskeyboard.h +++ b/vs/sdl2/src/video/windows/SDL_windowskeyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsmessagebox.c b/vs/sdl2/src/video/windows/SDL_windowsmessagebox.c index 9272f536c4..f90e0d2e9a 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmessagebox.c +++ b/vs/sdl2/src/video/windows/SDL_windowsmessagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #ifdef HAVE_LIMITS_H #include @@ -265,7 +265,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { /* Focus on the first default return-key button */ HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex)); - if (buttonctl == NULL) { + if (!buttonctl) { EndDialog(hDlg, IDINVALPTRDLGITEM); } PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE); @@ -276,7 +276,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return FALSE; case WM_SETFOCUS: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRSETFOCUS); return TRUE; } @@ -288,7 +288,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return TRUE; case WM_COMMAND: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRCOMMAND); return TRUE; } @@ -344,7 +344,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) if (size > dialog->size) { void *data = SDL_realloc(dialog->data, size); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -387,12 +387,12 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) size_t count; SDL_bool status; - if (string == NULL) { + if (!string) { string = ""; } wstring = WIN_UTF8ToStringW(string); - if (wstring == NULL) { + if (!wstring) { return SDL_FALSE; } @@ -448,7 +448,7 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, if (!AddDialogData(dialog, &type, sizeof(type))) { return SDL_FALSE; } - if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) { + if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption)) { if (!AddDialogString(dialog, caption)) { return SDL_FALSE; } @@ -521,7 +521,7 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy); dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); - if (dialog == NULL) { + if (!dialog) { return NULL; } @@ -623,7 +623,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) size_t ampcount = 0; size_t srclen = 0; - if (src == NULL) { + if (!src) { return NULL; } @@ -642,7 +642,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) if (SIZE_MAX - srclen < ampcount) { return NULL; } - if (*dst == NULL || *dstlen < srclen + ampcount) { + if (!*dst || *dstlen < srclen + ampcount) { /* Allocating extra space in case the next strings are a bit longer. */ size_t extraspace = SIZE_MAX - (srclen + ampcount); if (extraspace > 512) { @@ -652,7 +652,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) SDL_free(*dst); *dst = NULL; newdst = SDL_malloc(*dstlen); - if (newdst == NULL) { + if (!newdst) { return NULL; } *dst = newdst; @@ -817,7 +817,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * Size.cy += ButtonHeight + TextMargin; dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); - if (dialog == NULL) { + if (!dialog) { return -1; } @@ -858,7 +858,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * buttontext = EscapeAmpersands(&escape, &escapesize, sdlButton->text); /* Make sure to provide the correct ID to keep buttons indexed in the * same order as how they are in messageboxdata. */ - if (buttontext == NULL || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { + if (!buttontext || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { FreeDialogData(dialog); SDL_free(ampescape); return -1; @@ -932,7 +932,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* If we cannot load comctl32.dll use the old messagebox! */ hComctl32 = LoadLibrary(TEXT("comctl32.dll")); - if (hComctl32 == NULL) { + if (!hComctl32) { return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -944,7 +944,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") */ pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect"); - if (pfnTaskDialogIndirect == NULL) { + if (!pfnTaskDialogIndirect) { FreeLibrary(hComctl32); return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -992,7 +992,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pButton->nButtonID = IDBUTTONINDEX0 + i; } buttontext = EscapeAmpersands(&escape, &escapesize, messageboxdata->buttons[i].text); - if (buttontext == NULL) { + if (!buttontext) { int j; FreeLibrary(hComctl32); SDL_free(ampescape); diff --git a/vs/sdl2/src/video/windows/SDL_windowsmessagebox.h b/vs/sdl2/src/video/windows/SDL_windowsmessagebox.h index b87ecfde7a..5cddc87e0a 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmessagebox.h +++ b/vs/sdl2/src/video/windows/SDL_windowsmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#if defined(SDL_VIDEO_DRIVER_WINDOWS) extern int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/windows/SDL_windowsmodes.c b/vs/sdl2/src/video/windows/SDL_windowsmodes.c index b8f47a13a1..9a37a11ac0 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmodes.c +++ b/vs/sdl2/src/video/windows/SDL_windowsmodes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "../../events/SDL_displayevents_c.h" @@ -171,7 +171,7 @@ static SDL_bool WIN_GetDisplayMode(_THIS, LPCWSTR deviceName, DWORD index, SDL_D } data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_FALSE; } @@ -215,7 +215,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) LONG rc; dll = SDL_LoadObject("USER32.DLL"); - if (dll == NULL) { + if (!dll) { return NULL; } @@ -223,7 +223,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig)SDL_LoadFunction(dll, "QueryDisplayConfig"); pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo)SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo"); - if (pGetDisplayConfigBufferSizes == NULL || pQueryDisplayConfig == NULL || pDisplayConfigGetDeviceInfo == NULL) { + if (!pGetDisplayConfigBufferSizes || !pQueryDisplayConfig || !pDisplayConfigGetDeviceInfo) { goto WIN_GetDisplayNameVista_failed; } @@ -238,7 +238,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) paths = (DISPLAYCONFIG_PATH_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); modes = (DISPLAYCONFIG_MODE_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); - if ((paths == NULL) || (modes == NULL)) { + if ((!paths) || (!modes)) { goto WIN_GetDisplayNameVista_failed; } @@ -352,7 +352,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, } displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return; } SDL_memcpy(displaydata->DeviceName, info->szDevice, sizeof(displaydata->DeviceName)); @@ -361,7 +361,7 @@ static void WIN_AddDisplay(_THIS, HMONITOR hMonitor, const MONITORINFOEXW *info, SDL_zero(display); display.name = WIN_GetDisplayNameVista(info->szDevice); - if (display.name == NULL) { + if (!display.name) { DISPLAY_DEVICEW device; SDL_zero(device); device.cb = sizeof(device); @@ -521,7 +521,7 @@ int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi_out, float * float hinches, vinches; hdc = GetDC(NULL); - if (hdc == NULL) { + if (!hdc) { return SDL_SetError("GetDC failed"); } hdpi_int = GetDeviceCaps(hdc, LOGPIXELSX); @@ -603,7 +603,7 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) *dpiOut = 96; } - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } @@ -656,7 +656,7 @@ void WIN_ScreenPointToSDL(int *x, int *y) float ddpi, hdpi, vdpi; int x_pixels, y_pixels; - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } diff --git a/vs/sdl2/src/video/windows/SDL_windowsmodes.h b/vs/sdl2/src/video/windows/SDL_windowsmodes.h index 1fc5eef608..9cec89ebd0 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmodes.h +++ b/vs/sdl2/src/video/windows/SDL_windowsmodes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsmouse.c b/vs/sdl2/src/video/windows/SDL_windowsmouse.c index 5844da79e4..214197b6b0 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmouse.c +++ b/vs/sdl2/src/video/windows/SDL_windowsmouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" @@ -114,7 +114,7 @@ static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) maskbitslen = ((surface->w + (pad - (surface->w % pad))) / 8) * surface->h; maskbits = SDL_small_alloc(Uint8, maskbitslen, &isstack); - if (maskbits == NULL) { + if (!maskbits) { SDL_OutOfMemory(); return NULL; } @@ -249,7 +249,7 @@ static void WIN_FreeCursor(SDL_Cursor *cursor) static int WIN_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = SDL_blank_cursor; } if (cursor) { @@ -282,6 +282,8 @@ static void WIN_WarpMouse(SDL_Window *window, int x, int y) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; HWND hwnd = data->hwnd; POINT pt; + int warp_x = x; + int warp_y = y; /* Don't warp the mouse while we're doing a modal interaction */ if (data->in_title_click || data->focus_click_pending) { @@ -295,7 +297,7 @@ static void WIN_WarpMouse(SDL_Window *window, int x, int y) WIN_SetCursorPos(pt.x, pt.y); /* Send the exact mouse motion associated with this warp */ - SDL_SendMouseMotion(window, SDL_GetMouse()->mouseID, 0, x, y); + SDL_SendMouseMotion(window, SDL_GetMouse()->mouseID, 0, warp_x, warp_y); } static int WIN_WarpMouseGlobal(int x, int y) diff --git a/vs/sdl2/src/video/windows/SDL_windowsmouse.h b/vs/sdl2/src/video/windows/SDL_windowsmouse.h index 262b6992a0..25f510e5e0 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsmouse.h +++ b/vs/sdl2/src/video/windows/SDL_windowsmouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsopengl.c b/vs/sdl2/src/video/windows/SDL_windowsopengl.c index 947e30946b..ba505f1e78 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsopengl.c +++ b/vs/sdl2/src/video/windows/SDL_windowsopengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS #include "SDL_loadso.h" #include "SDL_windowsvideo.h" @@ -29,7 +29,7 @@ /* WGL implementation of SDL OpenGL support */ -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL #include "SDL_opengl.h" #define DEFAULT_OPENGL "OPENGL32.DLL" @@ -97,7 +97,7 @@ typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, const int *attribList); -#if __XBOXONE__ || __XBOXSERIES__ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) #define GetDC(hwnd) (HDC) hwnd #define ReleaseDC(hwnd, hdc) 1 #define SwapBuffers _this->gl_data->wglSwapBuffers @@ -145,7 +145,7 @@ int WIN_GL_LoadLibrary(_THIS, const char *path) SDL_LoadFunction(handle, "wglShareLists"); /* *INDENT-ON* */ /* clang-format on */ -#if __XBOXONE__ || __XBOXSERIES__ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) _this->gl_data->wglSwapBuffers = (BOOL(WINAPI *)(HDC)) SDL_LoadFunction(handle, "wglSwapBuffers"); _this->gl_data->wglDescribePixelFormat = (int(WINAPI *)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR)) @@ -162,7 +162,7 @@ int WIN_GL_LoadLibrary(_THIS, const char *path) !_this->gl_data->wglCreateContext || !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent -#if __XBOXONE__ || __XBOXSERIES__ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) || !_this->gl_data->wglSwapBuffers || !_this->gl_data->wglDescribePixelFormat || !_this->gl_data->wglChoosePixelFormat || @@ -220,7 +220,7 @@ void *WIN_GL_GetProcAddress(_THIS, const char *proc) /* This is to pick up extensions */ func = _this->gl_data->wglGetProcAddress(proc); - if (func == NULL) { + if (!func) { /* This is probably a normal GL function */ func = GetProcAddress(_this->gl_config.dll_handle, proc); } @@ -383,7 +383,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } @@ -395,7 +395,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -527,6 +527,9 @@ static int WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs) int pixel_format = 0; unsigned int matching; + int qAttrib = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; + int srgb = 0; + hwnd = CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); @@ -546,6 +549,10 @@ static int WIN_GL_ChoosePixelFormatARB(_THIS, int *iAttribs, float *fAttribs) _this->gl_data->wglChoosePixelFormatARB(hdc, iAttribs, fAttribs, 1, &pixel_format, &matching); + + /* Check whether we actually got an SRGB capable buffer */ + _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0, 1, &qAttrib, &srgb); + _this->gl_config.framebuffer_srgb_capable = srgb; } _this->gl_data->wglMakeCurrent(hdc, NULL); @@ -702,7 +709,7 @@ SDL_GLContext WIN_GL_CreateContext(_THIS, SDL_Window *window) HGLRC context, share_context; if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Switch to EGL based functions */ WIN_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GLES_LoadLibrary; @@ -835,9 +842,9 @@ int WIN_GL_MakeCurrent(_THIS, SDL_Window *window, SDL_GLContext context) NULL, against spec. Since hdc is _supposed_ to be ignored if context is NULL, we either use the current GL window, or do nothing if we already have no current context. */ - if (window == NULL) { + if (!window) { window = SDL_GL_GetCurrentWindow(); - if (window == NULL) { + if (!window) { SDL_assert(SDL_GL_GetCurrentContext() == NULL); return 0; /* already done. */ } diff --git a/vs/sdl2/src/video/windows/SDL_windowsopengl.h b/vs/sdl2/src/video/windows/SDL_windowsopengl.h index 0d30068ad7..184a313ab0 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsopengl.h +++ b/vs/sdl2/src/video/windows/SDL_windowsopengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #ifndef SDL_windowsopengl_h_ #define SDL_windowsopengl_h_ -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL -#if __XBOXONE__ || __XBOXSERIES__ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) typedef struct tagPIXELFORMATDESCRIPTOR { WORD nSize; @@ -85,7 +85,7 @@ struct SDL_GLDriverData BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); BOOL (WINAPI *wglSwapIntervalEXT)(int interval); int (WINAPI *wglGetSwapIntervalEXT)(void); -#if __XBOXONE__ || __XBOXSERIES__ +#if defined(__XBOXONE__) || defined(__XBOXSERIES__) BOOL (WINAPI *wglSwapBuffers)(HDC hdc); int (WINAPI *wglDescribePixelFormat)(HDC hdc, int iPixelFormat, diff --git a/vs/sdl2/src/video/windows/SDL_windowsopengles.c b/vs/sdl2/src/video/windows/SDL_windowsopengles.c index d410141ead..1450d50159 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsopengles.c +++ b/vs/sdl2/src/video/windows/SDL_windowsopengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && defined(SDL_VIDEO_OPENGL_EGL) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsvideo.h" #include "SDL_windowsopengles.h" @@ -34,7 +34,7 @@ int WIN_GLES_LoadLibrary(_THIS, const char *path) /* If the profile requested is not GL ES, switch over to WIN_GL functions */ if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL WIN_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = WIN_GL_LoadLibrary; _this->GL_GetProcAddress = WIN_GL_GetProcAddress; @@ -51,7 +51,7 @@ int WIN_GLES_LoadLibrary(_THIS, const char *path) #endif } - if (_this->egl_data == NULL) { + if (!_this->egl_data) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0); } @@ -63,7 +63,7 @@ SDL_GLContext WIN_GLES_CreateContext(_THIS, SDL_Window *window) SDL_GLContext context; SDL_WindowData *data = (SDL_WindowData *)window->driverdata; -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { /* Switch to WGL based functions */ WIN_GLES_UnloadLibrary(_this); @@ -106,7 +106,7 @@ int WIN_GLES_SetupWindow(_THIS, SDL_Window *window) SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); - if (_this->egl_data == NULL) { + if (!_this->egl_data) { /* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ #if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */ SDL_assert(!_this->gl_config.driver_loaded); diff --git a/vs/sdl2/src/video/windows/SDL_windowsopengles.h b/vs/sdl2/src/video/windows/SDL_windowsopengles.h index 65b71f5c8d..f7844b47db 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsopengles.h +++ b/vs/sdl2/src/video/windows/SDL_windowsopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_winopengles_h_ #define SDL_winopengles_h_ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/windows/SDL_windowsshape.c b/vs/sdl2/src/video/windows/SDL_windowsshape.c index 9aa75d2cb9..fdeb1cdd36 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsshape.c +++ b/vs/sdl2/src/video/windows/SDL_windowsshape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__) #include "SDL_windowsshape.h" #include "SDL_windowsvideo.h" @@ -29,7 +29,7 @@ SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window) { int resized_properly; SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -77,8 +77,8 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo SDL_ShapeData *data; HRGN mask_region = NULL; - if ((shaper == NULL) || - (shape == NULL) || + if ((!shaper) || + (!shape) || ((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey)) || (shape->w != shaper->window->w) || (shape->h != shaper->window->h)) { @@ -86,7 +86,7 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo } data = (SDL_ShapeData *)shaper->driverdata; - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } data->mask_tree = SDL_CalculateShapeTree(*shape_mode, shape); @@ -103,15 +103,15 @@ int Win32_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData *data; - if (window == NULL) { + if (!window) { return -1; } data = (SDL_ShapeData *)window->shaper->driverdata; - if (data == NULL) { + if (!data) { return -1; } - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } if (window->shaper->hasshape == SDL_TRUE) { diff --git a/vs/sdl2/src/video/windows/SDL_windowsshape.h b/vs/sdl2/src/video/windows/SDL_windowsshape.h index 875538b930..e1ce96a186 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsshape.h +++ b/vs/sdl2/src/video/windows/SDL_windowsshape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsvideo.c b/vs/sdl2/src/video/windows/SDL_windowsvideo.c index 5621293f52..5f1902aae3 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsvideo.c +++ b/vs/sdl2/src/video/windows/SDL_windowsvideo.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS #include "SDL_main.h" #include "SDL_video.h" @@ -35,6 +35,7 @@ #include "SDL_windowsframebuffer.h" #include "SDL_windowsshape.h" #include "SDL_windowsvulkan.h" +#include "SDL_windowsmessagebox.h" /* #define HIGHDPI_DEBUG */ @@ -215,7 +216,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; #endif -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL device->GL_LoadLibrary = WIN_GL_LoadLibrary; device->GL_GetProcAddress = WIN_GL_GetProcAddress; device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; @@ -225,7 +226,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; device->GL_SwapWindow = WIN_GL_SwapWindow; device->GL_DeleteContext = WIN_GL_DeleteContext; -#elif SDL_VIDEO_OPENGL_EGL +#elif defined(SDL_VIDEO_OPENGL_EGL) /* Use EGL based functions */ device->GL_LoadLibrary = WIN_GLES_LoadLibrary; device->GL_GetProcAddress = WIN_GLES_GetProcAddress; @@ -237,7 +238,7 @@ static SDL_VideoDevice *WIN_CreateDevice(void) device->GL_SwapWindow = WIN_GLES_SwapWindow; device->GL_DeleteContext = WIN_GLES_DeleteContext; #endif -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions; @@ -262,7 +263,12 @@ static SDL_VideoDevice *WIN_CreateDevice(void) } VideoBootStrap WINDOWS_bootstrap = { - "windows", "SDL Windows video driver", WIN_CreateDevice + "windows", "SDL Windows video driver", WIN_CreateDevice, + #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) + WIN_ShowMessageBox + #else + NULL + #endif }; static BOOL WIN_DeclareDPIAwareUnaware(_THIS) @@ -385,7 +391,7 @@ static void WIN_InitDPIAwareness(_THIS) { const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "permonitorv2") == 0) { WIN_DeclareDPIAwarePerMonitorV2(_this); } else if (SDL_strcmp(hint, "permonitor") == 0) { @@ -540,7 +546,7 @@ int SDL_Direct3D9GetAdapterIndex(int displayIndex) SDL_DisplayData *pData = (SDL_DisplayData *)SDL_GetDisplayDriverData(displayIndex); int adapterIndex = D3DADAPTER_DEFAULT; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); adapterIndex = -1; /* make sure we return something invalid */ } else { @@ -623,12 +629,12 @@ SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputI IDXGIAdapter *pDXGIAdapter; IDXGIOutput *pDXGIOutput; - if (adapterIndex == NULL) { + if (!adapterIndex) { SDL_InvalidParamError("adapterIndex"); return SDL_FALSE; } - if (outputIndex == NULL) { + if (!outputIndex) { SDL_InvalidParamError("outputIndex"); return SDL_FALSE; } @@ -636,7 +642,7 @@ SDL_bool SDL_DXGIGetOutputInfo(int displayIndex, int *adapterIndex, int *outputI *adapterIndex = -1; *outputIndex = -1; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); return SDL_FALSE; } diff --git a/vs/sdl2/src/video/windows/SDL_windowsvideo.h b/vs/sdl2/src/video/windows/SDL_windowsvideo.h index 7c44328fb5..93ca1cb63e 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsvideo.h +++ b/vs/sdl2/src/video/windows/SDL_windowsvideo.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/windows/SDL_windowsvulkan.c b/vs/sdl2/src/video/windows/SDL_windowsvulkan.c index aa5f018233..01ab8a55e4 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsvulkan.c +++ b/vs/sdl2/src/video/windows/SDL_windowsvulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WINDOWS +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WINDOWS) #include "SDL_windowsvideo.h" #include "SDL_windowswindow.h" @@ -48,10 +48,10 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "vulkan-1.dll"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -76,7 +76,7 @@ int WIN_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/vs/sdl2/src/video/windows/SDL_windowsvulkan.h b/vs/sdl2/src/video/windows/SDL_windowsvulkan.h index b2fe17dedc..1545dcd89a 100644 --- a/vs/sdl2/src/video/windows/SDL_windowsvulkan.h +++ b/vs/sdl2/src/video/windows/SDL_windowsvulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../SDL_vulkan_internal.h" #include "../SDL_sysvideo.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_WINDOWS +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WINDOWS) int WIN_Vulkan_LoadLibrary(_THIS, const char *path); void WIN_Vulkan_UnloadLibrary(_THIS); diff --git a/vs/sdl2/src/video/windows/SDL_windowswindow.c b/vs/sdl2/src/video/windows/SDL_windowswindow.c index 1d128f7dda..cf49fbfbfc 100644 --- a/vs/sdl2/src/video/windows/SDL_windowswindow.c +++ b/vs/sdl2/src/video/windows/SDL_windowswindow.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_DRIVER_WINDOWS #include "../../core/windows/SDL_windows.h" @@ -179,7 +179,7 @@ static void WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL mon = MonitorFromRect(&screen_rect, MONITOR_DEFAULTTONEAREST); - if (videodata != NULL) { + if (videodata) { /* GetDpiForMonitor docs promise to return the same hdpi / vdpi */ if (videodata->GetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &frame_dpi, &unused) != S_OK) { frame_dpi = 96; @@ -300,7 +300,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, HWND hwnd, HWND parent, SD /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -477,7 +477,7 @@ static void CleanupWindowData(_THIS, SDL_Window *window) } } else { /* Restore any original event handler... */ - if (data->wndproc != NULL) { + if (data->wndproc) { #ifdef GWLP_WNDPROC SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, (LONG_PTR)data->wndproc); @@ -537,13 +537,13 @@ int WIN_CreateWindow(_THIS, SDL_Window *window) } /* The rest of this macro mess is for OpenGL or OpenGL ES windows */ -#if SDL_VIDEO_OPENGL_ES2 +#ifdef SDL_VIDEO_OPENGL_ES2 if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL && (!_this->gl_data || WIN_GL_UseEGL(_this)) #endif /* SDL_VIDEO_OPENGL_WGL */ ) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (WIN_GLES_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; @@ -555,7 +555,7 @@ int WIN_CreateWindow(_THIS, SDL_Window *window) } #endif /* SDL_VIDEO_OPENGL_ES2 */ -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL if (WIN_GL_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); return -1; @@ -596,7 +596,7 @@ int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) return -1; } -#if SDL_VIDEO_OPENGL_WGL +#ifdef SDL_VIDEO_OPENGL_WGL { const char *hint = SDL_GetHint(SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT); if (hint) { @@ -607,7 +607,7 @@ int WIN_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) (void)SDL_sscanf(hint, "%p", (void **)&otherWindow); /* Do some error checking on the pointer */ - if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) { + if (otherWindow && otherWindow->magic == &_this->window_magic) { /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */ if (otherWindow->flags & SDL_WINDOW_OPENGL) { window->flags |= SDL_WINDOW_OPENGL; @@ -1058,7 +1058,7 @@ void *WIN_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) filename_utf8 = WIN_StringToUTF8(data->ICMFileName); if (filename_utf8) { iccProfileData = SDL_LoadFile(filename_utf8, size); - if (iccProfileData == NULL) { + if (!iccProfileData) { SDL_SetError("Could not open ICC profile"); } SDL_free(filename_utf8); @@ -1224,7 +1224,7 @@ int SDL_HelperWindowCreate(void) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL); - if (SDL_HelperWindow == NULL) { + if (!SDL_HelperWindow) { UnregisterClass(SDL_HelperWindowClassName, hInstance); return WIN_SetError("Unable to create Helper Window"); } @@ -1263,7 +1263,7 @@ void WIN_OnWindowEnter(_THIS, SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - if (data == NULL || !data->hwnd) { + if (!data || !data->hwnd) { /* The window wasn't fully initialized */ return; } @@ -1273,6 +1273,13 @@ void WIN_OnWindowEnter(_THIS, SDL_Window *window) } } +static BOOL GetClientScreenRect(HWND hwnd, RECT *rect) +{ + return GetClientRect(hwnd, rect) && /* RECT( left , top , right , bottom ) */ + ClientToScreen(hwnd, (LPPOINT)rect) && /* POINT( left , top ) */ + ClientToScreen(hwnd, (LPPOINT)rect + 1); /* POINT( right , bottom ) */ +} + void WIN_UpdateClipCursor(SDL_Window *window) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; @@ -1293,7 +1300,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) (window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { if (mouse->relative_mode && !mouse->relative_mode_warp && data->mouse_relative_mode_center) { - if (GetWindowRect(data->hwnd, &rect)) { + if (GetClientScreenRect(data->hwnd, &rect)) { /* WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 */ LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0; LONG cx, cy; @@ -1314,9 +1321,7 @@ void WIN_UpdateClipCursor(SDL_Window *window) } } } else { - if (GetClientRect(data->hwnd, &rect)) { - ClientToScreen(data->hwnd, (LPPOINT)&rect); - ClientToScreen(data->hwnd, (LPPOINT)&rect + 1); + if (GetClientScreenRect(data->hwnd, &rect)) { if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { SDL_Rect mouse_rect_win_client; RECT mouse_rect, intersection; diff --git a/vs/sdl2/src/video/windows/SDL_windowswindow.h b/vs/sdl2/src/video/windows/SDL_windowswindow.h index fe2e35f582..20f78b97d4 100644 --- a/vs/sdl2/src/video/windows/SDL_windowswindow.h +++ b/vs/sdl2/src/video/windows/SDL_windowswindow.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_windowswindow_h_ #define SDL_windowswindow_h_ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "../SDL_egl_c.h" #else #include "../SDL_sysvideo.h" @@ -64,7 +64,7 @@ typedef struct SDL_bool mouse_tracked; WCHAR *ICMFileName; struct SDL_VideoData *videodata; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif /** diff --git a/vs/sdl2/src/video/windows/wmmsg.h b/vs/sdl2/src/video/windows/wmmsg.h index d0cb887fcc..86e6c2a900 100644 --- a/vs/sdl2/src/video/windows/wmmsg.h +++ b/vs/sdl2/src/video/windows/wmmsg.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/winrt/SDL_winrtevents.cpp b/vs/sdl2/src/video/winrt/SDL_winrtevents.cpp index 30d1fac4b5..79468f7cdd 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtevents.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtevents.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* * Windows includes: diff --git a/vs/sdl2/src/video/winrt/SDL_winrtevents_c.h b/vs/sdl2/src/video/winrt/SDL_winrtevents_c.h index b761a40367..d08cf9aeaa 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtevents_c.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtevents_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/winrt/SDL_winrtgamebar.cpp b/vs/sdl2/src/video/winrt/SDL_winrtgamebar.cpp index fd71a55be3..e56def1d11 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtgamebar.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtgamebar.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* Windows includes */ #include @@ -116,7 +116,7 @@ static void WINRT_HandleGameBarIsInputRedirected_MainThread() return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { /* Shouldn't happen, but just in case... */ return; } @@ -167,11 +167,11 @@ void WINRT_QuitGameBar(_THIS) { SDL_VideoData *driverdata; IGameBarStatics_ *gameBar; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { return; } driverdata = (SDL_VideoData *)_this->driverdata; diff --git a/vs/sdl2/src/video/winrt/SDL_winrtgamebar_cpp.h b/vs/sdl2/src/video/winrt/SDL_winrtgamebar_cpp.h index 059a62cfeb..7e3f5d9277 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtgamebar_cpp.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtgamebar_cpp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/winrt/SDL_winrtkeyboard.cpp b/vs/sdl2/src/video/winrt/SDL_winrtkeyboard.cpp index 9e6e141c46..26a1902d5d 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtkeyboard.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtkeyboard.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* Windows-specific includes */ #include diff --git a/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.cpp b/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.cpp index 42a8f3207e..a2d66a3c4f 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT extern "C" { #include "SDL_messagebox.h" @@ -41,9 +41,9 @@ static String ^ WINRT_UTF8ToPlatformString(const char *str) { return rtstr; } - extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) +extern "C" int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) { -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION == NTDDI_WIN8) +#if SDL_WINAPI_FAMILY_PHONE && (NTDDI_VERSION == NTDDI_WIN8) /* Sadly, Windows Phone 8 doesn't include the MessageDialog class that * Windows 8.x/RT does, even though MSDN's reference documentation for * Windows Phone 8 mentions it. @@ -55,7 +55,7 @@ static String ^ WINRT_UTF8ToPlatformString(const char *str) { #else SDL_VideoDevice *_this = SDL_GetVideoDevice(); -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE const int maxbuttons = 2; const char *platform = "Windows Phone 8.1+"; #else @@ -106,7 +106,7 @@ static String ^ WINRT_UTF8ToPlatformString(const char *str) { *buttonid = messageboxdata->buttons[clicked_index].buttonid; } return 0; -#endif /* if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP / else */ +#endif /* if SDL_WINAPI_FAMILY_PHONE / else */ } #endif /* SDL_VIDEO_DRIVER_WINRT */ diff --git a/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.h b/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.h index 4ea65c550c..ab02d3a8b9 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtmessagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT extern int WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/winrt/SDL_winrtmouse.cpp b/vs/sdl2/src/video/winrt/SDL_winrtmouse.cpp index 05fae956a5..e46687fd48 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtmouse.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtmouse.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* * Windows includes: @@ -215,7 +215,7 @@ void WINRT_InitMouse(_THIS) - programmatically moveable cursors */ -#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP +#if !SDL_WINAPI_FAMILY_PHONE // mouse->CreateCursor = WINRT_CreateCursor; mouse->CreateSystemCursor = WINRT_CreateSystemCursor; mouse->ShowCursor = WINRT_ShowCursor; diff --git a/vs/sdl2/src/video/winrt/SDL_winrtmouse_c.h b/vs/sdl2/src/video/winrt/SDL_winrtmouse_c.h index 730bb1ea51..2271a14cdb 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtmouse_c.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtmouse_c.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/winrt/SDL_winrtopengles.cpp b/vs/sdl2/src/video/winrt/SDL_winrtopengles.cpp index 34889595b3..cf70241746 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtopengles.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtopengles.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_WINRT) && defined(SDL_VIDEO_OPENGL_EGL) /* EGL implementation of SDL OpenGL support */ @@ -144,7 +144,7 @@ WINRT_GLES_LoadLibrary(_THIS, const char *path) return SDL_EGL_SetError("Could not retrieve ANGLE/WinRT display function(s)", "eglGetProcAddress"); } -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) +#if !SDL_WINAPI_FAMILY_PHONE /* Try initializing EGL at D3D11 Feature Level 10_0+ (which is not * supported on WinPhone 8.x. */ diff --git a/vs/sdl2/src/video/winrt/SDL_winrtopengles.h b/vs/sdl2/src/video/winrt/SDL_winrtopengles.h index dc495609dc..c48a2df67d 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtopengles.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtopengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_winrtopengles_h_ #define SDL_winrtopengles_h_ -#if SDL_VIDEO_DRIVER_WINRT && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_WINRT) && defined(SDL_VIDEO_OPENGL_EGL) #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/winrt/SDL_winrtpointerinput.cpp b/vs/sdl2/src/video/winrt/SDL_winrtpointerinput.cpp index e80d99dfee..63c2c86054 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtpointerinput.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtpointerinput.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* SDL includes */ #include "SDL_winrtevents_c.h" @@ -78,7 +78,7 @@ WINRT_TransformCursorPosition(SDL_Window *window, // Compute coordinates normalized from 0..1. // If the coordinates need to be sized to the SDL window, // we'll do that after. -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8) +#if !SDL_WINAPI_FAMILY_PHONE || (NTDDI_VERSION > NTDDI_WIN8) outputPosition.X = rawPosition.X / nativeWindow->Bounds.Width; outputPosition.Y = rawPosition.Y / nativeWindow->Bounds.Height; #else @@ -116,7 +116,7 @@ SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt { using namespace Windows::UI::Input; -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE *button = SDL_BUTTON_LEFT; return SDL_TRUE; #else @@ -197,7 +197,7 @@ SDL_bool WINRT_GetSDLButtonForPointerPoint(Windows::UI::Input::PointerPoint ^ pt static bool WINRT_IsTouchEvent(Windows::UI::Input::PointerPoint ^ pointerPoint) { -#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP +#if SDL_WINAPI_FAMILY_PHONE return true; #else using namespace Windows::Devices::Input; diff --git a/vs/sdl2/src/video/winrt/SDL_winrtvideo.cpp b/vs/sdl2/src/video/winrt/SDL_winrtvideo.cpp index 9a38e6ccc4..9160bbb638 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtvideo.cpp +++ b/vs/sdl2/src/video/winrt/SDL_winrtvideo.cpp @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_WINRT +#ifdef SDL_VIDEO_DRIVER_WINRT /* WinRT SDL video driver implementation @@ -29,10 +29,8 @@ */ /* Standard C++11 includes */ -#include -#include #include -using namespace std; +#include /* Windows includes */ #include @@ -61,6 +59,7 @@ extern "C" { #include "SDL_syswm.h" #include "SDL_winrtopengles.h" #include "../../core/windows/SDL_windows.h" +#include "SDL_winrtmessagebox.h" } #include "../../core/winrt/SDL_winrtapp_direct3d.h" @@ -116,13 +115,13 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return 0; @@ -166,10 +165,10 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) return device; } -#define WINRTVID_DRIVER_NAME "winrt" VideoBootStrap WINRT_bootstrap = { - WINRTVID_DRIVER_NAME, "SDL WinRT video driver", - WINRT_CreateDevice + "winrt", "SDL WinRT video driver", + WINRT_CreateDevice, + WINRT_ShowMessageBox }; static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const char *name, const char *oldValue, const char *newValue) @@ -182,7 +181,7 @@ static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const * * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'. */ - if ((oldValue == NULL) && (newValue == NULL)) { + if ((!oldValue) && (!newValue)) { return; } @@ -337,7 +336,7 @@ static int WINRT_AddDisplaysForOutput(_THIS, IDXGIAdapter1 *dxgiAdapter1, int ou } dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC)); - if (dxgiModes == NULL) { + if (!dxgiModes) { SDL_OutOfMemory(); goto done; } @@ -406,7 +405,7 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a if (adapterIndex == 0 && outputIndex == 0) { SDL_VideoDisplay display; SDL_DisplayMode mode; -#if SDL_WINRT_USE_APPLICATIONVIEW +#ifdef SDL_WINRT_USE_APPLICATIONVIEW ApplicationView ^ appView = ApplicationView::GetForCurrentView(); #endif CoreWindow ^ coreWin = CoreWindow::GetForCurrentThread(); @@ -421,7 +420,7 @@ static int WINRT_AddDisplaysForAdapter(_THIS, IDXGIFactory2 *dxgiFactory2, int a failing test), whereas CoreWindow might not. -- DavidL */ -#if (NTDDI_VERSION >= NTDDI_WIN10) || (SDL_WINRT_USE_APPLICATIONVIEW && WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) +#if (NTDDI_VERSION >= NTDDI_WIN10) || (defined(SDL_WINRT_USE_APPLICATIONVIEW) && SDL_WINAPI_FAMILY_PHONE) mode.w = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Width); mode.h = WINRT_DIPS_TO_PHYSICAL_PIXELS(appView->VisibleBounds.Height); #else @@ -500,11 +499,11 @@ WINRT_DetectWindowFlags(SDL_Window *window) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; bool is_fullscreen = false; -#if SDL_WINRT_USE_APPLICATIONVIEW +#ifdef SDL_WINRT_USE_APPLICATIONVIEW if (data->appView) { is_fullscreen = data->appView->IsFullScreenMode; } -#elif (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION == NTDDI_WIN8) +#elif SDL_WINAPI_FAMILY_PHONE || (NTDDI_VERSION == NTDDI_WIN8) is_fullscreen = true; #endif @@ -514,13 +513,13 @@ WINRT_DetectWindowFlags(SDL_Window *window) int w = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Width); int h = WINRT_DIPS_TO_PHYSICAL_PIXELS(data->coreWindow->Bounds.Height); -#if (WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP) || (NTDDI_VERSION > NTDDI_WIN8) +#if !SDL_WINAPI_FAMILY_PHONE || (NTDDI_VERSION > NTDDI_WIN8) // On all WinRT platforms, except for WinPhone 8.0, rotate the // window size. This is needed to properly calculate // fullscreen vs. maximized. const DisplayOrientations currentOrientation = WINRT_DISPLAY_PROPERTY(CurrentOrientation); switch (currentOrientation) { -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) +#if SDL_WINAPI_FAMILY_PHONE case DisplayOrientations::Landscape: case DisplayOrientations::LandscapeFlipped: #else @@ -548,7 +547,7 @@ WINRT_DetectWindowFlags(SDL_Window *window) latestFlags |= SDL_WINDOW_HIDDEN; } -#if (WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP) && (NTDDI_VERSION < NTDDI_WINBLUE) +#if SDL_WINAPI_FAMILY_PHONE && (NTDDI_VERSION < NTDDI_WINBLUE) // data->coreWindow->PointerPosition is not supported on WinPhone 8.0 latestFlags |= SDL_WINDOW_MOUSE_FOCUS; #else @@ -622,7 +621,7 @@ int WINRT_CreateWindow(_THIS, SDL_Window *window) */ if (!WINRT_XAMLWasEnabled) { data->coreWindow = CoreWindow::GetForCurrentThread(); -#if SDL_WINRT_USE_APPLICATIONVIEW +#ifdef SDL_WINRT_USE_APPLICATIONVIEW data->appView = ApplicationView::GetForCurrentView(); #endif } @@ -630,7 +629,7 @@ int WINRT_CreateWindow(_THIS, SDL_Window *window) /* Make note of the requested window flags, before they start getting changed. */ const Uint32 requestedFlags = window->flags; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL /* Setup the EGL surface, but only if OpenGL ES 2 was requested. */ if (!(window->flags & SDL_WINDOW_OPENGL)) { /* OpenGL ES 2 wasn't requested. Don't set up an EGL surface. */ @@ -685,7 +684,7 @@ int WINRT_CreateWindow(_THIS, SDL_Window *window) SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (data->egl_surface) { window->flags |= SDL_WINDOW_OPENGL; } diff --git a/vs/sdl2/src/video/winrt/SDL_winrtvideo_cpp.h b/vs/sdl2/src/video/winrt/SDL_winrtvideo_cpp.h index a34b79e605..a60b3aa742 100644 --- a/vs/sdl2/src/video/winrt/SDL_winrtvideo_cpp.h +++ b/vs/sdl2/src/video/winrt/SDL_winrtvideo_cpp.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -99,7 +99,7 @@ struct SDL_WindowData #ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif -#if SDL_WINRT_USE_APPLICATIONVIEW +#ifdef SDL_WINRT_USE_APPLICATIONVIEW Windows::UI::ViewManagement::ApplicationView ^ appView; #endif }; diff --git a/vs/sdl2/src/video/x11/SDL_x11clipboard.c b/vs/sdl2/src/video/x11/SDL_x11clipboard.c index 6c84278f4c..cf826a5598 100644 --- a/vs/sdl2/src/video/x11/SDL_x11clipboard.c +++ b/vs/sdl2/src/video/x11/SDL_x11clipboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include /* For INT_MAX */ @@ -132,10 +132,7 @@ static int SetSelectionText(_THIS, const char *text, Atom selection_type) X11_GetSDLCutBufferClipboardInternalFormat(display, SDL_X11_CLIPBOARD_MIME_TYPE_STRING), 8, PropModeReplace, (const unsigned char *)text, SDL_strlen(text)); - if (X11_XGetSelectionOwner(display, selection_type) != window) { - X11_XSetSelectionOwner(display, selection_type, window, CurrentTime); - } - + X11_XSetSelectionOwner(display, selection_type, window, CurrentTime); return 0; } @@ -209,7 +206,7 @@ static char *GetSlectionText(_THIS, Atom selection_type) X11_XFree(src); } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } diff --git a/vs/sdl2/src/video/x11/SDL_x11clipboard.h b/vs/sdl2/src/video/x11/SDL_x11clipboard.h index 21575dda41..c9849b7bb5 100644 --- a/vs/sdl2/src/video/x11/SDL_x11clipboard.h +++ b/vs/sdl2/src/video/x11/SDL_x11clipboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11dyn.c b/vs/sdl2/src/video/x11/SDL_x11dyn.c index 8187299708..7a4f5cc0e6 100644 --- a/vs/sdl2/src/video/x11/SDL_x11dyn.c +++ b/vs/sdl2/src/video/x11/SDL_x11dyn.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #define DEBUG_DYNAMIC_X11 0 @@ -75,22 +75,22 @@ static void *X11_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { fn = SDL_LoadFunction(x11libs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_X11 - if (fn != NULL) + if (fn) printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn); else printf("X11: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -136,7 +136,7 @@ void SDL_X11_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } @@ -157,7 +157,7 @@ int SDL_X11_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].libname != NULL) { + if (x11libs[i].libname) { x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } diff --git a/vs/sdl2/src/video/x11/SDL_x11dyn.h b/vs/sdl2/src/video/x11/SDL_x11dyn.h index a18e41f244..5a78ad0004 100644 --- a/vs/sdl2/src/video/x11/SDL_x11dyn.h +++ b/vs/sdl2/src/video/x11/SDL_x11dyn.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 #include -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM #include #endif @@ -46,25 +46,25 @@ #include #endif -#if SDL_VIDEO_DRIVER_X11_XCURSOR +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR #include #endif -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE #include #endif -#if SDL_VIDEO_DRIVER_X11_XINPUT2 || SDL_VIDEO_DRIVER_X11_XFIXES +#if defined(SDL_VIDEO_DRIVER_X11_XINPUT2) || defined(SDL_VIDEO_DRIVER_X11_XFIXES) #include #endif -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES #include #endif -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR #include #endif -#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER #include #endif -#if SDL_VIDEO_DRIVER_X11_XSHAPE +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE #include #endif diff --git a/vs/sdl2/src/video/x11/SDL_x11events.c b/vs/sdl2/src/video/x11/SDL_x11events.c index a28ccce3dd..21b66ff778 100644 --- a/vs/sdl2/src/video/x11/SDL_x11events.c +++ b/vs/sdl2/src/video/x11/SDL_x11events.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include #include @@ -102,7 +102,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -224,7 +224,7 @@ static int X11_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -300,7 +300,7 @@ static char *X11_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -324,7 +324,7 @@ static char *X11_URIToLocal(char *uri) return file; } -#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS static void X11_HandleGenericEvent(SDL_VideoData *videodata, XEvent *xev) { /* event is a union, so cookie == &event, but this is type safe. */ @@ -756,7 +756,7 @@ static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int { int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out); if (IsHighLatin1(buffer_return, result)) { - char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result); + char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result + 1); if (utf8_text) { SDL_strlcpy(buffer_return, utf8_text, bytes_buffer); SDL_free(utf8_text); @@ -841,14 +841,14 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) return; } -#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS if (xevent->type == GenericEvent) { X11_HandleGenericEvent(videodata, xevent); return; } #endif -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR if (videodata->xrandr_event_base && (xevent->type == (videodata->xrandr_event_base + RRNotify))) { X11_HandleXRandREvent(_this, xevent); } @@ -869,6 +869,27 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) xevent->type, xevent->xany.display, xevent->xany.window); #endif +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + if (SDL_X11_HAVE_XFIXES && + xevent->type == X11_GetXFixesSelectionNotifyEvent()) { + XFixesSelectionNotifyEvent *ev = (XFixesSelectionNotifyEvent *) xevent; + + /* !!! FIXME: cache atoms */ + Atom XA_CLIPBOARD = X11_XInternAtom(display, "CLIPBOARD", 0); + +#ifdef DEBUG_XEVENTS + printf("window CLIPBOARD: XFixesSelectionNotify (selection = %s)\n", + X11_XGetAtomName(display, ev->selection)); +#endif + + if (ev->selection == XA_PRIMARY || + (XA_CLIPBOARD != None && ev->selection == XA_CLIPBOARD)) { + SDL_SendClipboardUpdate(); + return; + } + } +#endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ + if ((videodata->clipboard_window != None) && (videodata->clipboard_window == xevent->xany.window)) { X11_HandleClipboardEvent(_this, xevent); @@ -885,7 +906,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) } } } - if (data == NULL) { + if (!data) { /* The window for KeymapNotify, etc events is 0 */ if (xevent->type == KeymapNotify) { #ifdef DEBUG_XEVENTS @@ -960,7 +981,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) mouse->last_x = xevent->xcrossing.x; mouse->last_y = xevent->xcrossing.y; -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES { /* Only create the barriers if we have input focus */ SDL_WindowData *windowdata = (SDL_WindowData *)data->window->driverdata; @@ -1072,7 +1093,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; } -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES /* Disable confinement if it is activated. */ if (data->pointer_barrier_active == SDL_TRUE) { X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); @@ -1159,7 +1180,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) X11_DispatchUnmapNotify(data); } -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES /* Disable confinement if the window gets hidden. */ if (data->pointer_barrier_active == SDL_TRUE) { X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); @@ -1175,7 +1196,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) #endif X11_DispatchMapNotify(data); -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES /* Enable confinement if it was activated. */ if (data->pointer_barrier_active == SDL_TRUE) { X11_ConfineCursorWithFlags(_this, data->window, &data->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); @@ -1549,7 +1570,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) char *name = X11_XGetAtomName(display, target); if (name) { char *token = SDL_strtokr((char *)p.data, "\r\n", &saveptr); - while (token != NULL) { + while (token) { if (SDL_strcmp("text/plain", name) == 0) { SDL_SendDropText(data->window, token); } else if (SDL_strcmp("text/uri-list", name) == 0) { @@ -1717,7 +1738,7 @@ void X11_PumpEvents(_THIS) SDL_TICKS_PASSED(now, data->screensaver_activity + 30000)) { X11_XResetScreenSaver(data->display); -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS SDL_DBus_ScreensaverTickle(); #endif @@ -1753,13 +1774,13 @@ void X11_PumpEvents(_THIS) void X11_SuspendScreenSaver(_THIS) { -#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int dummy; int major_version, minor_version; #endif /* SDL_VIDEO_DRIVER_X11_XSCRNSAVER */ -#if SDL_USE_LIBDBUS +#ifdef SDL_USE_LIBDBUS if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { return; } @@ -1769,7 +1790,7 @@ void X11_SuspendScreenSaver(_THIS) } #endif -#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER if (SDL_X11_HAVE_XSS) { /* X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 */ if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || diff --git a/vs/sdl2/src/video/x11/SDL_x11events.h b/vs/sdl2/src/video/x11/SDL_x11events.h index 1c595f98be..cec823c0c3 100644 --- a/vs/sdl2/src/video/x11/SDL_x11events.h +++ b/vs/sdl2/src/video/x11/SDL_x11events.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11framebuffer.c b/vs/sdl2/src/video/x11/SDL_x11framebuffer.c index 403dbd338f..0a63eda7c0 100644 --- a/vs/sdl2/src/video/x11/SDL_x11framebuffer.c +++ b/vs/sdl2/src/video/x11/SDL_x11framebuffer.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_x11video.h" #include "SDL_x11framebuffer.h" @@ -127,7 +127,7 @@ int X11_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, #endif /* not NO_SHARED_MEMORY */ *pixels = SDL_malloc((size_t)h * (*pitch)); - if (*pixels == NULL) { + if (!*pixels) { return SDL_OutOfMemory(); } @@ -226,7 +226,7 @@ void X11_DestroyWindowFramebuffer(_THIS, SDL_Window *window) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/vs/sdl2/src/video/x11/SDL_x11framebuffer.h b/vs/sdl2/src/video/x11/SDL_x11framebuffer.h index 0330223350..f5fe14224b 100644 --- a/vs/sdl2/src/video/x11/SDL_x11framebuffer.h +++ b/vs/sdl2/src/video/x11/SDL_x11framebuffer.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11keyboard.c b/vs/sdl2/src/video/x11/SDL_x11keyboard.c index 12818ed69c..9a23baf324 100644 --- a/vs/sdl2/src/video/x11/SDL_x11keyboard.c +++ b/vs/sdl2/src/video/x11/SDL_x11keyboard.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_hints.h" #include "SDL_misc.h" @@ -100,7 +100,7 @@ X11_KeyCodeToSym(_THIS, KeyCode keycode, unsigned char group) SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; KeySym keysym; -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM if (data->xkb) { int num_groups = XkbKeyNumGroups(data->xkb, keycode); unsigned char info = XkbKeyGroupInfo(data->xkb, keycode); @@ -155,7 +155,7 @@ int X11_InitKeyboard(_THIS) int distance; Bool xkb_repeat = 0; -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM { int xkb_major = XkbMajorVersion; int xkb_minor = XkbMinorVersion; @@ -347,7 +347,7 @@ void X11_UpdateKeymap(_THIS, SDL_bool send_event) SDL_GetDefaultKeymap(keymap); -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM if (data->xkb) { XkbStateRec state; X11_XkbGetUpdatedMap(data->display, XkbAllClientInfoMask, data->xkb); @@ -403,7 +403,7 @@ void X11_QuitKeyboard(_THIS) { SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM if (data->xkb) { X11_XkbFreeKeyboard(data->xkb, 0, True); data->xkb = NULL; @@ -451,7 +451,7 @@ void X11_StopTextInput(_THIS) void X11_SetTextInputRect(_THIS, const SDL_Rect *rect) { - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/vs/sdl2/src/video/x11/SDL_x11keyboard.h b/vs/sdl2/src/video/x11/SDL_x11keyboard.h index c6be19c0ef..53cf51253b 100644 --- a/vs/sdl2/src/video/x11/SDL_x11keyboard.h +++ b/vs/sdl2/src/video/x11/SDL_x11keyboard.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11messagebox.c b/vs/sdl2/src/video/x11/SDL_x11messagebox.c index 12e40f46d5..0e3b67af11 100644 --- a/vs/sdl2/src/video/x11/SDL_x11messagebox.c +++ b/vs/sdl2/src/video/x11/SDL_x11messagebox.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL.h" #include "SDL_x11video.h" @@ -84,7 +84,7 @@ typedef struct SDL_MessageBoxDataX11 Display *display; int screen; Window window; -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE XdbeBackBuffer buf; SDL_bool xdbe; /* Whether Xdbe is present or not */ #endif @@ -191,15 +191,15 @@ static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxD int num_missing = 0; data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, &missing, &num_missing, NULL); - if (missing != NULL) { + if (missing) { X11_XFreeStringList(missing); } - if (data->font_set == NULL) { + if (!data->font_set) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { data->font_struct = X11_XLoadQueryFont(data->display, g_MessageBoxFontLatin1); - if (data->font_struct == NULL) { + if (!data->font_struct) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } } @@ -240,12 +240,12 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) const SDL_MessageBoxData *messageboxdata = data->messageboxdata; /* Go over text and break linefeeds into separate lines. */ - if (messageboxdata != NULL && messageboxdata->message[0]) { + if (messageboxdata && messageboxdata->message[0]) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); TextLineData *plinedata = (TextLineData *)SDL_malloc(sizeof(TextLineData) * linecount); - if (plinedata == NULL) { + if (!plinedata) { return SDL_OutOfMemory(); } @@ -273,7 +273,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) text += length + 1; /* Break if there are no more linefeeds. */ - if (lf == NULL) { + if (!lf) { break; } } @@ -362,17 +362,17 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) /* Free SDL_MessageBoxData data. */ static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) { - if (data->font_set != NULL) { + if (data->font_set) { X11_XFreeFontSet(data->display, data->font_set); data->font_set = NULL; } - if (data->font_struct != NULL) { + if (data->font_struct) { X11_XFreeFont(data->display, data->font_struct); data->font_struct = NULL; } -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE if (SDL_X11_HAVE_XDBE && data->xdbe) { X11_XdbeDeallocateBackBufferName(data->display, data->buf); } @@ -499,7 +499,7 @@ static int X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) X11_XMapRaised(display, data->window); -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE /* Initialise a back buffer for double buffering */ if (SDL_X11_HAVE_XDBE) { int xdbe_major, xdbe_minor; @@ -522,7 +522,7 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) Drawable window = data->window; Display *display = data->display; -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE if (SDL_X11_HAVE_XDBE && data->xdbe) { window = data->buf; X11_XdbeBeginIdiom(data->display); @@ -577,7 +577,7 @@ static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) } } -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE if (SDL_X11_HAVE_XDBE && data->xdbe) { XdbeSwapInfo swap_info; swap_info.swap_window = data->window; @@ -762,9 +762,9 @@ static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int #if SDL_SET_LOCALE origlocale = setlocale(LC_ALL, NULL); - if (origlocale != NULL) { + if (origlocale) { origlocale = SDL_strdup(origlocale); - if (origlocale == NULL) { + if (!origlocale) { return SDL_OutOfMemory(); } (void)setlocale(LC_ALL, ""); diff --git a/vs/sdl2/src/video/x11/SDL_x11messagebox.h b/vs/sdl2/src/video/x11/SDL_x11messagebox.h index 8e4cc03389..16759798f6 100644 --- a/vs/sdl2/src/video/x11/SDL_x11messagebox.h +++ b/vs/sdl2/src/video/x11/SDL_x11messagebox.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +22,7 @@ #ifndef SDL_x11messagebox_h_ #define SDL_x11messagebox_h_ -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 extern int X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid); diff --git a/vs/sdl2/src/video/x11/SDL_x11modes.c b/vs/sdl2/src/video/x11/SDL_x11modes.c index e3c24b24b3..35c02e304f 100644 --- a/vs/sdl2/src/video/x11/SDL_x11modes.c +++ b/vs/sdl2/src/video/x11/SDL_x11modes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_hints.h" #include "SDL_x11video.h" @@ -144,7 +144,7 @@ Uint32 X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo) return SDL_PIXELFORMAT_UNKNOWN; } -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR static SDL_bool CheckXRandR(Display *display, int *major, int *minor) { /* Default the extension not available */ @@ -323,7 +323,7 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output } output_info = X11_XRRGetOutputInfo(dpy, res, outputid); - if (output_info == NULL || !output_info->crtc || output_info->connection == RR_Disconnected) { + if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { X11_XRRFreeOutputInfo(output_info); return 0; /* ignore this one. */ } @@ -335,7 +335,7 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output X11_XRRFreeOutputInfo(output_info); crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); - if (crtc == NULL) { + if (!crtc) { return 0; /* oh well, ignore it. */ } @@ -351,12 +351,12 @@ static int X11_AddXRandRDisplay(_THIS, Display *dpy, int screen, RROutput output X11_XRRFreeCrtcInfo(crtc); displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -413,11 +413,11 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent SDL_assert((displayidx == -1) == (display == NULL)); if (ev->connection == RR_Disconnected) { /* output is going away */ - if (display != NULL) { + if (display) { SDL_DelVideoDisplay(displayidx); } } else if (ev->connection == RR_Connected) { /* output is coming online */ - if (display != NULL) { + if (display) { /* !!! FIXME: update rotation or current mode of existing display? */ } else { Display *dpy = ev->display; @@ -425,7 +425,7 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent XVisualInfo vinfo; if (get_visualinfo(dpy, screen, &vinfo) == 0) { XRRScreenResources *res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } @@ -481,13 +481,13 @@ static int X11_InitModes_XRandR(_THIS) } res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } res = X11_XRRGetScreenResources(dpy, RootWindow(dpy, screen)); - if (res == NULL) { + if (!res) { continue; } } @@ -525,7 +525,7 @@ static int GetXftDPI(Display *dpy) xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi"); - if (xdefault_resource == NULL) { + if (!xdefault_resource) { return 0; } @@ -578,12 +578,12 @@ static int X11_InitModes_StdXlib(_THIS) mode.refresh_rate = 0; /* don't know it, sorry. */ displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -637,7 +637,7 @@ int X11_InitModes(_THIS) /* XRandR is the One True Modern Way to do this on X11. If this fails, we just won't report any display modes except the current desktop size. */ -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR { SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int xrandr_major, xrandr_minor; @@ -668,7 +668,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) mode.format = sdl_display->current_mode.format; mode.driverdata = NULL; -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR if (data->use_xrandr) { Display *display = ((SDL_VideoData *)_this->driverdata)->display; XRRScreenResources *res; @@ -683,7 +683,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { continue; } mode.driverdata = modedata; @@ -716,7 +716,7 @@ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay *sdl_display) } } -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR /* This catches an error from XRRSetScreenSize, as a workaround for now. */ /* !!! FIXME: remove this later when we have a better solution. */ static int (*PreXRRSetScreenSizeErrorHandler)(Display *, XErrorEvent *) = NULL; @@ -739,7 +739,7 @@ int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *sdl_display, SDL_DisplayMode *mo viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2); -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR if (data->use_xrandr) { Display *display = viddata->display; SDL_DisplayModeData *modedata = (SDL_DisplayModeData *)mode->driverdata; @@ -750,18 +750,18 @@ int X11_SetDisplayMode(_THIS, SDL_VideoDisplay *sdl_display, SDL_DisplayMode *mo Status status; res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); - if (res == NULL) { + if (!res) { return SDL_SetError("Couldn't get XRandR screen resources"); } output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); - if (output_info == NULL || output_info->connection == RR_Disconnected) { + if (!output_info || output_info->connection == RR_Disconnected) { X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR output info"); } crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); - if (crtc == NULL) { + if (!crtc) { X11_XRRFreeOutputInfo(output_info); X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR crtc info"); diff --git a/vs/sdl2/src/video/x11/SDL_x11modes.h b/vs/sdl2/src/video/x11/SDL_x11modes.h index 178c7277cf..8c6c1c24e4 100644 --- a/vs/sdl2/src/video/x11/SDL_x11modes.h +++ b/vs/sdl2/src/video/x11/SDL_x11modes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +37,14 @@ typedef struct SDL_bool use_xrandr; -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR RROutput xrandr_output; #endif } SDL_DisplayData; typedef struct { -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR RRMode xrandr_mode; #else int unused; /* just so struct isn't empty. */ @@ -65,7 +65,7 @@ extern int X11_GetDisplayBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect * extern int X11_GetDisplayUsableBounds(_THIS, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); extern int X11_GetDisplayDPI(_THIS, SDL_VideoDisplay *sdl_display, float *ddpi, float *hdpi, float *vdpi); -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR extern void X11_HandleXRandREvent(_THIS, const XEvent *xevent); #endif diff --git a/vs/sdl2/src/video/x11/SDL_x11mouse.c b/vs/sdl2/src/video/x11/SDL_x11mouse.c index 978a305847..0938de99f8 100644 --- a/vs/sdl2/src/video/x11/SDL_x11mouse.c +++ b/vs/sdl2/src/video/x11/SDL_x11mouse.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include #include "SDL_x11video.h" @@ -80,7 +80,7 @@ static SDL_Cursor *X11_CreateDefaultCursor() return cursor; } -#if SDL_VIDEO_DRIVER_X11_XCURSOR +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y) { Display *display = GetDisplay(); @@ -88,7 +88,7 @@ static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y XcursorImage *image; image = X11_XcursorImageCreate(surface->w, surface->h); - if (image == NULL) { + if (!image) { SDL_OutOfMemory(); return None; } @@ -121,13 +121,13 @@ static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) size_t width_bytes = ((surface->w + 7) & ~((size_t)7)) / 8; data_bits = SDL_calloc(1, surface->h * width_bytes); - if (data_bits == NULL) { + if (!data_bits) { SDL_OutOfMemory(); return None; } mask_bits = SDL_calloc(1, surface->h * width_bytes); - if (mask_bits == NULL) { + if (!mask_bits) { SDL_free(data_bits); SDL_OutOfMemory(); return None; @@ -204,7 +204,7 @@ static SDL_Cursor *X11_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) if (cursor) { Cursor x11_cursor = None; -#if SDL_VIDEO_DRIVER_X11_XCURSOR +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR if (SDL_X11_HAVE_XCURSOR) { x11_cursor = X11_CreateXCursorCursor(surface, hot_x, hot_y); } @@ -220,64 +220,53 @@ static SDL_Cursor *X11_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return cursor; } -static SDL_Cursor *X11_CreateSystemCursor(SDL_SystemCursor id) +static unsigned int GetLegacySystemCursorShape(SDL_SystemCursor id) { - SDL_Cursor *cursor; - unsigned int shape; - switch (id) { - default: - SDL_assert(0); - return NULL; - /* X Font Cursors reference: */ - /* http://tronche.com/gui/x/xlib/appendix/b/ */ - case SDL_SYSTEM_CURSOR_ARROW: - shape = XC_left_ptr; - break; - case SDL_SYSTEM_CURSOR_IBEAM: - shape = XC_xterm; - break; - case SDL_SYSTEM_CURSOR_WAIT: - shape = XC_watch; - break; - case SDL_SYSTEM_CURSOR_CROSSHAIR: - shape = XC_tcross; - break; - case SDL_SYSTEM_CURSOR_WAITARROW: - shape = XC_watch; - break; - case SDL_SYSTEM_CURSOR_SIZENWSE: - shape = XC_top_left_corner; - break; - case SDL_SYSTEM_CURSOR_SIZENESW: - shape = XC_top_right_corner; - break; - case SDL_SYSTEM_CURSOR_SIZEWE: - shape = XC_sb_h_double_arrow; - break; - case SDL_SYSTEM_CURSOR_SIZENS: - shape = XC_sb_v_double_arrow; - break; - case SDL_SYSTEM_CURSOR_SIZEALL: - shape = XC_fleur; - break; - case SDL_SYSTEM_CURSOR_NO: - shape = XC_pirate; - break; - case SDL_SYSTEM_CURSOR_HAND: - shape = XC_hand2; - break; + /* X Font Cursors reference: */ + /* http://tronche.com/gui/x/xlib/appendix/b/ */ + case SDL_SYSTEM_CURSOR_ARROW: return XC_left_ptr; + case SDL_SYSTEM_CURSOR_IBEAM: return XC_xterm; + case SDL_SYSTEM_CURSOR_WAIT: return XC_watch; + case SDL_SYSTEM_CURSOR_CROSSHAIR: return XC_tcross; + case SDL_SYSTEM_CURSOR_WAITARROW: return XC_watch; + case SDL_SYSTEM_CURSOR_SIZENWSE: return XC_top_left_corner; + case SDL_SYSTEM_CURSOR_SIZENESW: return XC_top_right_corner; + case SDL_SYSTEM_CURSOR_SIZEWE: return XC_sb_h_double_arrow; + case SDL_SYSTEM_CURSOR_SIZENS: return XC_sb_v_double_arrow; + case SDL_SYSTEM_CURSOR_SIZEALL: return XC_fleur; + case SDL_SYSTEM_CURSOR_NO: return XC_pirate; + case SDL_SYSTEM_CURSOR_HAND: return XC_hand2; + case SDL_NUM_SYSTEM_CURSORS: break; /* so the compiler might notice if an enum value is missing here. */ } - cursor = SDL_calloc(1, sizeof(*cursor)); - if (cursor) { - Cursor x11_cursor; + SDL_assert(0); + return 0; +} - x11_cursor = X11_XCreateFontCursor(GetDisplay(), shape); +static SDL_Cursor *X11_CreateSystemCursor(SDL_SystemCursor id) +{ + SDL_Cursor *cursor = NULL; + Display *dpy = GetDisplay(); + Cursor x11_cursor = None; - cursor->driverdata = (void *)(uintptr_t)x11_cursor; - } else { - SDL_OutOfMemory(); +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR + if (SDL_X11_HAVE_XCURSOR) { + x11_cursor = X11_XcursorLibraryLoadCursor(dpy, SDL_GetCSSCursorName(id, NULL)); + } +#endif + + if (x11_cursor == None) { + x11_cursor = X11_XCreateFontCursor(dpy, GetLegacySystemCursorShape(id)); + } + + if (x11_cursor != None) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + SDL_OutOfMemory(); + } else { + cursor->driverdata = (void *)(uintptr_t)x11_cursor; + } } return cursor; @@ -328,21 +317,39 @@ static void WarpMouseInternal(Window xwindow, const int x, const int y) { SDL_VideoData *videodata = (SDL_VideoData *)SDL_GetVideoDevice()->driverdata; Display *display = videodata->display; -#if SDL_VIDEO_DRIVER_X11_XINPUT2 + SDL_Mouse *mouse = SDL_GetMouse(); int deviceid = 0; - /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: - * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea - */ - if (ScreenCount(display) == 1) { - X11_XIGetClientPointer(display, None, &deviceid); + SDL_bool warp_hack = SDL_FALSE; + + /* XWayland will only warp the cursor if it is hidden, so this workaround is required. */ + if (videodata->is_xwayland && mouse && mouse->cursor_shown) { + warp_hack = SDL_TRUE; + } + + if (warp_hack) { + X11_ShowCursor(NULL); + } +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + if (X11_Xinput2IsInitialized()) { + /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: + * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea + */ + if (ScreenCount(display) == 1) { + X11_XIGetClientPointer(display, None, &deviceid); + } } if (deviceid != 0) { + SDL_assert(SDL_X11_HAVE_XINPUT2); X11_XIWarpPointer(display, deviceid, None, xwindow, 0.0, 0.0, 0, 0, (double)x, (double)y); } else #endif { X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, x, y); } + + if (warp_hack) { + X11_ShowCursor(SDL_GetCursor()); + } X11_XSync(display, False); videodata->global_mouse_changed = SDL_TRUE; } @@ -351,7 +358,7 @@ static void X11_WarpMouse(SDL_Window *window, int x, int y) { SDL_WindowData *data = (SDL_WindowData *)window->driverdata; -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES /* If we have no barrier, we need to warp */ if (data->pointer_barrier_active == SDL_FALSE) { WarpMouseInternal(data->xwindow, x, y); @@ -369,14 +376,7 @@ static int X11_WarpMouseGlobal(int x, int y) static int X11_SetRelativeMouseMode(SDL_bool enabled) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 - if (X11_Xinput2IsInitialized()) { - return 0; - } -#else - SDL_Unsupported(); -#endif - return -1; + return X11_Xinput2IsInitialized() ? 0 : SDL_Unsupported(); } static int X11_CaptureMouse(SDL_Window *window) @@ -414,19 +414,16 @@ static Uint32 X11_GetGlobalMouseState(int *x, int *y) /* !!! FIXME: should we XSync() here first? */ -#if !SDL_VIDEO_DRIVER_X11_XINPUT2 - videodata->global_mouse_changed = SDL_TRUE; -#else - if (!SDL_X11_HAVE_XINPUT2) + if (!X11_Xinput2IsInitialized()) { videodata->global_mouse_changed = SDL_TRUE; -#endif + } /* check if we have this cached since XInput last saw the mouse move. */ /* !!! FIXME: can we just calculate this from XInput's events? */ if (videodata->global_mouse_changed) { for (i = 0; i < num_screens; i++) { SDL_DisplayData *data = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); - if (data != NULL) { + if (data) { Window root, child; int rootx, rooty, winx, winy; unsigned int mask; @@ -483,7 +480,7 @@ void X11_QuitMouse(_THIS) SDL_XInput2DeviceInfo *i; SDL_XInput2DeviceInfo *next; - for (i = data->mouse_device_info; i != NULL; i = next) { + for (i = data->mouse_device_info; i; i = next) { next = i->next; SDL_free(i); } diff --git a/vs/sdl2/src/video/x11/SDL_x11mouse.h b/vs/sdl2/src/video/x11/SDL_x11mouse.h index 0a7f165b16..5cccd31d4f 100644 --- a/vs/sdl2/src/video/x11/SDL_x11mouse.h +++ b/vs/sdl2/src/video/x11/SDL_x11mouse.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11opengl.c b/vs/sdl2/src/video/x11/SDL_x11opengl.c index 3e95d8d858..30563fc6e9 100644 --- a/vs/sdl2/src/video/x11/SDL_x11opengl.c +++ b/vs/sdl2/src/video/x11/SDL_x11opengl.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2021 NVIDIA Corporation This software is provided 'as-is', without any express or implied @@ -21,14 +21,14 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_x11video.h" #include "SDL_hints.h" /* GLX implementation of SDL OpenGL support */ -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_GLX #include "SDL_loadso.h" #include "SDL_x11opengles.h" @@ -241,6 +241,8 @@ int X11_GL_LoadLibrary(_THIS, const char *path) return SDL_SetError("GLX is not supported"); } + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNTESTED; + /* Initialize extensions */ /* See lengthy comment about the inc/dec in ../windows/SDL_windowsopengl.c. */ @@ -254,7 +256,7 @@ int X11_GL_LoadLibrary(_THIS, const char *path) if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) && X11_GL_UseEGL(_this) ) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL X11_GL_UnloadLibrary(_this); _this->GL_LoadLibrary = X11_GLES_LoadLibrary; _this->GL_GetProcAddress = X11_GLES_GetProcAddress; @@ -889,7 +891,6 @@ int X11_GL_SetSwapInterval(_THIS, int interval) int currentInterval = X11_GL_GetSwapInterval(_this); _this->gl_data->glXSwapIntervalEXT(display, drawable, currentInterval); _this->gl_data->glXSwapIntervalEXT(display, drawable, interval); - status = 0; swapinterval = interval; } else if (_this->gl_data->glXSwapIntervalMESA) { @@ -912,6 +913,53 @@ int X11_GL_SetSwapInterval(_THIS, int interval) return status; } +static SDL_GLSwapIntervalTearBehavior CheckSwapIntervalTearBehavior(SDL_VideoDevice *_this, Window drawable, unsigned int current_val, unsigned int current_allow_late) +{ + /* Mesa and Nvidia interpret GLX_EXT_swap_control_tear differently, as of this writing, so + figure out which behavior we have. + Technical details: https://github.com/libsdl-org/SDL/issues/8004#issuecomment-1819603282 */ + if (_this->gl_data->swap_interval_tear_behavior == SDL_SWAPINTERVALTEAR_UNTESTED) { + if (!_this->gl_data->HAS_GLX_EXT_swap_control_tear) { + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNKNOWN; + } else { + Display *display = ((SDL_VideoData *)_this->driverdata)->display; + unsigned int allow_late_swap_tearing = 22; + int original_val = (int) current_val; + + /* + * This is a workaround for a bug in NVIDIA drivers. Bug has been reported + * and will be fixed in a future release (probably 319.xx). + * + * There's a bug where glXSetSwapIntervalEXT ignores updates because + * it has the wrong value cached. To work around it, we just run a no-op + * update to the current value. + */ + _this->gl_data->glXSwapIntervalEXT(display, drawable, current_val); + + /* set it to no swap interval and see how it affects GLX_LATE_SWAPS_TEAR_EXT... */ + _this->gl_data->glXSwapIntervalEXT(display, drawable, 0); + _this->gl_data->glXQueryDrawable(display, drawable, GLX_LATE_SWAPS_TEAR_EXT, &allow_late_swap_tearing); + + if (allow_late_swap_tearing == 0) { /* GLX_LATE_SWAPS_TEAR_EXT says whether late swapping is currently in use */ + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_NVIDIA; + if (current_allow_late) { + original_val = -original_val; + } + } else if (allow_late_swap_tearing == 1) { /* GLX_LATE_SWAPS_TEAR_EXT says whether the Drawable can use late swapping at all */ + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_MESA; + } else { /* unexpected outcome! */ + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNKNOWN; + } + + /* set us back to what it was originally... */ + _this->gl_data->glXSwapIntervalEXT(display, drawable, original_val); + } + } + + return _this->gl_data->swap_interval_tear_behavior; +} + + int X11_GL_GetSwapInterval(_THIS) { if (_this->gl_data->glXSwapIntervalEXT) { @@ -924,6 +972,7 @@ int X11_GL_GetSwapInterval(_THIS) unsigned int interval = 0; if (_this->gl_data->HAS_GLX_EXT_swap_control_tear) { + allow_late_swap_tearing = 22; /* set this to nonsense. */ _this->gl_data->glXQueryDrawable(display, drawable, GLX_LATE_SWAPS_TEAR_EXT, &allow_late_swap_tearing); @@ -932,11 +981,19 @@ int X11_GL_GetSwapInterval(_THIS) _this->gl_data->glXQueryDrawable(display, drawable, GLX_SWAP_INTERVAL_EXT, &interval); - if ((allow_late_swap_tearing) && (interval > 0)) { - return -((int)interval); + switch (CheckSwapIntervalTearBehavior(_this, drawable, interval, allow_late_swap_tearing)) { + case SDL_SWAPINTERVALTEAR_MESA: + return (int)interval; /* unsigned int cast to signed that generates negative value if necessary. */ + + case SDL_SWAPINTERVALTEAR_NVIDIA: + default: + if ((allow_late_swap_tearing) && (interval > 0)) { + return -((int)interval); + } + return (int)interval; } - return (int)interval; + return (int)interval; /* shouldn't hit this, but just in case. */ } else if (_this->gl_data->glXGetSwapIntervalMESA) { return _this->gl_data->glXGetSwapIntervalMESA(); } else { diff --git a/vs/sdl2/src/video/x11/SDL_x11opengl.h b/vs/sdl2/src/video/x11/SDL_x11opengl.h index a3413982d7..e0e8e195d9 100644 --- a/vs/sdl2/src/video/x11/SDL_x11opengl.h +++ b/vs/sdl2/src/video/x11/SDL_x11opengl.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,10 +23,18 @@ #ifndef SDL_x11opengl_h_ #define SDL_x11opengl_h_ -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_GLX #include "SDL_opengl.h" #include +typedef enum SDL_GLSwapIntervalTearBehavior +{ + SDL_SWAPINTERVALTEAR_UNTESTED, + SDL_SWAPINTERVALTEAR_UNKNOWN, + SDL_SWAPINTERVALTEAR_MESA, + SDL_SWAPINTERVALTEAR_NVIDIA +} SDL_GLSwapIntervalTearBehavior; + struct SDL_GLDriverData { int errorBase, eventBase; @@ -48,6 +56,8 @@ struct SDL_GLDriverData int minor; } es_profile_max_supported_version; + SDL_GLSwapIntervalTearBehavior swap_interval_tear_behavior; + Bool (*glXQueryExtension)(Display *, int *, int *); void *(*glXGetProcAddress)(const GLubyte *); XVisualInfo *(*glXChooseVisual)(Display *, int, int *); diff --git a/vs/sdl2/src/video/x11/SDL_x11opengles.c b/vs/sdl2/src/video/x11/SDL_x11opengles.c index 4d38a71e87..ad1e26b1f6 100644 --- a/vs/sdl2/src/video/x11/SDL_x11opengles.c +++ b/vs/sdl2/src/video/x11/SDL_x11opengles.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDL_VIDEO_OPENGL_EGL) #include "SDL_hints.h" #include "SDL_x11video.h" @@ -36,7 +36,7 @@ int X11_GLES_LoadLibrary(_THIS, const char *path) /* If the profile requested is not GL ES, switch over to X11_GL functions */ if ((_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) && !SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) { - #if SDL_VIDEO_OPENGL_GLX + #ifdef SDL_VIDEO_OPENGL_GLX X11_GLES_UnloadLibrary(_this); _this->GL_LoadLibrary = X11_GL_LoadLibrary; _this->GL_GetProcAddress = X11_GL_GetProcAddress; diff --git a/vs/sdl2/src/video/x11/SDL_x11opengles.h b/vs/sdl2/src/video/x11/SDL_x11opengles.h index cd5bfba0ad..23530d8546 100644 --- a/vs/sdl2/src/video/x11/SDL_x11opengles.h +++ b/vs/sdl2/src/video/x11/SDL_x11opengles.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +23,7 @@ #ifndef SDL_x11opengles_h_ #define SDL_x11opengles_h_ -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "../SDL_sysvideo.h" #include "../SDL_egl_c.h" diff --git a/vs/sdl2/src/video/x11/SDL_x11shape.c b/vs/sdl2/src/video/x11/SDL_x11shape.c index 4a8d9462f8..fee1c7aa8a 100644 --- a/vs/sdl2/src/video/x11/SDL_x11shape.c +++ b/vs/sdl2/src/video/x11/SDL_x11shape.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_x11video.h" #include "SDL_x11shape.h" @@ -30,12 +30,12 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) { SDL_WindowShaper *result = NULL; - SDL_ShapeData *data = NULL; -#if SDL_VIDEO_DRIVER_X11_XSHAPE +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE + SDL_ShapeData *data = NULL; if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ result = SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -44,7 +44,7 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) result->mode.parameters.binarizationCutoff = 1; result->userx = result->usery = 0; data = SDL_malloc(sizeof(SDL_ShapeData)); - if (data == NULL) { + if (!data) { SDL_free(result); SDL_OutOfMemory(); return NULL; @@ -75,11 +75,11 @@ int X11_ResizeWindowShape(SDL_Window *window) bitmapsize += 1; } bitmapsize *= window->h; - if (data->bitmapsize != bitmapsize || data->bitmap == NULL) { + if (data->bitmapsize != bitmapsize || !data->bitmap) { data->bitmapsize = bitmapsize; SDL_free(data->bitmap); data->bitmap = SDL_malloc(data->bitmapsize); - if (data->bitmap == NULL) { + if (!data->bitmap) { return SDL_OutOfMemory(); } } @@ -94,15 +94,17 @@ int X11_ResizeWindowShape(SDL_Window *window) int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowShapeMode *shape_mode) { +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE SDL_ShapeData *data = NULL; SDL_WindowData *windowdata = NULL; Pixmap shapemask; +#endif - if (shaper == NULL || shape == NULL || shaper->driverdata == NULL) { + if (!shaper || !shape || !shaper->driverdata) { return -1; } -#if SDL_VIDEO_DRIVER_X11_XSHAPE +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE if (shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) { return -2; } diff --git a/vs/sdl2/src/video/x11/SDL_x11shape.h b/vs/sdl2/src/video/x11/SDL_x11shape.h index b1741d1e1a..7cd168c8f9 100644 --- a/vs/sdl2/src/video/x11/SDL_x11shape.h +++ b/vs/sdl2/src/video/x11/SDL_x11shape.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11sym.h b/vs/sdl2/src/video/x11/SDL_x11sym.h index beb0d38115..450c07ebf2 100644 --- a/vs/sdl2/src/video/x11/SDL_x11sym.h +++ b/vs/sdl2/src/video/x11/SDL_x11sym.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -156,20 +156,21 @@ SDL_X11_SYM(int,XQueryTree,(Display* a,Window b,Window* c,Window* d,Window** e,u SDL_X11_SYM(Bool,XSupportsLocale,(void),(),return) SDL_X11_SYM(Status,XmbTextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES SDL_X11_MODULE(XFIXES) SDL_X11_SYM(PointerBarrier, XFixesCreatePointerBarrier, (Display* a, Window b, int c, int d, int e, int f, int g, int h, int *i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(void, XFixesDestroyPointerBarrier, (Display* a, PointerBarrier b), (a,b),) SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return) /* this is actually Xinput2 */ SDL_X11_SYM(Status, XFixesQueryVersion,(Display* a, int* b, int* c), (a,b,c), return) +SDL_X11_SYM(Status, XFixesSelectSelectionInput, (Display* a, Window b, Atom c, unsigned long d), (a,b,c,d), return) #endif -#if SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS SDL_X11_SYM(Bool,XGetEventData,(Display* a,XGenericEventCookie* b),(a,b),return) SDL_X11_SYM(void,XFreeEventData,(Display* a,XGenericEventCookie* b),(a,b),) #endif -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM SDL_X11_SYM(Bool,XkbQueryExtension,(Display* a,int * b,int * c,int * d,int * e, int *f),(a,b,c,d,e,f),return) #if NeedWidePrototypes SDL_X11_SYM(KeySym,XkbKeycodeToKeysym,(Display* a,unsigned int b,int c,int d),(a,b,c,d),return) @@ -184,11 +185,19 @@ 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) #endif +/* XKeycodeToKeysym is a deprecated function */ +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) || defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif #if NeedWidePrototypes SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return) #else SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) #endif +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))) || defined(__clang__) +#pragma GCC diagnostic pop +#endif #ifdef X_HAVE_UTF8_STRING SDL_X11_MODULE(UTF8) @@ -239,15 +248,16 @@ SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return) #endif /* XCursor support */ -#if SDL_VIDEO_DRIVER_X11_XCURSOR +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR SDL_X11_MODULE(XCURSOR) SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return) SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),) SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return) +SDL_X11_SYM(Cursor,XcursorLibraryLoadCursor,(Display *a, const char *b),(a,b),return) #endif /* Xdbe support */ -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE SDL_X11_MODULE(XDBE) SDL_X11_SYM(Status,XdbeQueryExtension,(Display *dpy,int *major_version_return,int *minor_version_return),(dpy,major_version_return,minor_version_return),return) SDL_X11_SYM(XdbeBackBuffer,XdbeAllocateBackBufferName,(Display *dpy,Window window,XdbeSwapAction swap_action),(dpy,window,swap_action),return) @@ -261,7 +271,7 @@ SDL_X11_SYM(XdbeBackBufferAttributes*,XdbeGetBackBufferAttributes,(Display *dpy, #endif /* XInput2 support for multiple mice, tablets, etc. */ -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_X11_MODULE(XINPUT2) SDL_X11_SYM(XIDeviceInfo*,XIQueryDevice,(Display *a,int b,int *c),(a,b,c),return) SDL_X11_SYM(void,XIFreeDeviceInfo,(XIDeviceInfo *a),(a),) @@ -275,7 +285,7 @@ SDL_X11_SYM(Bool,XIWarpPointer,(Display *a,int b,Window c,Window d,double e,doub #endif /* XRandR support */ -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR SDL_X11_MODULE(XRANDR) SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) SDL_X11_SYM(Bool,XRRQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return); @@ -304,14 +314,14 @@ SDL_X11_SYM(void,XRRSelectInput,(Display *dpy, Window window, int mask),(dpy,win #endif /* MIT-SCREEN-SAVER support */ -#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER SDL_X11_MODULE(XSS) SDL_X11_SYM(Bool,XScreenSaverQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return) #endif -#if SDL_VIDEO_DRIVER_X11_XSHAPE +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE SDL_X11_MODULE(XSHAPE) SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),) #endif diff --git a/vs/sdl2/src/video/x11/SDL_x11touch.c b/vs/sdl2/src/video/x11/SDL_x11touch.c index 90a41353e9..338001fd61 100644 --- a/vs/sdl2/src/video/x11/SDL_x11touch.c +++ b/vs/sdl2/src/video/x11/SDL_x11touch.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_x11video.h" #include "SDL_x11touch.h" diff --git a/vs/sdl2/src/video/x11/SDL_x11touch.h b/vs/sdl2/src/video/x11/SDL_x11touch.h index 246e0bdeb8..ca6edac544 100644 --- a/vs/sdl2/src/video/x11/SDL_x11touch.h +++ b/vs/sdl2/src/video/x11/SDL_x11touch.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/x11/SDL_x11video.c b/vs/sdl2/src/video/x11/SDL_x11video.c index e2b36a8496..6a543c186c 100644 --- a/vs/sdl2/src/video/x11/SDL_x11video.c +++ b/vs/sdl2/src/video/x11/SDL_x11video.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include /* For getpid() and readlink() */ @@ -37,8 +37,9 @@ #include "SDL_x11touch.h" #include "SDL_x11xinput2.h" #include "SDL_x11xfixes.h" +#include "SDL_x11messagebox.h" -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -125,7 +126,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; device = SDL_GetVideoDevice(); - if (device != NULL) { + if (device) { int i; for (i = 0; i < device->num_displays; i++) { SDL_VideoDisplay *display = &device->displays[i]; @@ -137,13 +138,19 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) } } - if (orig_x11_errhandler != NULL) { + if (orig_x11_errhandler) { return orig_x11_errhandler(d, e); /* probably terminate. */ } return 0; } +static SDL_bool X11_IsXWayland(Display *d) +{ + int opcode, event, error; + return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True; +} + static SDL_VideoDevice *X11_CreateDevice(void) { SDL_VideoDevice *device; @@ -162,19 +169,19 @@ static SDL_VideoDevice *X11_CreateDevice(void) /* Open the display first to be sure that X11 is available */ x11_display = X11_XOpenDisplay(display); - if (x11_display == NULL) { + if (!x11_display) { SDL_X11_UnloadSymbols(); return NULL; } /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_free(device); SDL_OutOfMemory(); return NULL; @@ -183,13 +190,13 @@ static SDL_VideoDevice *X11_CreateDevice(void) data->global_mouse_changed = SDL_TRUE; -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES data->active_cursor_confined_window = NULL; #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ data->display = x11_display; data->request_display = X11_XOpenDisplay(display); - if (data->request_display == NULL) { + if (!data->request_display) { X11_XCloseDisplay(data->display); SDL_free(device->driverdata); SDL_free(device); @@ -261,7 +268,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->AcceptDragAndDrop = X11_AcceptDragAndDrop; device->FlashWindow = X11_FlashWindow; -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES device->SetWindowMouseRect = X11_SetWindowMouseRect; #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ @@ -269,7 +276,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->shape_driver.SetWindowShape = X11_SetWindowShape; device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_UnloadLibrary = X11_GL_UnloadLibrary; @@ -280,8 +287,8 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_DeleteContext = X11_GL_DeleteContext; #endif -#if SDL_VIDEO_OPENGL_EGL -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_GLX if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) { #endif device->GL_LoadLibrary = X11_GLES_LoadLibrary; @@ -293,7 +300,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->GL_GetSwapInterval = X11_GLES_GetSwapInterval; device->GL_SwapWindow = X11_GLES_SwapWindow; device->GL_DeleteContext = X11_GLES_DeleteContext; -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_GLX } #endif #endif @@ -314,19 +321,22 @@ static SDL_VideoDevice *X11_CreateDevice(void) device->free = X11_DeleteDevice; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary; device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary; device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions; device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface; #endif + data->is_xwayland = X11_IsXWayland(x11_display); + return device; } VideoBootStrap X11_bootstrap = { "x11", "SDL X11 video driver", - X11_CreateDevice + X11_CreateDevice, + X11_ShowMessageBox }; static int (*handler)(Display *, XErrorEvent *) = NULL; diff --git a/vs/sdl2/src/video/x11/SDL_x11video.h b/vs/sdl2/src/video/x11/SDL_x11video.h index 65876c2206..a12a34b968 100644 --- a/vs/sdl2/src/video/x11/SDL_x11video.h +++ b/vs/sdl2/src/video/x11/SDL_x11video.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,22 +31,22 @@ #include #include -#if SDL_VIDEO_DRIVER_X11_XCURSOR +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR #include #endif -#if SDL_VIDEO_DRIVER_X11_XDBE +#ifdef SDL_VIDEO_DRIVER_X11_XDBE #include #endif -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 #include #endif -#if SDL_VIDEO_DRIVER_X11_XRANDR +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR #include #endif -#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER #include #endif -#if SDL_VIDEO_DRIVER_X11_XSHAPE +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE #include #endif @@ -79,7 +79,7 @@ typedef struct SDL_VideoData int windowlistlength; XID window_group; Window clipboard_window; -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES SDL_Window *active_cursor_confined_window; #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ @@ -138,7 +138,7 @@ typedef struct SDL_VideoData int xrandr_event_base; -#if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM XkbDescPtr xkb; #endif int xkb_event; @@ -146,7 +146,7 @@ typedef struct SDL_VideoData KeyCode filter_code; Time filter_time; -#if SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_VULKAN /* Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL */ void *vulkan_xlib_xcb_library; PFN_XGetXCBConnection vulkan_XGetXCBConnection; @@ -156,6 +156,8 @@ typedef struct SDL_VideoData SDL_bool is_steam_deck; SDL_bool steam_keyboard_open; + SDL_bool is_xwayland; + } SDL_VideoData; extern SDL_bool X11_UseDirectColorVisuals(void); diff --git a/vs/sdl2/src/video/x11/SDL_x11vulkan.c b/vs/sdl2/src/video/x11/SDL_x11vulkan.c index 07b4a80280..d9a0d2f35b 100644 --- a/vs/sdl2/src/video/x11/SDL_x11vulkan.c +++ b/vs/sdl2/src/video/x11/SDL_x11vulkan.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_X11 +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_X11) #include "SDL_x11video.h" @@ -56,10 +56,10 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -83,7 +83,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { @@ -107,7 +107,7 @@ int X11_Vulkan_LoadLibrary(_THIS, const char *path) goto fail; } else { const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY"); - if (libX11XCBLibraryName == NULL) { + if (!libX11XCBLibraryName) { libX11XCBLibraryName = "libX11-xcb.so"; } videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName); diff --git a/vs/sdl2/src/video/x11/SDL_x11vulkan.h b/vs/sdl2/src/video/x11/SDL_x11vulkan.h index 775e07de9c..438b16d07d 100644 --- a/vs/sdl2/src/video/x11/SDL_x11vulkan.h +++ b/vs/sdl2/src/video/x11/SDL_x11vulkan.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +25,7 @@ #include "../SDL_vulkan_internal.h" -#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_X11 +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_X11) /*typedef struct xcb_connection_t xcb_connection_t;*/ typedef xcb_connection_t *(*PFN_XGetXCBConnection)(Display *dpy); diff --git a/vs/sdl2/src/video/x11/SDL_x11window.c b/vs/sdl2/src/video/x11/SDL_x11window.c index 2a2a160f81..07ec43156a 100644 --- a/vs/sdl2/src/video/x11/SDL_x11window.c +++ b/vs/sdl2/src/video/x11/SDL_x11window.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_hints.h" #include "../SDL_sysvideo.h" @@ -35,7 +35,7 @@ #include "SDL_x11xinput2.h" #include "SDL_x11xfixes.h" -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include "SDL_x11opengles.h" #endif @@ -256,7 +256,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -284,7 +284,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) (numwindows + 1) * sizeof(*windowlist)); - if (windowlist == NULL) { + if (!windowlist) { SDL_free(data); return SDL_OutOfMemory(); } @@ -391,10 +391,10 @@ int X11_CreateWindow(_THIS, SDL_Window *window) long fevent = 0; const char *hint = NULL; -#if SDL_VIDEO_OPENGL_GLX || SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_OPENGL_GLX) || defined(SDL_VIDEO_OPENGL_EGL) const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); - if (forced_visual_id != NULL && forced_visual_id[0] != '\0') { + if (forced_visual_id && forced_visual_id[0] != '\0') { XVisualInfo *vi, template; int nvis; @@ -412,23 +412,23 @@ int X11_CreateWindow(_THIS, SDL_Window *window) !SDL_getenv("SDL_VIDEO_X11_VISUALID")) { XVisualInfo *vinfo = NULL; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) -#if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) +#ifdef SDL_VIDEO_OPENGL_GLX + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { vinfo = X11_GLES_GetVisual(_this, display, screen); } else #endif { -#if SDL_VIDEO_OPENGL_GLX +#ifdef SDL_VIDEO_OPENGL_GLX vinfo = X11_GL_GetVisual(_this, display, screen); #endif } - if (vinfo == NULL) { + if (!vinfo) { return -1; } visual = vinfo->visual; @@ -465,7 +465,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) /* OK, we got a colormap, now fill it in as best as we can */ colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); - if (colorcells == NULL) { + if (!colorcells) { return SDL_OutOfMemory(); } ncolors = visual->map_entries; @@ -592,7 +592,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) wintype_name = "_NET_WM_WINDOW_TYPE_TOOLTIP"; } else if (window->flags & SDL_WINDOW_POPUP_MENU) { wintype_name = "_NET_WM_WINDOW_TYPE_POPUP_MENU"; - } else if (hint != NULL && *hint) { + } else if (hint && *hint) { wintype_name = hint; } else { wintype_name = "_NET_WM_WINDOW_TYPE_NORMAL"; @@ -634,15 +634,15 @@ int X11_CreateWindow(_THIS, SDL_Window *window) } windowdata = (SDL_WindowData *)window->driverdata; -#if SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 || SDL_VIDEO_OPENGL_EGL +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL) if ((window->flags & SDL_WINDOW_OPENGL) && ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) -#if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) +#ifdef SDL_VIDEO_OPENGL_GLX + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL if (!_this->egl_data) { return -1; } @@ -1612,7 +1612,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -1662,7 +1662,7 @@ void *X11_GetWindowICCProfile(_THIS, SDL_Window *window, size_t *size) } ret_icc_profile_data = SDL_malloc(real_nitems); - if (ret_icc_profile_data == NULL) { + if (!ret_icc_profile_data) { SDL_OutOfMemory(); return NULL; } @@ -1679,7 +1679,7 @@ void X11_SetWindowMouseGrab(_THIS, SDL_Window *window, SDL_bool grabbed) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } data->mouse_grabbed = SDL_FALSE; @@ -1734,7 +1734,7 @@ void X11_SetWindowKeyboardGrab(_THIS, SDL_Window *window, SDL_bool grabbed) SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } @@ -1798,7 +1798,7 @@ void X11_DestroyWindow(_THIS, SDL_Window *window) } SDL_free(data); -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES /* If the pointer barriers are active for this, deactivate it.*/ if (videodata->active_cursor_confined_window == window) { X11_DestroyPointerBarrier(_this, window); @@ -1813,7 +1813,7 @@ SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* This sometimes happens in SDL_IBus_UpdateTextRect() while creating the window */ SDL_SetError("Window not initialized"); return SDL_FALSE; @@ -1860,7 +1860,7 @@ int X11_FlashWindow(_THIS, SDL_Window *window, SDL_FlashOperation operation) XWMHints *wmhints; wmhints = X11_XGetWMHints(display, data->xwindow); - if (wmhints == NULL) { + if (!wmhints) { return SDL_SetError("Couldn't get WM hints"); } diff --git a/vs/sdl2/src/video/x11/SDL_x11window.h b/vs/sdl2/src/video/x11/SDL_x11window.h index f31eb403e9..12a89b03b2 100644 --- a/vs/sdl2/src/video/x11/SDL_x11window.h +++ b/vs/sdl2/src/video/x11/SDL_x11window.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ */ #define PENDING_FOCUS_TIME 200 -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL #include #endif @@ -70,10 +70,10 @@ typedef struct Window xdnd_source; SDL_bool flashing_window; Uint32 flash_cancel_time; -#if SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_EGL EGLSurface egl_surface; #endif -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES SDL_bool pointer_barrier_active; PointerBarrier barrier[4]; SDL_Rect barrier_rect; diff --git a/vs/sdl2/src/video/x11/SDL_x11xfixes.c b/vs/sdl2/src/video/x11/SDL_x11xfixes.c index 662759f67d..6ae7e053ff 100644 --- a/vs/sdl2/src/video/x11/SDL_x11xfixes.c +++ b/vs/sdl2/src/video/x11/SDL_x11xfixes.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_DRIVER_X11_XFIXES +#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDL_VIDEO_DRIVER_X11_XFIXES) #include "SDL_x11video.h" #include "SDL_x11xfixes.h" @@ -29,6 +29,7 @@ #include "../../events/SDL_touch_c.h" static int xfixes_initialized = 0; +static int xfixes_selection_notify_event = 0; static int query_xfixes_version(Display *display, int major, int minor) { @@ -50,11 +51,20 @@ void X11_InitXfixes(_THIS) int event, error; int fixes_opcode; + Atom XA_CLIPBOARD = X11_XInternAtom(data->display, "CLIPBOARD", 0); + if (!SDL_X11_HAVE_XFIXES || !X11_XQueryExtension(data->display, "XFIXES", &fixes_opcode, &event, &error)) { return; } + /* Selection tracking is available in all versions of XFixes */ + xfixes_selection_notify_event = event + XFixesSelectionNotify; + X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), + XA_CLIPBOARD, XFixesSetSelectionOwnerNotifyMask); + X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), + XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask); + /* We need at least 5.0 for barriers. */ version = query_xfixes_version(data->display, 5, 0); if (!xfixes_version_atleast(version, 5, 0)) { @@ -69,6 +79,11 @@ int X11_XfixesIsInitialized() return xfixes_initialized; } +int X11_GetXFixesSelectionNotifyEvent() +{ + return xfixes_selection_notify_event; +} + void X11_SetWindowMouseRect(_THIS, SDL_Window *window) { if (SDL_RectEmpty(&window->mouse_rect)) { diff --git a/vs/sdl2/src/video/x11/SDL_x11xfixes.h b/vs/sdl2/src/video/x11/SDL_x11xfixes.h index 92c659406e..3464867374 100644 --- a/vs/sdl2/src/video/x11/SDL_x11xfixes.h +++ b/vs/sdl2/src/video/x11/SDL_x11xfixes.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ #ifndef SDL_x11xfixes_h_ #define SDL_x11xfixes_h_ -#if SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES #define X11_BARRIER_HANDLED_BY_EVENT 1 @@ -33,7 +33,7 @@ extern int X11_XfixesIsInitialized(void); extern void X11_SetWindowMouseRect(_THIS, SDL_Window *window); extern int X11_ConfineCursorWithFlags(_THIS, SDL_Window *window, const SDL_Rect *rect, int flags); extern void X11_DestroyPointerBarrier(_THIS, SDL_Window *window); - +extern int X11_GetXFixesSelectionNotifyEvent(void); #endif /* SDL_VIDEO_DRIVER_X11_XFIXES */ #endif /* SDL_x11xfixes_h_ */ diff --git a/vs/sdl2/src/video/x11/SDL_x11xinput2.c b/vs/sdl2/src/video/x11/SDL_x11xinput2.c index 4fe205b7e7..afed858174 100644 --- a/vs/sdl2/src/video/x11/SDL_x11xinput2.c +++ b/vs/sdl2/src/video/x11/SDL_x11xinput2.c @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ */ #include "../../SDL_internal.h" -#if SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_X11 #include "SDL_x11video.h" #include "SDL_x11xinput2.h" @@ -29,10 +29,10 @@ #define MAX_AXIS 16 -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 static int xinput2_initialized = 0; -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH static int xinput2_multitouch_supported = 0; #endif @@ -74,7 +74,7 @@ static SDL_bool xinput2_version_atleast(const int version, const int wantmajor, return version >= ((wantmajor * 1000) + wantminor); } -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH static SDL_Window *xinput2_get_sdlwindow(SDL_VideoData *videodata, Window window) { int i; @@ -112,7 +112,7 @@ static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, void X11_InitXinput2(_THIS) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; int version = 0; @@ -142,7 +142,7 @@ void X11_InitXinput2(_THIS) xinput2_initialized = 1; -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Multitouch needs XInput 2.2 */ xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2); #endif @@ -155,7 +155,7 @@ void X11_InitXinput2(_THIS) XISetMask(mask, XI_RawButtonPress); XISetMask(mask, XI_RawButtonRelease); -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* Enable raw touch events if supported */ if (X11_Xinput2IsMultitouchSupported()) { XISetMask(mask, XI_RawTouchBegin); @@ -181,17 +181,17 @@ void X11_InitXinput2(_THIS) #endif } -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 /* xi2 device went away? take it out of the list. */ static void xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) { SDL_XInput2DeviceInfo *prev = NULL; SDL_XInput2DeviceInfo *devinfo; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev == NULL) { + if (!prev) { videodata->mouse_device_info = devinfo->next; } else { prev->next = devinfo->next; @@ -212,10 +212,10 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, int axis = 0; int i; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev != NULL) { /* move this to the front of the list, assuming we'll get more from this one. */ + if (prev) { /* move this to the front of the list, assuming we'll get more from this one. */ prev->next = devinfo->next; devinfo->next = videodata->mouse_device_info; videodata->mouse_device_info = devinfo; @@ -227,13 +227,13 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, /* don't know about this device yet, query and cache it. */ devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); - if (devinfo == NULL) { + if (!devinfo) { SDL_OutOfMemory(); return NULL; } xidevinfo = X11_XIQueryDevice(videodata->display, device_id, &i); - if (xidevinfo == NULL) { + if (!xidevinfo) { SDL_free(devinfo); return NULL; } @@ -266,7 +266,7 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 if (cookie->extension != xinput2_opcode) { return 0; } @@ -287,7 +287,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie } devinfo = xinput2_get_device_info(videodata, rawev->deviceid); - if (devinfo == NULL) { + if (!devinfo) { return 0; /* oh well. */ } @@ -321,7 +321,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie case XI_RawButtonPress: case XI_RawButtonRelease: -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH case XI_RawTouchBegin: case XI_RawTouchUpdate: case XI_RawTouchEnd: @@ -329,7 +329,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie videodata->global_mouse_changed = SDL_TRUE; break; -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH /* With multitouch, register to receive XI_Motion (which desctivates MotionNotify), * so that we can distinguish real mouse motions from synthetic one. */ case XI_Motion: @@ -337,6 +337,8 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; int pointer_emulated = (xev->flags & XIPointerEmulated); + videodata->global_mouse_changed = SDL_TRUE; + if (!pointer_emulated) { SDL_Mouse *mouse = SDL_GetMouse(); if (!mouse->relative_mode || mouse->relative_mode_warp) { @@ -385,7 +387,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie void X11_InitXinput2Multitouch(_THIS) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH SDL_VideoData *data = (SDL_VideoData *)_this->driverdata; XIDeviceInfo *info; int ndevices, i, j; @@ -425,7 +427,7 @@ void X11_InitXinput2Multitouch(_THIS) void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH SDL_VideoData *data = NULL; XIEventMask eventmask; unsigned char mask[4] = { 0, 0, 0, 0 }; @@ -453,7 +455,7 @@ void X11_Xinput2SelectTouch(_THIS, SDL_Window *window) int X11_Xinput2IsInitialized() { -#if SDL_VIDEO_DRIVER_X11_XINPUT2 +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 return xinput2_initialized; #else return 0; @@ -462,7 +464,7 @@ int X11_Xinput2IsInitialized() int X11_Xinput2IsMultitouchSupported() { -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH return xinput2_initialized && xinput2_multitouch_supported; #else return 0; @@ -471,7 +473,7 @@ int X11_Xinput2IsMultitouchSupported() void X11_Xinput2GrabTouch(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; @@ -501,7 +503,7 @@ void X11_Xinput2GrabTouch(_THIS, SDL_Window *window) void X11_Xinput2UngrabTouch(_THIS, SDL_Window *window) { -#if SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH SDL_WindowData *data = (SDL_WindowData *)window->driverdata; Display *display = data->videodata->display; diff --git a/vs/sdl2/src/video/x11/SDL_x11xinput2.h b/vs/sdl2/src/video/x11/SDL_x11xinput2.h index 4d7890b139..3a8e3c0f44 100644 --- a/vs/sdl2/src/video/x11/SDL_x11xinput2.h +++ b/vs/sdl2/src/video/x11/SDL_x11xinput2.h @@ -1,6 +1,6 @@ /* Simple DirectMedia Layer - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb.h index 5668c0fc41..c3593168f8 100644 --- a/vs/sdl2/src/video/yuv2rgb/yuv_rgb.h +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb.h @@ -1,412 +1,33 @@ +#ifndef YUV_RGB_H_ +#define YUV_RGB_H_ + // Copyright 2016 Adrien Descamps // Distributed under BSD 3-Clause License // Provide optimized functions to convert images from 8bits yuv420 to rgb24 format -// There are a few slightly different variations of the YCbCr color space with different parameters that +// There are a few slightly different variations of the YCbCr color space with different parameters that // change the conversion matrix. // The three most common YCbCr color space, defined by BT.601, BT.709 and JPEG standard are implemented here. // See the respective standards for details // The matrix values used are derived from http://www.equasys.de/colorconversion.html // YUV420 is stored as three separate channels, with U and V (Cb and Cr) subsampled by a 2 factor -// For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This +// For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This // is suboptimal for image quality, but by far the fastest method. // For all methods, width and height should be even, if not, the last row/column of the result image won't be affected. // For sse methods, if the width if not divisable by 32, the last (width%32) pixels of each line won't be affected. -#include "SDL_stdinc.h" /*#include */ -typedef enum -{ - YCBCR_JPEG, - YCBCR_601, - YCBCR_709 -} YCbCrType; - // yuv to rgb, standard c implementation -void yuv420_rgb565_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgb24_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgba_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_bgra_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_argb_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_abgr_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb565_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb24_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgba_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_bgra_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_argb_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_abgr_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb565_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb24_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgba_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_bgra_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_argb_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_abgr_std( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -// yuv to rgb, sse implementation -// pointers must be 16 byte aligned, and strides must be divisable by 16 -void yuv420_rgb565_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgb24_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgba_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_bgra_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_argb_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_abgr_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb565_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb24_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgba_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_bgra_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_argb_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_abgr_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb565_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb24_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgba_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_bgra_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_argb_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_abgr_sse( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -// yuv to rgb, sse implementation -// pointers do not need to be 16 byte aligned -void yuv420_rgb565_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgb24_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgba_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_bgra_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_argb_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_abgr_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb565_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgb24_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_rgba_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_bgra_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_argb_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv422_abgr_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb565_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgb24_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_rgba_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_bgra_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_argb_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuvnv12_abgr_sseu( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - - -// rgb to yuv, standard c implementation -void rgb24_yuv420_std( - uint32_t width, uint32_t height, - const uint8_t *rgb, uint32_t rgb_stride, - uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - YCbCrType yuv_type); - -// rgb to yuv, sse implementation -// pointers must be 16 byte aligned, and strides must be divisible by 16 -void rgb24_yuv420_sse( - uint32_t width, uint32_t height, - const uint8_t *rgb, uint32_t rgb_stride, - uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - YCbCrType yuv_type); - -// rgb to yuv, sse implementation -// pointers do not need to be 16 byte aligned -void rgb24_yuv420_sseu( - uint32_t width, uint32_t height, - const uint8_t *rgb, uint32_t rgb_stride, - uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - YCbCrType yuv_type); - - -//yuv420 to bgra, lsx implementation -void yuv420_rgb24_lsx( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); - -void yuv420_rgba_lsx( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); +#include "yuv_rgb_std.h" -void yuv420_bgra_lsx( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); +// yuv to rgb, sse2 implementation +#include "yuv_rgb_sse.h" -void yuv420_argb_lsx( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); +// yuv to rgb, lsx implementation +#include "yuv_rgb_lsx.h" -void yuv420_abgr_lsx( - uint32_t width, uint32_t height, - const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, - uint8_t *rgb, uint32_t rgb_stride, - YCbCrType yuv_type); +#endif /* YUV_RGB_H_ */ diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_common.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_common.h new file mode 100644 index 0000000000..ae787ed5f2 --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_common.h @@ -0,0 +1,13 @@ +#ifndef YUV_RGB_COMMON_H_ +#define YUV_RGB_COMMON_H_ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +typedef enum +{ + YCBCR_JPEG, + YCBCR_601, + YCBCR_709 +} YCbCrType; + +#endif /* YUV_RGB_COMMON_H_ */ diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_internal.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_internal.h new file mode 100644 index 0000000000..cad978b5fa --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_internal.h @@ -0,0 +1,74 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +#define PRECISION 6 +#define PRECISION_FACTOR (1<[0-255]) +// for ITU-R BT.709-6 values are derived from equations in sections 3.2-3.4, assuming RGB is encoded using full range ([0-1]<->[0-255]) +// all values are rounded to the fourth decimal + +static const YUV2RGBParam YUV2RGB[3] = { + // ITU-T T.871 (JPEG) + {/*.y_shift=*/ 0, /*.y_factor=*/ V(1.0), /*.v_r_factor=*/ V(1.402), /*.u_g_factor=*/ -V(0.3441), /*.v_g_factor=*/ -V(0.7141), /*.u_b_factor=*/ V(1.772)}, + // ITU-R BT.601-7 + {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.596), /*.u_g_factor=*/ -V(0.3918), /*.v_g_factor=*/ -V(0.813), /*.u_b_factor=*/ V(2.0172)}, + // ITU-R BT.709-6 + {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.7927), /*.u_g_factor=*/ -V(0.2132), /*.v_g_factor=*/ -V(0.5329), /*.u_b_factor=*/ V(2.1124)} +}; + +static const RGB2YUVParam RGB2YUV[3] = { + // ITU-T T.871 (JPEG) + {/*.y_shift=*/ 0, /*.matrix=*/ {{V(0.299), V(0.587), V(0.114)}, {-V(0.1687), -V(0.3313), V(0.5)}, {V(0.5), -V(0.4187), -V(0.0813)}}}, + // ITU-R BT.601-7 + {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.2568), V(0.5041), V(0.0979)}, {-V(0.1482), -V(0.291), V(0.4392)}, {V(0.4392), -V(0.3678), -V(0.0714)}}}, + // ITU-R BT.709-6 + {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.1826), V(0.6142), V(0.062)}, {-V(0.1006), -V(0.3386), V(0.4392)}, {V(0.4392), -V(0.3989), -V(0.0403)}}} +}; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +/* The various layouts of YUV data we support */ +#define YUV_FORMAT_420 1 +#define YUV_FORMAT_422 2 +#define YUV_FORMAT_NV12 3 + +/* The various formats of RGB pixel that we support */ +#define RGB_FORMAT_RGB565 1 +#define RGB_FORMAT_RGB24 2 +#define RGB_FORMAT_RGBA 3 +#define RGB_FORMAT_BGRA 4 +#define RGB_FORMAT_ARGB 5 +#define RGB_FORMAT_ABGR 6 diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.c b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.c new file mode 100644 index 0000000000..f24a05276d --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.c @@ -0,0 +1,44 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "../../SDL_internal.h" + +#if SDL_HAVE_YUV +#include "yuv_rgb.h" +#include "yuv_rgb_internal.h" +#include "SDL_cpuinfo.h" + +#ifdef __loongarch_sx + +#define LSX_FUNCTION_NAME yuv420_rgb24_lsx +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_rgba_lsx +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_bgra_lsx +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_argb_lsx +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_abgr_lsx +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_lsx_func.h" + +#endif //__loongarch_sx + +#endif /* SDL_HAVE_YUV */ diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.h new file mode 100644 index 0000000000..bcffd95c6e --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_lsx.h @@ -0,0 +1,407 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +// Provide optimized functions to convert images from 8bits yuv420 to rgb24 format + +// There are a few slightly different variations of the YCbCr color space with different parameters that +// change the conversion matrix. +// The three most common YCbCr color space, defined by BT.601, BT.709 and JPEG standard are implemented here. +// See the respective standards for details +// The matrix values used are derived from http://www.equasys.de/colorconversion.html + +// YUV420 is stored as three separate channels, with U and V (Cb and Cr) subsampled by a 2 factor +// For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This +// is suboptimal for image quality, but by far the fastest method. + +// For all methods, width and height should be even, if not, the last row/column of the result image won't be affected. +// For sse methods, if the width if not divisable by 32, the last (width%32) pixels of each line won't be affected. + +/*#include */ +#include "yuv_rgb_common.h" + +#include "SDL_stdinc.h" + +// yuv to rgb, standard c implementation +void yuv420_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +// yuv to rgb, sse implementation +// pointers must be 16 byte aligned, and strides must be divisable by 16 +void yuv420_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +// yuv to rgb, sse implementation +// pointers do not need to be 16 byte aligned +void yuv420_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + + +// rgb to yuv, standard c implementation +void rgb24_yuv420_std( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); + +// rgb to yuv, sse implementation +// pointers must be 16 byte aligned, and strides must be divisible by 16 +void rgb24_yuv420_sse( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); + +// rgb to yuv, sse implementation +// pointers do not need to be 16 byte aligned +void rgb24_yuv420_sseu( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); + + +//yuv420 to bgra, lsx implementation +void yuv420_rgb24_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.c b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.c new file mode 100644 index 0000000000..b22a89fa4e --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse.c @@ -0,0 +1,464 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "../../SDL_internal.h" + +#if SDL_HAVE_YUV +#include "yuv_rgb.h" +#include "yuv_rgb_internal.h" + +#include "SDL_cpuinfo.h" +/*#include */ + +#ifdef __SSE2__ + +/* SDL doesn't use these atm and compiling them adds seconds onto the build. --ryan. +#define SSE_FUNCTION_NAME yuv420_rgb565_sse +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgb24_sse +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgba_sse +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_bgra_sse +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_argb_sse +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_abgr_sse +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb565_sse +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb24_sse +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgba_sse +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_bgra_sse +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_argb_sse +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_abgr_sse +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb565_sse +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb24_sse +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgba_sse +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_bgra_sse +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_argb_sse +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_abgr_sse +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" +*/ + +#define SSE_FUNCTION_NAME yuv420_rgb565_sseu +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgb24_sseu +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgba_sseu +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_bgra_sseu +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_argb_sseu +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_abgr_sseu +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb565_sseu +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb24_sseu +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgba_sseu +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_bgra_sseu +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_argb_sseu +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_abgr_sseu +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb565_sseu +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb24_sseu +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgba_sseu +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_bgra_sseu +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_argb_sseu +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_abgr_sseu +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + + +/* SDL doesn't use these atm and compiling them adds seconds onto the build. --ryan. +#define UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +R1 = _mm_unpacklo_epi8(RGB1, RGB4); \ +R2 = _mm_unpackhi_epi8(RGB1, RGB4); \ +G1 = _mm_unpacklo_epi8(RGB2, RGB5); \ +G2 = _mm_unpackhi_epi8(RGB2, RGB5); \ +B1 = _mm_unpacklo_epi8(RGB3, RGB6); \ +B2 = _mm_unpackhi_epi8(RGB3, RGB6); + +#define UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +RGB1 = _mm_unpacklo_epi8(R1, G2); \ +RGB2 = _mm_unpackhi_epi8(R1, G2); \ +RGB3 = _mm_unpacklo_epi8(R2, B1); \ +RGB4 = _mm_unpackhi_epi8(R2, B1); \ +RGB5 = _mm_unpacklo_epi8(G1, B2); \ +RGB6 = _mm_unpackhi_epi8(G1, B2); \ + +#define UNPACK_RGB24_32(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ + +#define RGB2YUV_16(R, G, B, Y, U, V) \ +Y = _mm_add_epi16(_mm_mullo_epi16(R, _mm_set1_epi16(param->matrix[0][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[0][1]))); \ +Y = _mm_add_epi16(Y, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[0][2]))); \ +Y = _mm_add_epi16(Y, _mm_set1_epi16((param->y_shift)<matrix[1][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[1][1]))); \ +U = _mm_add_epi16(U, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[1][2]))); \ +U = _mm_add_epi16(U, _mm_set1_epi16(128<matrix[2][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[2][1]))); \ +V = _mm_add_epi16(V, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[2][2]))); \ +V = _mm_add_epi16(V, _mm_set1_epi16(128<*/ +#include "yuv_rgb_common.h" + +#include "SDL_stdinc.h" + +// yuv to rgb, sse implementation +// pointers must be 16 byte aligned, and strides must be divisable by 16 +void yuv420_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_sse( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +// yuv to rgb, sse implementation +// pointers do not need to be 16 byte aligned +void yuv420_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_sseu( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + + +// rgb to yuv, standard c implementation +void rgb24_yuv420_std( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); + +// rgb to yuv, sse implementation +// pointers must be 16 byte aligned, and strides must be divisible by 16 +void rgb24_yuv420_sse( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); + +// rgb to yuv, sse implementation +// pointers do not need to be 16 byte aligned +void rgb24_yuv420_sseu( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse_func.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse_func.h index f541017a40..295749a872 100644 --- a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse_func.h +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_sse_func.h @@ -52,7 +52,7 @@ { \ __m128i red_mask, tmp1, tmp2, tmp3, tmp4; \ \ - red_mask = _mm_set1_epi16((short)0xF800); \ + red_mask = _mm_set1_epi16((unsigned short)0xF800); \ RGB1 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R1), red_mask); \ RGB2 = _mm_and_si128(_mm_unpackhi_epi8(_mm_setzero_si128(), R1), red_mask); \ RGB3 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R2), red_mask); \ @@ -145,7 +145,7 @@ PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) #define PACK_PIXEL \ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ - __m128i a = _mm_set1_epi8((char)0xFF); \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ \ PACK_RGBA_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ \ @@ -156,7 +156,7 @@ PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) #define PACK_PIXEL \ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ - __m128i a = _mm_set1_epi8((char)0xFF); \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ \ PACK_RGBA_32(b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ \ @@ -167,7 +167,7 @@ PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) #define PACK_PIXEL \ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ - __m128i a = _mm_set1_epi8((char)0xFF); \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ \ PACK_RGBA_32(a, a, r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ \ @@ -178,7 +178,7 @@ PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) #define PACK_PIXEL \ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ - __m128i a = _mm_set1_epi8((char)0xFF); \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ \ PACK_RGBA_32(a, a, b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ \ @@ -491,7 +491,7 @@ void SSE_FUNCTION_NAME(uint32_t width, uint32_t height, /* Catch the right column, if needed */ { - int converted = (width & ~31); + uint32_t converted = (width & ~31); if (fix_read_nv12) { converted -= 32; } diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.c b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.c new file mode 100644 index 0000000000..a222a3abb6 --- /dev/null +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std.c @@ -0,0 +1,179 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "../../SDL_internal.h" + +#if SDL_HAVE_YUV +#include "yuv_rgb.h" +#include "yuv_rgb_internal.h" + +// divide by PRECISION_FACTOR and clamp to [0:255] interval +// input must be in the [-128*PRECISION_FACTOR:384*PRECISION_FACTOR] range +static uint8_t clampU8(int32_t v) +{ + static const uint8_t lut[512] = + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, + 47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90, + 91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, + 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158, + 159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224, + 225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 + }; + return lut[((v+128*PRECISION_FACTOR)>>PRECISION)&511]; +} + + +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +void rgb24_yuv420_std( + uint32_t width, uint32_t height, + const uint8_t *RGB, uint32_t RGB_stride, + uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, + YCbCrType yuv_type) +{ + const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]); + + uint32_t x, y; + for(y=0; y<(height-1); y+=2) + { + const uint8_t *rgb_ptr1=RGB+y*RGB_stride, + *rgb_ptr2=RGB+(y+1)*RGB_stride; + + uint8_t *y_ptr1=Y+y*Y_stride, + *y_ptr2=Y+(y+1)*Y_stride, + *u_ptr=U+(y/2)*UV_stride, + *v_ptr=V+(y/2)*UV_stride; + + for(x=0; x<(width-1); x+=2) + { + // compute yuv for the four pixels, u and v values are summed + int32_t y_tmp, u_tmp, v_tmp; + + y_tmp = param->matrix[0][0]*rgb_ptr1[0] + param->matrix[0][1]*rgb_ptr1[1] + param->matrix[0][2]*rgb_ptr1[2]; + u_tmp = param->matrix[1][0]*rgb_ptr1[0] + param->matrix[1][1]*rgb_ptr1[1] + param->matrix[1][2]*rgb_ptr1[2]; + v_tmp = param->matrix[2][0]*rgb_ptr1[0] + param->matrix[2][1]*rgb_ptr1[1] + param->matrix[2][2]*rgb_ptr1[2]; + y_ptr1[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr1[3] + param->matrix[0][1]*rgb_ptr1[4] + param->matrix[0][2]*rgb_ptr1[5]; + u_tmp += param->matrix[1][0]*rgb_ptr1[3] + param->matrix[1][1]*rgb_ptr1[4] + param->matrix[1][2]*rgb_ptr1[5]; + v_tmp += param->matrix[2][0]*rgb_ptr1[3] + param->matrix[2][1]*rgb_ptr1[4] + param->matrix[2][2]*rgb_ptr1[5]; + y_ptr1[1]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[0] + param->matrix[0][1]*rgb_ptr2[1] + param->matrix[0][2]*rgb_ptr2[2]; + u_tmp += param->matrix[1][0]*rgb_ptr2[0] + param->matrix[1][1]*rgb_ptr2[1] + param->matrix[1][2]*rgb_ptr2[2]; + v_tmp += param->matrix[2][0]*rgb_ptr2[0] + param->matrix[2][1]*rgb_ptr2[1] + param->matrix[2][2]*rgb_ptr2[2]; + y_ptr2[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[3] + param->matrix[0][1]*rgb_ptr2[4] + param->matrix[0][2]*rgb_ptr2[5]; + u_tmp += param->matrix[1][0]*rgb_ptr2[3] + param->matrix[1][1]*rgb_ptr2[4] + param->matrix[1][2]*rgb_ptr2[5]; + v_tmp += param->matrix[2][0]*rgb_ptr2[3] + param->matrix[2][1]*rgb_ptr2[4] + param->matrix[2][2]*rgb_ptr2[5]; + y_ptr2[1]=clampU8(y_tmp+((param->y_shift)<*/ +#include "yuv_rgb_common.h" + +#include "SDL_stdinc.h" + +// yuv to rgb, standard c implementation +void yuv420_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); diff --git a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h index 94872ec9f5..f359abae8b 100644 --- a/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h +++ b/vs/sdl2/src/video/yuv2rgb/yuv_rgb_std_func.h @@ -69,10 +69,15 @@ #endif +#ifdef _MSC_VER /* Visual Studio analyzer can't tell that we're building this with different constants */ +#pragma warning(push) +#pragma warning(disable : 6239) +#endif + void STD_FUNCTION_NAME( - uint32_t width, uint32_t height, - const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, - uint8_t *RGB, uint32_t RGB_stride, + uint32_t width, uint32_t height, + const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, + uint8_t *RGB, uint32_t RGB_stride, YCbCrType yuv_type) { const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]); @@ -113,26 +118,26 @@ void STD_FUNCTION_NAME( for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + #if uv_y_sample_interval > 1 y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); - + y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); #endif @@ -149,19 +154,19 @@ void STD_FUNCTION_NAME( if (uv_x_sample_interval == 2 && x == (width-1)) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + #if uv_y_sample_interval > 1 y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr2); @@ -175,28 +180,28 @@ void STD_FUNCTION_NAME( const uint8_t *y_ptr1=Y+y*Y_stride, *u_ptr=U+(y/uv_y_sample_interval)*UV_stride, *v_ptr=V+(y/uv_y_sample_interval)*UV_stride; - + uint8_t *rgb_ptr1=RGB+y*RGB_stride; - + for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); - + y_ptr1+=2*y_pixel_stride; u_ptr+=2*uv_pixel_stride/uv_x_sample_interval; v_ptr+=2*uv_pixel_stride/uv_x_sample_interval; @@ -206,16 +211,16 @@ void STD_FUNCTION_NAME( if (uv_x_sample_interval == 2 && x == (width-1)) { // Compute U and V contributions, common to the four pixels - + int32_t u_tmp = ((*u_ptr)-128); int32_t v_tmp = ((*v_ptr)-128); - + int32_t r_tmp = (v_tmp*param->v_r_factor); int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); int32_t b_tmp = (u_tmp*param->u_b_factor); - + // Compute the Y contribution for each pixel - + int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor); PACK_PIXEL(rgb_ptr1); } @@ -227,6 +232,10 @@ void STD_FUNCTION_NAME( #undef uv_y_sample_interval } +#ifdef _MSC_VER +#pragma warning(pop) +#endif + #undef STD_FUNCTION_NAME #undef YUV_FORMAT #undef RGB_FORMAT diff --git a/vs/sdl2/test/CMakeLists.txt b/vs/sdl2/test/CMakeLists.txt index a7099e16c0..f048d51f9e 100644 --- a/vs/sdl2/test/CMakeLists.txt +++ b/vs/sdl2/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.0...3.5) project(SDL2_test) include(CheckCCompilerFlag) @@ -7,18 +7,55 @@ include(CMakePushCheckState) set(SDL_TEST_EXECUTABLES) set(SDL_TESTS_NONINTERACTIVE) -set(SDL_TESTS_NEEDS_ESOURCES) +set(SDL_TESTS_NEEDS_RESOURCES) macro(add_sdl_test_executable TARGET) cmake_parse_arguments(AST "NONINTERACTIVE;NEEDS_RESOURCES" "" "" ${ARGN}) - add_executable(${TARGET} ${AST_UNPARSED_ARGUMENTS}) + if(ANDROID) + add_library(${TARGET} SHARED ${AST_UNPARSED_ARGUMENTS}) + else() + add_executable(${TARGET} ${AST_UNPARSED_ARGUMENTS}) + endif() list(APPEND SDL_TEST_EXECUTABLES ${TARGET}) if(AST_NONINTERACTIVE) list(APPEND SDL_TESTS_NONINTERACTIVE ${TARGET}) endif() if(AST_NEEDS_RESOURCES) - list(APPEND SDL_TESTS_NEEDS_ESOURCES ${TARGET}) + list(APPEND SDL_TESTS_NEEDS_RESOURCES ${TARGET}) + endif() + + if(HAVE_GCC_WDOCUMENTATION) + target_compile_options(${TARGET} PRIVATE "-Wdocumentation") + if(HAVE_GCC_WERROR_DOCUMENTATION) + target_compile_options(${TARGET} PRIVATE "-Werror=documentation") + endif() + endif() + + if(HAVE_GCC_WDOCUMENTATION_UNKNOWN_COMMAND) + if(SDL_WERROR) + if(HAVE_GCC_WERROR_DOCUMENTATION_UNKNOWN_COMMAND) + target_compile_options(${TARGET} PRIVATE "-Werror=documentation-unknown-command") + endif() + endif() + target_compile_options(${TARGET} PRIVATE "-Wdocumentation-unknown-command") + endif() + + if(HAVE_GCC_COMMENT_BLOCK_COMMANDS) + target_compile_options(${TARGET} PRIVATE "-fcomment-block-commands=threadsafety") + target_compile_options(${TARGET} PRIVATE "-fcomment-block-commands=deprecated") + else() + if(HAVE_CLANG_COMMENT_BLOCK_COMMANDS) + target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=threadsafety") + target_compile_options(${TARGET} PRIVATE "/clang:-fcomment-block-commands=deprecated") + endif() + endif() + + if(USE_GCC OR USE_CLANG) + check_c_compiler_flag(-fno-fast-math HAVE_GCC_FNO_FAST_MATH) + if(HAVE_GCC_FNO_FAST_MATH) + target_compile_options(${TARGET} PRIVATE -fno-fast-math) + endif() endif() endmacro() @@ -53,7 +90,7 @@ if(PSP) psppower ) elseif(PS2) -link_libraries( + link_libraries( SDL2main SDL2_test SDL2-static @@ -61,7 +98,7 @@ link_libraries( gskit dmakit ps2_drivers -) + ) else() link_libraries(SDL2::SDL2test SDL2::SDL2-static) endif() @@ -91,7 +128,7 @@ if(NOT MSVC OR NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM64") endif() if (OPENGL_FOUND) -add_definitions(-DHAVE_OPENGL) + add_definitions(-DHAVE_OPENGL) endif() add_sdl_test_executable(checkkeys checkkeys.c) @@ -103,7 +140,7 @@ add_sdl_test_executable(testresample NEEDS_RESOURCES testresample.c) add_sdl_test_executable(testaudioinfo testaudioinfo.c) file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c) -add_sdl_test_executable(testautomation NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES}) +add_sdl_test_executable(testautomation NONINTERACTIVE NEEDS_RESOURCES ${TESTAUTOMATION_SOURCE_FILES}) add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES testmultiaudio.c testutils.c) add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES testaudiohotplug.c testutils.c) add_sdl_test_executable(testaudiocapture testaudiocapture.c) @@ -168,6 +205,9 @@ add_sdl_test_executable(testoverlay2 NEEDS_RESOURCES testoverlay2.c testyuv_cvt. add_sdl_test_executable(testplatform NONINTERACTIVE testplatform.c) add_sdl_test_executable(testpower NONINTERACTIVE testpower.c) add_sdl_test_executable(testfilesystem NONINTERACTIVE testfilesystem.c) +if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4) + add_sdl_test_executable(testfilesystem_pre NONINTERACTIVE testfilesystem_pre.c) +endif() add_sdl_test_executable(testrendertarget NEEDS_RESOURCES testrendertarget.c testutils.c) add_sdl_test_executable(testscale NEEDS_RESOURCES testscale.c testutils.c) add_sdl_test_executable(testsem testsem.c) @@ -214,18 +254,18 @@ endif() cmake_pop_check_state() if(SDL_DUMMYAUDIO) - list(APPEND SDL_TESTS_NONINTERACTIVE - testaudioinfo - testsurround - ) + list(APPEND SDL_TESTS_NONINTERACTIVE + testaudioinfo + testsurround + ) endif() if(SDL_DUMMYVIDEO) - list(APPEND SDL_TESTS_NONINTERACTIVE - testkeys - testbounds - testdisplayinfo - ) + list(APPEND SDL_TESTS_NONINTERACTIVE + testkeys + testbounds + testdisplayinfo + ) endif() if(OPENGL_FOUND) @@ -251,7 +291,7 @@ file(COPY ${RESOURCE_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) if(PSP) # Build EBOOT files if building for PSP set(BUILD_EBOOT - ${SDL_TESTS_NEEDS_ESOURCES} + ${SDL_TESTS_NEEDS_RESOURCES} testatomic testaudiocapture testaudioinfo @@ -360,14 +400,41 @@ if(RISCOS) endforeach() endif() +if(CMAKE_RUNTIME_OUTPUT_DIRECTORY) + set(test_bin_dir "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + if(NOT IS_ABSOLUTE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") + endif() +else() + set(test_bin_dir "${CMAKE_CURRENT_BINARY_DIR}") +endif() +if(NOT CMAKE_VERSION VERSION_LESS 3.20) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + set(test_bin_dir "${test_bin_dir}$<$:/$>") +endif() + +set(RESOURCE_FILES_BINDIR) +foreach(resource_file IN LISTS RESOURCE_FILES) + get_filename_component(res_file_name ${resource_file} NAME) + set(resource_file_bindir "${test_bin_dir}/${res_file_name}") + add_custom_command(OUTPUT "${resource_file_bindir}" + COMMAND "${CMAKE_COMMAND}" -E copy "${resource_file}" "${resource_file_bindir}" + DEPENDS "${resource_file}" + ) + list(APPEND RESOURCE_FILES_BINDIR "${resource_file_bindir}") +endforeach() +add_custom_target(copy-sdl-test-resources + DEPENDS "${RESOURCE_FILES_BINDIR}" +) + foreach(APP IN LISTS SDL_TESTS_NEEDS_RESOURCES) - foreach(RESOURCE_FILE ${RESOURCE_FILES}) - if(PSP OR PS2) + if(PSP OR PS2) + foreach(RESOURCE_FILE ${RESOURCE_FILES}) add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $/sdl-${APP}) - else() - add_custom_command(TARGET ${APP} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILE} $) - endif() - endforeach(RESOURCE_FILE) + endforeach() + else() + add_dependencies(${APP} copy-sdl-test-resources) + endif() if(APPLE) # Make sure resource files get installed into macOS/iOS .app bundles. target_sources(${APP} PRIVATE "${RESOURCE_FILES}") @@ -424,8 +491,13 @@ foreach(TESTCASE ${SDL_TESTS_NONINTERACTIVE}) endif() endforeach() +set_tests_properties(testautomation PROPERTIES TIMEOUT 120) set_tests_properties(testthread PROPERTIES TIMEOUT 40) set_tests_properties(testtimer PROPERTIES TIMEOUT 60) +if(TARGET testfilesystem_pre) + set_property(TEST testfilesystem_pre PROPERTY TIMEOUT 60) + set_property(TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre) +endif() if(SDL_INSTALL_TESTS) if(RISCOS) @@ -439,6 +511,11 @@ if(SDL_INSTALL_TESTS) DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2 ) endif() + if(MSVC) + foreach(test ${SDL_TEST_EXECUTABLES}) + SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2") + endforeach() + endif() install( FILES ${RESOURCE_FILES} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL2 diff --git a/vs/sdl2/test/Makefile.in b/vs/sdl2/test/Makefile.in index 93df6360e8..76331d67fd 100644 --- a/vs/sdl2/test/Makefile.in +++ b/vs/sdl2/test/Makefile.in @@ -95,7 +95,7 @@ installedtestsmetadir = $(datadir)/installed-tests/SDL2 generatetestmeta: rm -f *.test - set -e; for exe in $(noninteractive) $(needs_audio) $(needs_display); do \ + set -e; for exe in $(TESTS); do \ sed \ -e 's#@installedtestsdir@#$(installedtestsdir)#g' \ -e "s#@exe@#$$exe#g" \ @@ -141,6 +141,7 @@ testautomation$(EXE): $(srcdir)/testautomation.c \ $(srcdir)/testautomation_hints.c \ $(srcdir)/testautomation_joystick.c \ $(srcdir)/testautomation_keyboard.c \ + $(srcdir)/testautomation_log.c \ $(srcdir)/testautomation_main.c \ $(srcdir)/testautomation_math.c \ $(srcdir)/testautomation_mouse.c \ @@ -151,6 +152,7 @@ testautomation$(EXE): $(srcdir)/testautomation.c \ $(srcdir)/testautomation_rwops.c \ $(srcdir)/testautomation_sdltest.c \ $(srcdir)/testautomation_stdlib.c \ + $(srcdir)/testautomation_subsystems.c \ $(srcdir)/testautomation_surface.c \ $(srcdir)/testautomation_syswm.c \ $(srcdir)/testautomation_timer.c \ @@ -385,8 +387,12 @@ distclean: clean rm -f config.status config.cache config.log rm -rf $(srcdir)/autom4te* -noninteractive = \ +TESTS = \ testatomic$(EXE) \ + testaudioinfo$(EXE) \ + testautomation$(EXE) \ + testbounds$(EXE) \ + testdisplayinfo$(EXE) \ testerror$(EXE) \ testevdev$(EXE) \ testfilesystem$(EXE) \ @@ -395,23 +401,12 @@ noninteractive = \ testplatform$(EXE) \ testpower$(EXE) \ testqsort$(EXE) \ + testsurround$(EXE) \ testthread$(EXE) \ testtimer$(EXE) \ testver$(EXE) \ $(NULL) -needs_audio = \ - testaudioinfo$(EXE) \ - testsurround$(EXE) \ - $(NULL) - -needs_display = \ - testbounds$(EXE) \ - testdisplayinfo$(EXE) \ - $(NULL) - -TESTS = $(noninteractive) $(needs_audio) $(needs_display) - check: @set -e; \ status=0; \ diff --git a/vs/sdl2/test/acinclude.m4 b/vs/sdl2/test/acinclude.m4 index 0fdf353ea2..ebee8238ab 100644 --- a/vs/sdl2/test/acinclude.m4 +++ b/vs/sdl2/test/acinclude.m4 @@ -5,8 +5,6 @@ # stolen from Manish Singh # Shamelessly stolen from Owen Taylor -# 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 @@ -45,7 +43,7 @@ AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run if test "x$sdl_pc" = xyes ; then no_sdl="" - SDL2_CONFIG="pkg-config sdl2" + SDL2_CONFIG="$PKG_CONFIG sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then diff --git a/vs/sdl2/test/checkkeys.c b/vs/sdl2/test/checkkeys.c index 4efdc721e1..f546900c50 100644 --- a/vs/sdl2/test/checkkeys.c +++ b/vs/sdl2/test/checkkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -269,14 +269,14 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("CheckKeys Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(2); @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) textwin = SDLTest_TextWindowCreate(0, 0, 640, 480); -#if __IPHONEOS__ +#ifdef __IPHONEOS__ /* Creating the context creates the view, which we need to show keyboard */ SDL_GL_CreateContext(window); #endif diff --git a/vs/sdl2/test/checkkeysthreads.c b/vs/sdl2/test/checkkeysthreads.c index 3db5dd2dc7..efd654875f 100644 --- a/vs/sdl2/test/checkkeysthreads.c +++ b/vs/sdl2/test/checkkeysthreads.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -254,7 +254,7 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("CheckKeys Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) renderer = SDL_CreateRenderer(window, -1, 0); SDL_RenderPresent(renderer); -#if __IPHONEOS__ +#ifdef __IPHONEOS__ /* Creating the context creates the view, which we need to show keyboard */ SDL_GL_CreateContext(window); #endif diff --git a/vs/sdl2/test/configure b/vs/sdl2/test/configure index c71abe4897..8ea80bc27e 100755 --- a/vs/sdl2/test/configure +++ b/vs/sdl2/test/configure @@ -3966,7 +3966,7 @@ fi if test "x$sdl_pc" = xyes ; then no_sdl="" - SDL2_CONFIG="pkg-config sdl2" + SDL2_CONFIG="$PKG_CONFIG sdl2" else as_save_PATH="$PATH" if test "x$prefix" != xNONE && test "$cross_compiling" != yes; then diff --git a/vs/sdl2/test/controllermap.c b/vs/sdl2/test/controllermap.c index cfb0efface..982a9fb6fd 100644 --- a/vs/sdl2/test/controllermap.c +++ b/vs/sdl2/test/controllermap.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -288,7 +288,8 @@ ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding) SDL_Log("Configuring button binding for button %d\n", pBinding->value.button); break; case SDL_CONTROLLER_BINDTYPE_AXIS: - SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false"); + SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, + pBinding->committed ? "true" : "false"); break; case SDL_CONTROLLER_BINDTYPE_HAT: SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); @@ -729,13 +730,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 2; } screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); return 2; } @@ -766,7 +767,7 @@ int main(int argc, char *argv[]) name = SDL_JoystickNameForIndex(i); SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); joystick = SDL_JoystickOpen(i); - if (joystick == NULL) { + if (!joystick) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError()); } else { @@ -792,7 +793,7 @@ int main(int argc, char *argv[]) } } joystick = SDL_JoystickOpen(joystick_index); - if (joystick == NULL) { + if (!joystick) { SDL_Log("Couldn't open joystick %d: %s\n", joystick_index, SDL_GetError()); } else { WatchJoystick(joystick); diff --git a/vs/sdl2/test/loopwave.c b/vs/sdl2/test/loopwave.c index 156767c20f..15f13658c5 100644 --- a/vs/sdl2/test/loopwave.c +++ b/vs/sdl2/test/loopwave.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -127,7 +127,7 @@ int main(int argc, char *argv[]) filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } diff --git a/vs/sdl2/test/loopwavequeue.c b/vs/sdl2/test/loopwavequeue.c index 70dd072d29..01b6ece3e3 100644 --- a/vs/sdl2/test/loopwavequeue.c +++ b/vs/sdl2/test/loopwavequeue.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #include "SDL.h" -#if HAVE_SIGNAL_H +#ifdef HAVE_SIGNAL_H #include #endif @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } @@ -97,7 +97,7 @@ int main(int argc, char *argv[]) wave.spec.callback = NULL; /* we'll push audio. */ -#if HAVE_SIGNAL_H +#ifdef HAVE_SIGNAL_H /* Set the signals */ #ifdef SIGHUP (void)signal(SIGHUP, poked); diff --git a/vs/sdl2/test/testatomic.c b/vs/sdl2/test/testatomic.c index 15a7a6a7d9..1a599101ec 100644 --- a/vs/sdl2/test/testatomic.c +++ b/vs/sdl2/test/testatomic.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -234,7 +234,8 @@ static void RunEpicTest() v = SDL_AtomicGet(&good); SDL_Log("Atomic %d Non-Atomic %d\n", v, bad); SDL_assert(v == Expect); - SDL_assert(bad != Expect); + /* We can't guarantee that bad != Expect, this would happen on a single core system, for example. */ + /*SDL_assert(bad != Expect);*/ } /* End atomic operation test */ diff --git a/vs/sdl2/test/testaudiocapture.c b/vs/sdl2/test/testaudiocapture.c index a8fdf5ec5c..523385b3ae 100644 --- a/vs/sdl2/test/testaudiocapture.c +++ b/vs/sdl2/test/testaudiocapture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testaudiohotplug.c b/vs/sdl2/test/testaudiohotplug.c index e4bd9ac096..354d4644f3 100644 --- a/vs/sdl2/test/testaudiohotplug.c +++ b/vs/sdl2/test/testaudiohotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -17,7 +17,7 @@ #include #include -#if HAVE_SIGNAL_H +#ifdef HAVE_SIGNAL_H #include #endif @@ -96,7 +96,7 @@ iteration() int index = e.adevice.which; int iscapture = e.adevice.iscapture; const char *name = SDL_GetAudioDeviceName(index, iscapture); - if (name != NULL) { + if (name) { SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n", @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) quit(1); } -#if HAVE_SIGNAL_H +#ifdef HAVE_SIGNAL_H /* Set the signals */ #ifdef SIGHUP (void)signal(SIGHUP, poked); diff --git a/vs/sdl2/test/testaudioinfo.c b/vs/sdl2/test/testaudioinfo.c index ae59cbcc86..ec4b86470d 100644 --- a/vs/sdl2/test/testaudioinfo.c +++ b/vs/sdl2/test/testaudioinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ print_devices(int iscapture) int i; for (i = 0; i < n; i++) { const char *name = SDL_GetAudioDeviceName(i, iscapture); - if (name != NULL) { + if (name) { SDL_Log(" %d: %s\n", i, name); } else { SDL_Log(" %d Error: %s\n", i, SDL_GetError()); @@ -81,7 +81,7 @@ int main(int argc, char **argv) if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 0) < 0) { SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError()); } else { - SDL_Log("Default Output Name: %s\n", deviceName != NULL ? deviceName : "unknown"); + SDL_Log("Default Output Name: %s\n", deviceName ? deviceName : "unknown"); SDL_free(deviceName); SDL_Log("Sample Rate: %d\n", spec.freq); SDL_Log("Channels: %d\n", spec.channels); @@ -91,7 +91,7 @@ int main(int argc, char **argv) if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) { SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError()); } else { - SDL_Log("Default Capture Name: %s\n", deviceName != NULL ? deviceName : "unknown"); + SDL_Log("Default Capture Name: %s\n", deviceName ? deviceName : "unknown"); SDL_free(deviceName); SDL_Log("Sample Rate: %d\n", spec.freq); SDL_Log("Channels: %d\n", spec.channels); diff --git a/vs/sdl2/test/testautomation.c b/vs/sdl2/test/testautomation.c index 2150ed246b..3b5fad808a 100644 --- a/vs/sdl2/test/testautomation.c +++ b/vs/sdl2/test/testautomation.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testautomation_audio.c b/vs/sdl2/test/testautomation_audio.c index bd586314f9..16ab753e97 100644 --- a/vs/sdl2/test/testautomation_audio.c +++ b/vs/sdl2/test/testautomation_audio.c @@ -52,6 +52,42 @@ void SDLCALL _audio_testCallback(void *userdata, Uint8 *stream, int len) _audio_testCallbackLength += len; } +#if defined(__linux__) +/* Linux builds can include many audio drivers, but some are very + * obscure and typically unsupported on modern systems. They will + * be skipped in tests that run against all included drivers, as + * they are basically guaranteed to fail. + */ +static SDL_bool DriverIsProblematic(const char *driver) +{ + static const char *driverList[] = { + /* Omnipresent in Linux builds, but deprecated since 2002, + * very rarely used on Linux nowadays, and is almost certainly + * guaranteed to fail. + */ + "dsp", + + /* OpenBSD sound API. Can be used on Linux, but very rare. */ + "sndio", + + /* Always fails on initialization and/or opening a device. + * Does anyone or anything actually use this? + */ + "nas" + }; + + int i; + + for (i = 0; i < SDL_arraysize(driverList); ++i) { + if (SDL_strcmp(driver, driverList[i]) == 0) { + return SDL_TRUE; + } + } + + return SDL_FALSE; +} +#endif + /* Test case functions */ /** @@ -83,20 +119,43 @@ int audio_initQuitAudio() int result; int i, iMax; const char *audioDriver; + const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER); /* Stop SDL audio subsystem */ SDL_QuitSubSystem(SDL_INIT_AUDIO); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + /* Was a specific driver requested? */ + audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER); + + if (audioDriver == NULL) { + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + } else { + /* A specific driver was requested for testing */ + iMax = 1; + } for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + if (audioDriver == NULL) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + +#if defined(__linux__) + if (DriverIsProblematic(audioDriver)) { + SDLTest_Log("Audio driver '%s' flagged as problematic: skipping init/quit test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver); + audioDriver = NULL; + continue; + } +#endif + } + + if (hint && SDL_strcmp(audioDriver, hint) != 0) { + continue; + } /* Call Init */ result = SDL_AudioInit(audioDriver); @@ -106,6 +165,8 @@ int audio_initQuitAudio() /* Call Quit */ SDL_AudioQuit(); SDLTest_AssertPass("Call to SDL_AudioQuit()"); + + audioDriver = NULL; } /* NULL driver specification */ @@ -140,20 +201,43 @@ int audio_initOpenCloseQuitAudio() int i, iMax, j, k; const char *audioDriver; SDL_AudioSpec desired; + const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER); /* Stop SDL audio subsystem */ SDL_QuitSubSystem(SDL_INIT_AUDIO); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + /* Was a specific driver requested? */ + audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER); + + if (audioDriver == NULL) { + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + } else { + /* A specific driver was requested for testing */ + iMax = 1; + } for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + if (audioDriver == NULL) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + +#if defined(__linux__) + if (DriverIsProblematic(audioDriver)) { + SDLTest_Log("Audio driver '%s' flagged as problematic: skipping device open/close test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver); + audioDriver = NULL; + continue; + } +#endif + } + + if (hint && SDL_strcmp(audioDriver, hint) != 0) { + continue; + } /* Change specs */ for (j = 0; j < 2; j++) { @@ -163,6 +247,17 @@ int audio_initOpenCloseQuitAudio() SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + /* Check for output devices */ + result = SDL_GetNumAudioDevices(SDL_FALSE); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)"); + SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result); + if (result <= 0) { + SDLTest_Log("No output devices for '%s': skipping device open/close test", audioDriver); + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); + break; + } + /* Set spec */ SDL_memset(&desired, 0, sizeof(desired)); switch (j) { @@ -207,7 +302,10 @@ int audio_initOpenCloseQuitAudio() } } /* spec loop */ - } /* driver loop */ + + audioDriver = NULL; + + } /* driver loop */ /* Restart audio again */ _audioSetUp(NULL); @@ -229,20 +327,43 @@ int audio_pauseUnpauseAudio() int originalCounter; const char *audioDriver; SDL_AudioSpec desired; + const char *hint = SDL_GetHint(SDL_HINT_AUDIODRIVER); /* Stop SDL audio subsystem */ SDL_QuitSubSystem(SDL_INIT_AUDIO); SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); - /* Loop over all available audio drivers */ - iMax = SDL_GetNumAudioDrivers(); - SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); - SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + /* Was a specific driver requested? */ + audioDriver = SDL_GetHint(SDL_HINT_AUDIODRIVER); + + if (audioDriver == NULL) { + /* Loop over all available audio drivers */ + iMax = SDL_GetNumAudioDrivers(); + SDLTest_AssertPass("Call to SDL_GetNumAudioDrivers()"); + SDLTest_AssertCheck(iMax > 0, "Validate number of audio drivers; expected: >0 got: %d", iMax); + } else { + /* A specific driver was requested for testing */ + iMax = 1; + } for (i = 0; i < iMax; i++) { - audioDriver = SDL_GetAudioDriver(i); - SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); - SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); - SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + if (audioDriver == NULL) { + audioDriver = SDL_GetAudioDriver(i); + SDLTest_AssertPass("Call to SDL_GetAudioDriver(%d)", i); + SDLTest_Assert(audioDriver != NULL, "Audio driver name is not NULL"); + SDLTest_AssertCheck(audioDriver[0] != '\0', "Audio driver name is not empty; got: %s", audioDriver); /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ + +#if defined(__linux__) + if (DriverIsProblematic(audioDriver)) { + SDLTest_Log("Audio driver '%s' flagged as problematic: skipping pause/unpause test (set SDL_AUDIODRIVER=%s to force)", audioDriver, audioDriver); + audioDriver = NULL; + continue; + } +#endif + } + + if (hint && SDL_strcmp(audioDriver, hint) != 0) { + continue; + } /* Change specs */ for (j = 0; j < 2; j++) { @@ -252,6 +373,16 @@ int audio_pauseUnpauseAudio() SDLTest_AssertPass("Call to SDL_AudioInit('%s')", audioDriver); SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0 got: %d", result); + result = SDL_GetNumAudioDevices(SDL_FALSE); + SDLTest_AssertPass("Call to SDL_GetNumAudioDevices(SDL_FALSE)"); + SDLTest_AssertCheck(result >= 0, "Validate result value; expected: >=0 got: %d", result); + if (result <= 0) { + SDLTest_Log("No output devices for '%s': skipping pause/unpause test", audioDriver); + SDL_AudioQuit(); + SDLTest_AssertPass("Call to SDL_AudioQuit()"); + break; + } + /* Set spec */ SDL_memset(&desired, 0, sizeof(desired)); switch (j) { @@ -326,7 +457,10 @@ int audio_pauseUnpauseAudio() SDLTest_AssertPass("Call to SDL_AudioQuit()"); } /* spec loop */ - } /* driver loop */ + + audioDriver = NULL; + + } /* driver loop */ /* Restart audio again */ _audioSetUp(NULL); @@ -1025,8 +1159,8 @@ int audio_resampleLoss() SDLTest_AssertPass("Test resampling of %i s %i Hz %f phase sine wave from sampling rate of %i Hz to %i Hz", spec->time, spec->freq, spec->phase, spec->rate_in, spec->rate_out); - ret = SDL_BuildAudioCVT(&cvt, AUDIO_F32, 1, spec->rate_in, AUDIO_F32, 1, spec->rate_out); - SDLTest_AssertPass("Call to SDL_BuildAudioCVT(&cvt, AUDIO_F32, 1, %i, AUDIO_F32, 1, %i)", spec->rate_in, spec->rate_out); + ret = SDL_BuildAudioCVT(&cvt, AUDIO_F32SYS, 1, spec->rate_in, AUDIO_F32SYS, 1, spec->rate_out); + SDLTest_AssertPass("Call to SDL_BuildAudioCVT(&cvt, AUDIO_F32SYS, 1, %i, AUDIO_F32SYS, 1, %i)", spec->rate_in, spec->rate_out); SDLTest_AssertCheck(ret == 1, "Expected SDL_BuildAudioCVT to succeed and conversion to be needed."); if (ret != 1) { return TEST_ABORTED; diff --git a/vs/sdl2/test/testautomation_clipboard.c b/vs/sdl2/test/testautomation_clipboard.c index dbe1ef8e40..ce8ea1bd3d 100644 --- a/vs/sdl2/test/testautomation_clipboard.c +++ b/vs/sdl2/test/testautomation_clipboard.c @@ -84,7 +84,7 @@ int clipboard_testSetClipboardText(void *arg) char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); int result; - result = SDL_SetClipboardText((const char *)text); + result = SDL_SetClipboardText(text); SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); SDLTest_AssertCheck( result == 0, @@ -112,7 +112,7 @@ int clipboard_testSetPrimarySelectionText(void *arg) char *textRef = SDLTest_RandomAsciiString(); char *text = SDL_strdup(textRef); int result; - result = SDL_SetPrimarySelectionText((const char *)text); + result = SDL_SetPrimarySelectionText(text); SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText succeeded"); SDLTest_AssertCheck( result == 0, @@ -149,7 +149,7 @@ int clipboard_testClipboardTextFunctions(void *arg) boolResult = SDL_HasClipboardText(); SDLTest_AssertPass("Call to SDL_HasClipboardText succeeded"); if (boolResult == SDL_TRUE) { - intResult = SDL_SetClipboardText((const char *)NULL); + intResult = SDL_SetClipboardText(NULL); SDLTest_AssertPass("Call to SDL_SetClipboardText(NULL) succeeded"); SDLTest_AssertCheck( intResult == 0, @@ -176,7 +176,7 @@ int clipboard_testClipboardTextFunctions(void *arg) charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ "Verify SDL_GetClipboardText returned string with length 0, got length %i", (int)SDL_strlen(charResult)); - intResult = SDL_SetClipboardText((const char *)text); + intResult = SDL_SetClipboardText(text); SDLTest_AssertPass("Call to SDL_SetClipboardText succeeded"); SDLTest_AssertCheck( intResult == 0, @@ -227,7 +227,7 @@ int clipboard_testPrimarySelectionTextFunctions(void *arg) boolResult = SDL_HasPrimarySelectionText(); SDLTest_AssertPass("Call to SDL_HasPrimarySelectionText succeeded"); if (boolResult == SDL_TRUE) { - intResult = SDL_SetPrimarySelectionText((const char *)NULL); + intResult = SDL_SetPrimarySelectionText(NULL); SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText(NULL) succeeded"); SDLTest_AssertCheck( intResult == 0, @@ -254,7 +254,7 @@ int clipboard_testPrimarySelectionTextFunctions(void *arg) charResult[0] == '\0', /* NOLINT(clang-analyzer-core.NullDereference): Checked for NULL above */ "Verify SDL_GetPrimarySelectionText returned string with length 0, got length %i", (int)SDL_strlen(charResult)); - intResult = SDL_SetPrimarySelectionText((const char *)text); + intResult = SDL_SetPrimarySelectionText(text); SDLTest_AssertPass("Call to SDL_SetPrimarySelectionText succeeded"); SDLTest_AssertCheck( intResult == 0, diff --git a/vs/sdl2/test/testautomation_events.c b/vs/sdl2/test/testautomation_events.c index 6d0f3ff533..d4babdafce 100644 --- a/vs/sdl2/test/testautomation_events.c +++ b/vs/sdl2/test/testautomation_events.c @@ -68,6 +68,10 @@ int events_pushPumpAndPollUserevent(void *arg) SDLTest_AssertPass("Call to SDL_PollEvent()"); SDLTest_AssertCheck(result == 1, "Check result from SDL_PollEvent, expected: 1, got: %d", result); + /* Need to finish getting all events and sentinel, otherwise other tests that rely on event are in bad state */ + while (SDL_PollEvent(&event2)) { + } + return TEST_COMPLETED; } diff --git a/vs/sdl2/test/testautomation_guid.c b/vs/sdl2/test/testautomation_guid.c index cf99dea813..81e60e8f4b 100644 --- a/vs/sdl2/test/testautomation_guid.c +++ b/vs/sdl2/test/testautomation_guid.c @@ -125,7 +125,7 @@ TestGuidToString(void *arg) SDL_GUIDToString(guid, guid_str, size); /* Check bytes before guid_str_buf */ - expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (fill_char << 24); + expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (((Uint32)fill_char) << 24); SDL_memcpy(&actual_prefix, guid_str_buf, 4); SDLTest_AssertCheck(expected_prefix == actual_prefix, "String buffer memory before output untouched, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32 ", at size=%d", expected_prefix, actual_prefix, size); diff --git a/vs/sdl2/test/testautomation_keyboard.c b/vs/sdl2/test/testautomation_keyboard.c index 0d459d0b2d..5ed9207bca 100644 --- a/vs/sdl2/test/testautomation_keyboard.c +++ b/vs/sdl2/test/testautomation_keyboard.c @@ -463,32 +463,34 @@ int keyboard_setTextInputRect(void *arg) */ int keyboard_setTextInputRectNegative(void *arg) { + int platform_sets_error_message = SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 || + SDL_strcmp(SDL_GetCurrentVideoDriver(), "android") == 0 || + SDL_strcmp(SDL_GetCurrentVideoDriver(), "cococa") == 0; /* Some platforms set also an error message; prepare for checking it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA const char *expectedError = "Parameter 'rect' is invalid"; const char *error; SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); -#endif /* NULL refRect */ SDL_SetTextInputRect(NULL); SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)"); /* Some platforms set also an error message; so check it */ -#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); + + if (platform_sets_error_message) { + error = SDL_GetError(); + SDLTest_AssertPass("Call to SDL_GetError()"); + SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); + if (error != NULL) { + SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, + "Validate error message, expected: '%s', got: '%s'", expectedError, error); + } } SDL_ClearError(); SDLTest_AssertPass("Call to SDL_ClearError()"); -#endif return TEST_COMPLETED; } diff --git a/vs/sdl2/test/testautomation_log.c b/vs/sdl2/test/testautomation_log.c new file mode 100644 index 0000000000..4edb487ea3 --- /dev/null +++ b/vs/sdl2/test/testautomation_log.c @@ -0,0 +1,209 @@ +/** + * Log test suite + */ +#include "SDL.h" +#include "SDL_test.h" + + +static SDL_LogOutputFunction original_function; +static void *original_userdata; + +static void SDLCALL TestLogOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) +{ + int *message_count = (int *)userdata; + ++(*message_count); +} + +static void EnableTestLog(int *message_count) +{ + *message_count = 0; + SDL_LogGetOutputFunction(&original_function, &original_userdata); + SDL_LogSetOutputFunction(TestLogOutput, message_count); +} + +static void DisableTestLog() +{ + SDL_LogSetOutputFunction(original_function, original_userdata); +} + +/* Fixture */ + +/* Test case functions */ + +/** + * Check SDL_HINT_LOGGING functionality + */ +static int log_testHint(void *arg) +{ + int count; + + SDL_SetHint(SDL_HINT_LOGGING, NULL); + SDLTest_AssertPass("SDL_SetHint(SDL_HINT_LOGGING, NULL)"); + { + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + } + + SDL_SetHint(SDL_HINT_LOGGING, "debug"); + SDLTest_AssertPass("SDL_SetHint(SDL_HINT_LOGGING, \"debug\")"); + { + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_VERBOSE, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + } + + SDL_SetHint(SDL_HINT_LOGGING, "system=debug"); + SDLTest_AssertPass("SDL_SetHint(SDL_HINT_LOGGING, \"system=debug\")"); + { + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + } + + SDL_SetHint(SDL_HINT_LOGGING, "app=warn,system=debug,assert=quiet,*=info"); + SDLTest_AssertPass("SDL_SetHint(SDL_HINT_LOGGING, \"app=warn,system=debug,assert=quiet,*=info\")"); + { + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_CRITICAL, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_CRITICAL, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_INFO, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_INFO, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + } + + SDL_SetHint(SDL_HINT_LOGGING, "0=4,3=2,2=0,*=3"); + SDLTest_AssertPass("SDL_SetHint(SDL_HINT_LOGGING, \"0=4,3=2,2=0,*=3\")"); + { + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_SYSTEM, SDL_LOG_PRIORITY_VERBOSE, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_CRITICAL, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_ASSERT, SDL_LOG_PRIORITY_CRITICAL, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_INFO, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_INFO, \"test\")"); + SDLTest_AssertCheck(count == 1, "Check result value, expected: 1, got: %d", count); + + EnableTestLog(&count); + SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_DEBUG, "test"); + DisableTestLog(); + SDLTest_AssertPass("SDL_LogMessage(SDL_LOG_CATEGORY_CUSTOM, SDL_LOG_PRIORITY_DEBUG, \"test\")"); + SDLTest_AssertCheck(count == 0, "Check result value, expected: 0, got: %d", count); + + } + + return TEST_COMPLETED; +} + +/* ================= Test References ================== */ + +/* Log test cases */ +static const SDLTest_TestCaseReference logTestHint = { + (SDLTest_TestCaseFp)log_testHint, "log_testHint", "Check SDL_HINT_LOGGING functionality", TEST_ENABLED +}; + +/* Sequence of Log test cases */ +static const SDLTest_TestCaseReference *logTests[] = { + &logTestHint, NULL +}; + +/* Timer test suite (global) */ +SDLTest_TestSuiteReference logTestSuite = { + "Log", + NULL, + logTests, + NULL +}; diff --git a/vs/sdl2/test/testautomation_main.c b/vs/sdl2/test/testautomation_main.c index ed72e0d950..78572d1a43 100644 --- a/vs/sdl2/test/testautomation_main.c +++ b/vs/sdl2/test/testautomation_main.c @@ -9,34 +9,6 @@ #include "SDL.h" #include "SDL_test.h" -/* ! - * \brief Tests SDL_Init() and SDL_Quit() of Joystick and Haptic subsystems - * \sa - * http://wiki.libsdl.org/SDL_Init - * http://wiki.libsdl.org/SDL_Quit - */ -static int main_testInitQuitJoystickHaptic(void *arg) -{ -#if defined SDL_JOYSTICK_DISABLED || defined SDL_HAPTIC_DISABLED - return TEST_SKIPPED; -#else - int enabled_subsystems; - int initialized_subsystems = SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC; - - SDLTest_AssertCheck(SDL_Init(initialized_subsystems) == 0, "SDL_Init multiple systems."); - - enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck(enabled_subsystems == initialized_subsystems, "SDL_WasInit(SDL_INIT_EVERYTHING) contains all systems (%i)", enabled_subsystems); - - SDL_Quit(); - - enabled_subsystems = SDL_WasInit(initialized_subsystems); - SDLTest_AssertCheck(enabled_subsystems == 0, "SDL_Quit should shut down everything (%i)", enabled_subsystems); - - return TEST_COMPLETED; -#endif -} - /* ! * \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem() * \sa @@ -154,22 +126,18 @@ main_testSetError(void *arg) #endif static const SDLTest_TestCaseReference mainTest1 = { - (SDLTest_TestCaseFp)main_testInitQuitJoystickHaptic, "main_testInitQuitJoystickHaptic", "Tests SDL_Init/Quit of Joystick and Haptic subsystem", TEST_ENABLED -}; - -static const SDLTest_TestCaseReference mainTest2 = { (SDLTest_TestCaseFp)main_testInitQuitSubSystem, "main_testInitQuitSubSystem", "Tests SDL_InitSubSystem/QuitSubSystem", TEST_ENABLED }; -static const SDLTest_TestCaseReference mainTest3 = { +static const SDLTest_TestCaseReference mainTest2 = { (SDLTest_TestCaseFp)main_testImpliedJoystickInit, "main_testImpliedJoystickInit", "Tests that init for gamecontroller properly implies joystick", TEST_ENABLED }; -static const SDLTest_TestCaseReference mainTest4 = { +static const SDLTest_TestCaseReference mainTest3 = { (SDLTest_TestCaseFp)main_testImpliedJoystickQuit, "main_testImpliedJoystickQuit", "Tests that quit for gamecontroller doesn't quit joystick if you inited it explicitly", TEST_ENABLED }; -static const SDLTest_TestCaseReference mainTest5 = { +static const SDLTest_TestCaseReference mainTest4 = { (SDLTest_TestCaseFp)main_testSetError, "main_testSetError", "Tests that SDL_SetError() handles arbitrarily large strings", TEST_ENABLED }; @@ -179,7 +147,6 @@ static const SDLTest_TestCaseReference *mainTests[] = { &mainTest2, &mainTest3, &mainTest4, - &mainTest5, NULL }; @@ -190,5 +157,3 @@ SDLTest_TestSuiteReference mainTestSuite = { mainTests, NULL }; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/test/testautomation_math.c b/vs/sdl2/test/testautomation_math.c index 87637c01db..314d8ba7fd 100644 --- a/vs/sdl2/test/testautomation_math.c +++ b/vs/sdl2/test/testautomation_math.c @@ -49,6 +49,12 @@ typedef struct double expected; } dd_to_d; +#define DD_TO_D_CASE(IDX, X, Y, E) do { \ + cases[IDX].x_input = (X); \ + cases[IDX].y_input = (Y); \ + cases[IDX].expected = (E); \ + } while (0) + /* NB: You cannot create an array of these structures containing INFINITY or NAN. On platforms such as OS/2, they are defined as 'extern const double' making them @@ -64,10 +70,10 @@ typedef double(SDLCALL *dd_to_d_func)(double, double); * \brief Runs all the cases on a given function with a signature double -> double. * The result is expected to be exact. * - * \param func_name, a printable name for the tested function. - * \param func, the function to call. - * \param cases, an array of all the cases. - * \param cases_size, the size of the cases array. + * \param func_name a printable name for the tested function. + * \param func the function to call. + * \param cases an array of all the cases. + * \param cases_size the size of the cases array. */ static int helper_dtod(const char *func_name, d_to_d_func func, @@ -76,7 +82,7 @@ helper_dtod(const char *func_name, d_to_d_func func, Uint32 i; for (i = 0; i < cases_size; i++) { const double result = func(cases[i].input); - SDLTest_AssertCheck(result == cases[i].expected, + SDLTest_AssertCheck(SDL_fabs(result - cases[i].expected) < FLT_EPSILON, "%s(%f), expected %f, got %f", func_name, cases[i].input, @@ -90,10 +96,10 @@ helper_dtod(const char *func_name, d_to_d_func func, * \brief Runs all the cases on a given function with a signature double -> double. * Checks if the result between expected +/- EPSILON. * - * \param func_name, a printable name for the tested function. - * \param func, the function to call. - * \param cases, an array of all the cases. - * \param cases_size, the size of the cases array. + * \param func_name a printable name for the tested function. + * \param func the function to call. + * \param cases an array of all the cases. + * \param cases_size the size of the cases array. */ static int helper_dtod_inexact(const char *func_name, d_to_d_func func, @@ -102,13 +108,19 @@ helper_dtod_inexact(const char *func_name, d_to_d_func func, Uint32 i; for (i = 0; i < cases_size; i++) { const double result = func(cases[i].input); - SDLTest_AssertCheck(result >= cases[i].expected - EPSILON && - result <= cases[i].expected + EPSILON, - "%s(%f), expected [%f,%f], got %f", + double diff = result - cases[i].expected; + double max_err = (cases[i].expected + 1.) * EPSILON; + if (diff < 0) { + diff = -diff; + } + if (max_err < 0) { + max_err = -max_err; + } + SDLTest_AssertCheck(diff <= max_err, + "%s(%f), expected %f +/- %g, got %f", func_name, cases[i].input, - cases[i].expected - EPSILON, - cases[i].expected + EPSILON, + cases[i].expected, max_err, result); } @@ -119,10 +131,10 @@ helper_dtod_inexact(const char *func_name, d_to_d_func func, * \brief Runs all the cases on a given function with a signature * (double, double) -> double. The result is expected to be exact. * - * \param func_name, a printable name for the tested function. - * \param func, the function to call. - * \param cases, an array of all the cases. - * \param cases_size, the size of the cases array. + * \param func_name a printable name for the tested function. + * \param func the function to call. + * \param cases an array of all the cases. + * \param cases_size the size of the cases array. */ static int helper_ddtod(const char *func_name, dd_to_d_func func, @@ -131,6 +143,8 @@ helper_ddtod(const char *func_name, dd_to_d_func func, Uint32 i; for (i = 0; i < cases_size; i++) { const double result = func(cases[i].x_input, cases[i].y_input); + /* By using the result as input, the compiler is less likely to use higher precision floating point number */ + (void)SDL_sin(result); SDLTest_AssertCheck(result == cases[i].expected, "%s(%f,%f), expected %f, got %f", func_name, @@ -145,10 +159,10 @@ helper_ddtod(const char *func_name, dd_to_d_func func, * \brief Runs all the cases on a given function with a signature * (double, double) -> double. Checks if the result between expected +/- EPSILON. * - * \param func_name, a printable name for the tested function. - * \param func, the function to call. - * \param cases, an array of all the cases. - * \param cases_size, the size of the cases array. + * \param func_name a printable name for the tested function. + * \param func the function to call. + * \param cases an array of all the cases. + * \param cases_size the size of the cases array. */ static int helper_ddtod_inexact(const char *func_name, dd_to_d_func func, @@ -157,13 +171,20 @@ helper_ddtod_inexact(const char *func_name, dd_to_d_func func, Uint32 i; for (i = 0; i < cases_size; i++) { const double result = func(cases[i].x_input, cases[i].y_input); - SDLTest_AssertCheck(result >= cases[i].expected - EPSILON && - result <= cases[i].expected + EPSILON, - "%s(%f,%f), expected [%f,%f], got %f", + double diff = result - cases[i].expected; + double max_err = (cases[i].expected + 1.) * EPSILON; + if (diff < 0) { + diff = -diff; + } + if (max_err < 0) { + max_err = -max_err; + } + + SDLTest_AssertCheck(diff <= max_err, + "%s(%f,%f), expected %f +/- %g, got %f", func_name, cases[i].x_input, cases[i].y_input, - cases[i].expected - EPSILON, - cases[i].expected + EPSILON, + cases[i].expected, max_err, result); } @@ -176,8 +197,8 @@ helper_ddtod_inexact(const char *func_name, dd_to_d_func func, * This function is only meant to test functions that returns the input value if it is * integral: f(x) -> x for x in N. * - * \param func_name, a printable name for the tested function. - * \param func, the function to call. + * \param func_name a printable name for the tested function. + * \param func the function to call. */ static int helper_range(const char *func_name, d_to_d_func func) @@ -1091,7 +1112,7 @@ exp_regularCases(void *args) { 112.89, 10653788283588960962604279261058893737879589093376.0 }, { 539.483, 1970107755334319939701129934673541628417235942656909222826926175622435588279443011110464355295725187195188154768877850257012251677751742837992843520967922303961718983154427294786640886286983037548604937796221048661733679844353544028160.0 }, }; - return helper_dtod("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases)); + return helper_dtod_inexact("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases)); } /* SDL_log tests functions */ @@ -1138,7 +1159,7 @@ log_baseCases(void *args) 1.0, 0.0, result); result = SDL_log(EULER); - SDLTest_AssertCheck(1.0 == result, + SDLTest_AssertCheck(SDL_fabs(result - 1.) < FLT_EPSILON, "Log(%f), expected %f, got %f", EULER, 1.0, result); @@ -1646,14 +1667,16 @@ static int pow_regularCases(void *args) { const dd_to_d regular_cases[] = { +#if 0 /* These tests fail when using the Mingw C runtime, we'll disable them for now */ { -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 }, { -72.3, 12.0, 20401381050275984310272.0 }, +#endif { -5.0, 3.0, -125.0 }, { 3.0, 2.5, 15.58845726811989607085706666111946105957031250 }, { 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 }, { 478.972, 12.125, 315326359630449587856007411793920.0 } }; - return helper_ddtod("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases)); + return helper_ddtod_inexact("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases)); } /** @@ -1981,24 +2004,24 @@ static int cos_precisionTest(void *args) { const d_to_d precision_cases[] = { - { M_PI * 1.0 / 10.0, 0.9510565162 }, - { M_PI * 2.0 / 10.0, 0.8090169943 }, - { M_PI * 3.0 / 10.0, 0.5877852522 }, - { M_PI * 4.0 / 10.0, 0.3090169943 }, + { M_PI * 1.0 / 10.0, 0.9510565162951535 }, + { M_PI * 2.0 / 10.0, 0.8090169943749475 }, + { M_PI * 3.0 / 10.0, 0.5877852522924731 }, + { M_PI * 4.0 / 10.0, 0.30901699437494745 }, { M_PI * 5.0 / 10.0, 0.0 }, - { M_PI * 6.0 / 10.0, -0.3090169943 }, - { M_PI * 7.0 / 10.0, -0.5877852522 }, - { M_PI * 8.0 / 10.0, -0.8090169943 }, - { M_PI * 9.0 / 10.0, -0.9510565162 }, - { M_PI * -1.0 / 10.0, 0.9510565162 }, - { M_PI * -2.0 / 10.0, 0.8090169943 }, - { M_PI * -3.0 / 10.0, 0.5877852522 }, - { M_PI * -4.0 / 10.0, 0.3090169943 }, + { M_PI * 6.0 / 10.0, -0.30901699437494734 }, + { M_PI * 7.0 / 10.0, -0.587785252292473 }, + { M_PI * 8.0 / 10.0, -0.8090169943749473 }, + { M_PI * 9.0 / 10.0, -0.9510565162951535 }, + { M_PI * -1.0 / 10.0, 0.9510565162951535 }, + { M_PI * -2.0 / 10.0, 0.8090169943749475 }, + { M_PI * -3.0 / 10.0, 0.5877852522924731 }, + { M_PI * -4.0 / 10.0, 0.30901699437494745 }, { M_PI * -5.0 / 10.0, 0.0 }, - { M_PI * -6.0 / 10.0, -0.3090169943 }, - { M_PI * -7.0 / 10.0, -0.5877852522 }, - { M_PI * -8.0 / 10.0, -0.8090169943 }, - { M_PI * -9.0 / 10.0, -0.9510565162 } + { M_PI * -6.0 / 10.0, -0.30901699437494734 }, + { M_PI * -7.0 / 10.0, -0.587785252292473 }, + { M_PI * -8.0 / 10.0, -0.8090169943749473 }, + { M_PI * -9.0 / 10.0, -0.9510565162951535 } }; return helper_dtod_inexact("Cos", SDL_cos, precision_cases, SDL_arraysize(precision_cases)); } @@ -2099,23 +2122,23 @@ static int sin_precisionTest(void *args) { const d_to_d precision_cases[] = { - { M_PI * 1.0 / 10.0, 0.3090169943 }, - { M_PI * 2.0 / 10.0, 0.5877852522 }, - { M_PI * 3.0 / 10.0, 0.8090169943 }, - { M_PI * 4.0 / 10.0, 0.9510565162 }, - { M_PI * 6.0 / 10.0, 0.9510565162 }, - { M_PI * 7.0 / 10.0, 0.8090169943 }, - { M_PI * 8.0 / 10.0, 0.5877852522 }, - { M_PI * 9.0 / 10.0, 0.3090169943 }, + { M_PI * 1.0 / 10.0, 0.3090169943749474 }, + { M_PI * 2.0 / 10.0, 0.5877852522924731 }, + { M_PI * 3.0 / 10.0, 0.8090169943749475 }, + { M_PI * 4.0 / 10.0, 0.9510565162951535 }, + { M_PI * 6.0 / 10.0, 0.9510565162951536 }, + { M_PI * 7.0 / 10.0, 0.8090169943749475 }, + { M_PI * 8.0 / 10.0, 0.5877852522924732 }, + { M_PI * 9.0 / 10.0, 0.3090169943749475 }, { M_PI, 0.0 }, - { M_PI * -1.0 / 10.0, -0.3090169943 }, - { M_PI * -2.0 / 10.0, -0.5877852522 }, - { M_PI * -3.0 / 10.0, -0.8090169943 }, - { M_PI * -4.0 / 10.0, -0.9510565162 }, - { M_PI * -6.0 / 10.0, -0.9510565162 }, - { M_PI * -7.0 / 10.0, -0.8090169943 }, - { M_PI * -8.0 / 10.0, -0.5877852522 }, - { M_PI * -9.0 / 10.0, -0.3090169943 }, + { M_PI * -1.0 / 10.0, -0.3090169943749474 }, + { M_PI * -2.0 / 10.0, -0.5877852522924731 }, + { M_PI * -3.0 / 10.0, -0.8090169943749475 }, + { M_PI * -4.0 / 10.0, -0.9510565162951535 }, + { M_PI * -6.0 / 10.0, -0.9510565162951536 }, + { M_PI * -7.0 / 10.0, -0.8090169943749475 }, + { M_PI * -8.0 / 10.0, -0.5877852522924732 }, + { M_PI * -9.0 / 10.0, -0.3090169943749475 }, { -M_PI, 0.0 }, }; return helper_dtod_inexact("Sin", SDL_sin, precision_cases, SDL_arraysize(precision_cases)); @@ -2215,26 +2238,26 @@ static int tan_precisionTest(void *args) { const d_to_d precision_cases[] = { - { M_PI * 1.0 / 11.0, 0.2936264929 }, - { M_PI * 2.0 / 11.0, 0.6426609771 }, - { M_PI * 3.0 / 11.0, 1.1540615205 }, - { M_PI * 4.0 / 11.0, 2.1896945629 }, - { M_PI * 5.0 / 11.0, 6.9551527717 }, - { M_PI * 6.0 / 11.0, -6.9551527717 }, - { M_PI * 7.0 / 11.0, -2.1896945629 }, - { M_PI * 8.0 / 11.0, -1.1540615205 }, - { M_PI * 9.0 / 11.0, -0.6426609771 }, - { M_PI * 10.0 / 11.0, -0.2936264929 }, - { M_PI * -1.0 / 11.0, -0.2936264929 }, - { M_PI * -2.0 / 11.0, -0.6426609771 }, - { M_PI * -3.0 / 11.0, -1.1540615205 }, - { M_PI * -4.0 / 11.0, -2.1896945629 }, - { M_PI * -5.0 / 11.0, -6.9551527717 }, - { M_PI * -6.0 / 11.0, 6.9551527717 }, - { M_PI * -7.0 / 11.0, 2.1896945629 }, - { M_PI * -8.0 / 11.0, 1.1540615205 }, - { M_PI * -9.0 / 11.0, 0.6426609771 }, - { M_PI * -10.0 / 11.0, 0.2936264929 } + { M_PI * 1.0 / 11.0, 0.29362649293836673 }, + { M_PI * 2.0 / 11.0, 0.642660977168331 }, + { M_PI * 3.0 / 11.0, 1.1540615205330094 }, + { M_PI * 4.0 / 11.0, 2.189694562989681 }, + { M_PI * 5.0 / 11.0, 6.9551527717734745 }, + { M_PI * 6.0 / 11.0, -6.955152771773481 }, + { M_PI * 7.0 / 11.0, -2.189694562989682 }, + { M_PI * 8.0 / 11.0, -1.1540615205330096 }, + { M_PI * 9.0 / 11.0, -0.6426609771683314 }, + { M_PI * 10.0 / 11.0, -0.2936264929383667 }, + { M_PI * -1.0 / 11.0, -0.29362649293836673 }, + { M_PI * -2.0 / 11.0, -0.642660977168331 }, + { M_PI * -3.0 / 11.0, -1.1540615205330094 }, + { M_PI * -4.0 / 11.0, -2.189694562989681 }, + { M_PI * -5.0 / 11.0, -6.9551527717734745 }, + { M_PI * -6.0 / 11.0, 6.955152771773481 }, + { M_PI * -7.0 / 11.0, 2.189694562989682 }, + { M_PI * -8.0 / 11.0, 1.1540615205330096 }, + { M_PI * -9.0 / 11.0, 0.6426609771683314 }, + { M_PI * -10.0 / 11.0, 0.2936264929383667 } }; return helper_dtod_inexact("Tan", SDL_tan, precision_cases, SDL_arraysize(precision_cases)); } @@ -2256,7 +2279,7 @@ acos_limitCases(void *args) 1.0, 0.0, result); result = SDL_acos(-1.0); - SDLTest_AssertCheck(M_PI == result, + SDLTest_AssertCheck(SDL_fabs(M_PI - result) <= EPSILON, "Acos(%f), expected %f, got %f", -1.0, M_PI, result); @@ -2343,12 +2366,12 @@ asin_limitCases(void *args) double result; result = SDL_asin(1.0); - SDLTest_AssertCheck(M_PI / 2.0 == result, + SDLTest_AssertCheck(SDL_fabs(M_PI / 2.0 - result) <= EPSILON, "Asin(%f), expected %f, got %f", 1.0, M_PI / 2.0, result); result = SDL_asin(-1.0); - SDLTest_AssertCheck(-M_PI / 2.0 == result, + SDLTest_AssertCheck(SDL_fabs(-M_PI / 2.0 - result) <= EPSILON, "Asin(%f), expected %f, got %f", -1.0, -M_PI / 2.0, result); @@ -2399,26 +2422,26 @@ static int asin_precisionTest(void *args) { const d_to_d precision_cases[] = { - { 0.9, 1.1197695149 }, - { 0.8, 0.9272952180 }, - { 0.7, 0.7753974966 }, - { 0.6, 0.6435011087 }, - { 0.5, 0.5235987755 }, - { 0.4, 0.4115168460 }, - { 0.3, 0.3046926540 }, - { 0.2, 0.2013579207 }, - { 0.1, 0.1001674211 }, + { 0.9, 1.1197695149986342 }, + { 0.8, 0.9272952180016123 }, + { 0.7, 0.775397496610753 }, + { 0.6, 0.6435011087932844 }, + { 0.5, 0.5235987755982989 }, + { 0.4, 0.41151684606748806 }, + { 0.3, 0.3046926540153976 }, + { 0.2, 0.20135792079033074 }, + { 0.1, 0.10016742116155977 }, { 0.0, 0.0 }, { -0.0, -0.0 }, - { -0.1, -0.1001674211 }, - { -0.2, -0.2013579207 }, - { -0.3, -0.3046926540 }, - { -0.4, -0.4115168460 }, - { -0.5, -0.5235987755 }, - { -0.6, -0.6435011087 }, - { -0.7, -0.7753974966 }, - { -0.8, -0.9272952180 }, - { -0.9, -1.1197695149 } + { -0.1, -0.10016742116155977 }, + { -0.2, -0.20135792079033074 }, + { -0.3, -0.3046926540153976 }, + { -0.4, -0.41151684606748806 }, + { -0.5, -0.5235987755982989 }, + { -0.6, -0.6435011087932844 }, + { -0.7, -0.775397496610753 }, + { -0.8, -0.9272952180016123 }, + { -0.9, -1.1197695149986342 } }; return helper_dtod_inexact("Asin", SDL_asin, precision_cases, SDL_arraysize(precision_cases)); } @@ -2493,24 +2516,24 @@ static int atan_precisionTest(void *args) { const d_to_d precision_cases[] = { - { 6.313751514675041, 1.4137166941 }, - { 3.0776835371752527, 1.2566370614 }, - { 1.9626105055051504, 1.0995574287 }, - { 1.3763819204711734, 0.9424777960 }, - { 1.0, 0.7853981633 }, - { 0.7265425280053609, 0.6283185307 }, - { 0.5095254494944288, 0.4712388980 }, - { 0.3249196962329063, 0.3141592653 }, - { 0.15838444032453627, 0.1570796326 }, - { -0.15838444032453627, -0.1570796326 }, - { -0.3249196962329063, -0.3141592653 }, - { -0.5095254494944288, -0.4712388980 }, - { -0.7265425280053609, -0.6283185307 }, - { -1.0, -0.7853981633 }, - { -1.3763819204711734, -0.9424777960 }, - { -1.9626105055051504, -1.0995574287 }, - { -3.0776835371752527, -1.2566370614 }, - { -6.313751514675041, -1.4137166941 }, + { 6.313751514675041, 1.413716694115407 }, + { 3.0776835371752527, 1.2566370614359172 }, + { 1.9626105055051504, 1.0995574287564276 }, + { 1.3763819204711734, 0.9424777960769379 }, + { 1.0, 0.7853981633974483 }, + { 0.7265425280053609, 0.6283185307179586 }, + { 0.5095254494944288, 0.47123889803846897 }, + { 0.3249196962329063, 0.3141592653589793 }, + { 0.15838444032453627, 0.15707963267948966 }, + { -0.15838444032453627, -0.15707963267948966 }, + { -0.3249196962329063, -0.3141592653589793 }, + { -0.5095254494944288, -0.47123889803846897 }, + { -0.7265425280053609, -0.6283185307179586 }, + { -1.0, -0.7853981633974483 }, + { -1.3763819204711734, -0.9424777960769379 }, + { -1.9626105055051504, -1.0995574287564276 }, + { -3.0776835371752527, -1.2566370614359172 }, + { -6.313751514675041, -1.413716694115407 }, }; return helper_dtod_inexact("Atan", SDL_atan, precision_cases, SDL_arraysize(precision_cases)); } @@ -2535,7 +2558,7 @@ atan2_bothZeroCases(void *args) { 0.0, -0.0, M_PI }, { -0.0, -0.0, -M_PI }, }; - return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); + return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } /** @@ -2554,7 +2577,7 @@ atan2_yZeroCases(void *args) { -0.0, 1.0, -0.0 }, { -0.0, -1.0, -M_PI } }; - return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); + return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } /** @@ -2570,7 +2593,7 @@ atan2_xZeroCases(void *args) { 1.0, -0.0, M_PI / 2.0 }, { -1.0, -0.0, -M_PI / 2.0 } }; - return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); + return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); } /* Infinity cases */ @@ -2586,29 +2609,12 @@ atan2_xZeroCases(void *args) static int atan2_bothInfCases(void *args) { - double result; - - result = SDL_atan2(INFINITY, INFINITY); - SDLTest_AssertCheck(M_PI / 4.0 == result, - "Atan2(%f,%f), expected %f, got %f", - INFINITY, INFINITY, M_PI / 4.0, result); - - result = SDL_atan2(INFINITY, -INFINITY); - SDLTest_AssertCheck(3.0 * M_PI / 4.0 == result, - "Atan2(%f,%f), expected %f, got %f", - INFINITY, -INFINITY, 3.0 * M_PI / 4.0, result); - - result = SDL_atan2(-INFINITY, INFINITY); - SDLTest_AssertCheck(-M_PI / 4.0 == result, - "Atan2(%f,%f), expected %f, got %f", - -INFINITY, INFINITY, -M_PI / 4.0, result); - - result = SDL_atan2(-INFINITY, -INFINITY); - SDLTest_AssertCheck(-3.0 * M_PI / 4.0 == result, - "Atan2(%f,%f), expected %f, got %f", - -INFINITY, -INFINITY, -3.0 * M_PI / 4.0, result); - - return TEST_COMPLETED; + dd_to_d cases[4]; + DD_TO_D_CASE(0, INFINITY, INFINITY, 1.0 * M_PI / 4.0); + DD_TO_D_CASE(1, INFINITY, -INFINITY, 3.0 * M_PI / 4.0); + DD_TO_D_CASE(2, -INFINITY, INFINITY, -1.0 * M_PI / 4.0); + DD_TO_D_CASE(3, -INFINITY, -INFINITY, -3.0 * M_PI / 4.0); + return helper_ddtod("SDL_atan2(bothInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); } /** @@ -2618,29 +2624,12 @@ atan2_bothInfCases(void *args) static int atan2_yInfCases(void *args) { - double result; - - result = SDL_atan2(INFINITY, 1.0); - SDLTest_AssertCheck(M_PI / 2.0 == result, - "Atan2(%f,%f), expected %f, got %f", - INFINITY, 1.0, M_PI / 2.0, result); - - result = SDL_atan2(INFINITY, -1.0); - SDLTest_AssertCheck(M_PI / 2.0 == result, - "Atan2(%f,%f), expected %f, got %f", - INFINITY, -1.0, M_PI / 2.0, result); - - result = SDL_atan2(-INFINITY, 1.0); - SDLTest_AssertCheck(-M_PI / 2.0 == result, - "Atan2(%f,%f), expected %f, got %f", - -INFINITY, 1.0, -M_PI / 2.0, result); - - result = SDL_atan2(-INFINITY, -1.0); - SDLTest_AssertCheck(-M_PI / 2.0 == result, - "Atan2(%f,%f), expected %f, got %f", - -INFINITY, -1.0, -M_PI / 2.0, result); - - return TEST_COMPLETED; + dd_to_d cases[4]; + DD_TO_D_CASE(0, INFINITY, 1.0, 1.0 * M_PI / 2.0); + DD_TO_D_CASE(1, INFINITY, -1.0, 1.0 * M_PI / 2.0); + DD_TO_D_CASE(2, -INFINITY, 1.0, -1.0 * M_PI / 2.0); + DD_TO_D_CASE(3, -INFINITY, -1.0, -1.0 * M_PI / 2.0); + return helper_ddtod("SDL_atan2(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); } /** @@ -2652,29 +2641,12 @@ atan2_yInfCases(void *args) static int atan2_xInfCases(void *args) { - double result; - - result = SDL_atan2(1.0, INFINITY); - SDLTest_AssertCheck(0.0 == result, - "Atan2(%f,%f), expected %f, got %f", - 1.0, INFINITY, 0.0, result); - - result = SDL_atan2(-1.0, INFINITY); - SDLTest_AssertCheck(-0.0 == result, - "Atan2(%f,%f), expected %f, got %f", - -1.0, INFINITY, -0.0, result); - - result = SDL_atan2(1.0, -INFINITY); - SDLTest_AssertCheck(M_PI == result, - "Atan2(%f,%f), expected %f, got %f", - 1.0, -INFINITY, M_PI, result); - - result = SDL_atan2(-1.0, -INFINITY); - SDLTest_AssertCheck(-M_PI == result, - "Atan2(%f,%f), expected %f, got %f", - -1.0, -INFINITY, -M_PI, result); - - return TEST_COMPLETED; + dd_to_d cases[4]; + DD_TO_D_CASE(0, 1.0, INFINITY, 0.0); + DD_TO_D_CASE(1, -1.0, INFINITY, -0.0); + DD_TO_D_CASE(2, 1.0, -INFINITY, M_PI); + DD_TO_D_CASE(3, -1.0, -INFINITY, -M_PI); + return helper_ddtod("atan2_xInfCases(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); } /* Miscelanious cases */ diff --git a/vs/sdl2/test/testautomation_mouse.c b/vs/sdl2/test/testautomation_mouse.c index 22a4378018..19b1a9f58c 100644 --- a/vs/sdl2/test/testautomation_mouse.c +++ b/vs/sdl2/test/testautomation_mouse.c @@ -423,7 +423,7 @@ SDL_Window *_createMouseSuiteTestWindow() */ void _destroyMouseSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow()"); @@ -458,7 +458,7 @@ int mouse_warpMouseInWindow(void *arg) yPositions[5] = h + 1; /* Create test window */ window = _createMouseSuiteTestWindow(); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -503,6 +503,7 @@ int mouse_getMouseFocus(void *arg) int x, y; SDL_Window *window; SDL_Window *focusWindow; + const SDL_bool video_driver_is_wayland = !SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland"); /* Get focus - focus non-deterministic */ focusWindow = SDL_GetMouseFocus(); @@ -510,32 +511,37 @@ int mouse_getMouseFocus(void *arg) /* Create test window */ window = _createMouseSuiteTestWindow(); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } - /* Mouse to random position inside window */ - x = SDLTest_RandomIntegerInRange(1, w - 1); - y = SDLTest_RandomIntegerInRange(1, h - 1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); - - /* Pump events to update focus state */ - SDL_Delay(100); - SDL_PumpEvents(); - SDLTest_AssertPass("SDL_PumpEvents()"); - - /* Get focus with explicit window setup - focus deterministic */ - focusWindow = SDL_GetMouseFocus(); - SDLTest_AssertPass("SDL_GetMouseFocus()"); - SDLTest_AssertCheck(focusWindow != NULL, "Check returned window value is not NULL"); - SDLTest_AssertCheck(focusWindow == window, "Check returned window value is test window"); - - /* Mouse to random position outside window */ - x = SDLTest_RandomIntegerInRange(-9, -1); - y = SDLTest_RandomIntegerInRange(-9, -1); - SDL_WarpMouseInWindow(window, x, y); - SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); + /* Wayland explicitly disallows warping the mouse pointer, so this test must be skipped. */ + if (!video_driver_is_wayland) { + /* Mouse to random position inside window */ + x = SDLTest_RandomIntegerInRange(1, w - 1); + y = SDLTest_RandomIntegerInRange(1, h - 1); + SDL_WarpMouseInWindow(window, x, y); + SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); + + /* Pump events to update focus state */ + SDL_Delay(100); + SDL_PumpEvents(); + SDLTest_AssertPass("SDL_PumpEvents()"); + + /* Get focus with explicit window setup - focus deterministic */ + focusWindow = SDL_GetMouseFocus(); + SDLTest_AssertPass("SDL_GetMouseFocus()"); + SDLTest_AssertCheck(focusWindow != NULL, "Check returned window value is not NULL"); + SDLTest_AssertCheck(focusWindow == window, "Check returned window value is test window"); + + /* Mouse to random position outside window */ + x = SDLTest_RandomIntegerInRange(-9, -1); + y = SDLTest_RandomIntegerInRange(-9, -1); + SDL_WarpMouseInWindow(window, x, y); + SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%i,%i)", x, y); + } else { + SDLTest_Log("Skipping mouse warp focus tests: Wayland does not support warping the mouse pointer"); + } /* Clean up test window */ _destroyMouseSuiteTestWindow(window); diff --git a/vs/sdl2/test/testautomation_pixels.c b/vs/sdl2/test/testautomation_pixels.c index 3b806d6055..12cf632490 100644 --- a/vs/sdl2/test/testautomation_pixels.c +++ b/vs/sdl2/test/testautomation_pixels.c @@ -14,6 +14,8 @@ const int _numRGBPixelFormats = 31; Uint32 _RGBPixelFormats[] = { SDL_PIXELFORMAT_INDEX1LSB, SDL_PIXELFORMAT_INDEX1MSB, + SDL_PIXELFORMAT_INDEX2LSB, + SDL_PIXELFORMAT_INDEX2MSB, SDL_PIXELFORMAT_INDEX4LSB, SDL_PIXELFORMAT_INDEX4MSB, SDL_PIXELFORMAT_INDEX8, @@ -47,6 +49,8 @@ Uint32 _RGBPixelFormats[] = { const char *_RGBPixelFormatsVerbose[] = { "SDL_PIXELFORMAT_INDEX1LSB", "SDL_PIXELFORMAT_INDEX1MSB", + "SDL_PIXELFORMAT_INDEX2LSB", + "SDL_PIXELFORMAT_INDEX2MSB", "SDL_PIXELFORMAT_INDEX4LSB", "SDL_PIXELFORMAT_INDEX4MSB", "SDL_PIXELFORMAT_INDEX8", @@ -102,8 +106,8 @@ const char *_nonRGBPixelFormatsVerbose[] = { /* Definition of some invalid formats for negative tests */ const int _numInvalidPixelFormats = 2; Uint32 _invalidPixelFormats[] = { - 0xfffffffe, - 0xffffffff + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1010102 + 1, 32, 4), + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ABGR, SDL_PACKEDLAYOUT_1010102 + 2, 32, 4) }; const char *_invalidPixelFormatsVerbose[] = { "SDL_PIXELFORMAT_UNKNOWN", @@ -121,7 +125,6 @@ const char *_invalidPixelFormatsVerbose[] = { int pixels_allocFreeFormat(void *arg) { const char *unknownFormat = "SDL_PIXELFORMAT_UNKNOWN"; - const char *expectedError = "Parameter 'format' is invalid"; const char *error; int i; Uint32 format; @@ -172,6 +175,7 @@ int pixels_allocFreeFormat(void *arg) } } +#if 0 /* This succeeds for SDL3, but we don't expect SDL2 applications to call SDL_AllocFormat() for FOURCC formats directly */ /* Non-RGB formats */ for (i = 0; i < _numNonRGBPixelFormats; i++) { format = _nonRGBPixelFormats[i]; @@ -182,6 +186,7 @@ int pixels_allocFreeFormat(void *arg) SDLTest_AssertPass("Call to SDL_AllocFormat()"); SDLTest_AssertCheck(result == NULL, "Verify result is NULL"); } +#endif /* Negative cases */ @@ -196,23 +201,6 @@ int pixels_allocFreeFormat(void *arg) error = SDL_GetError(); SDLTest_AssertPass("Call to SDL_GetError()"); SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); - } - } - - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreeFormat(NULL); - SDLTest_AssertPass("Call to SDL_FreeFormat(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError, error); } return TEST_COMPLETED; @@ -310,7 +298,6 @@ int pixels_getPixelFormatName(void *arg) int pixels_allocFreePalette(void *arg) { const char *expectedError1 = "Parameter 'ncolors' is invalid"; - const char *expectedError2 = "Parameter 'palette' is invalid"; const char *error; int variation; int i; @@ -375,19 +362,6 @@ int pixels_allocFreePalette(void *arg) } } - /* Invalid free pointer */ - SDL_ClearError(); - SDLTest_AssertPass("Call to SDL_ClearError()"); - SDL_FreePalette(NULL); - SDLTest_AssertPass("Call to SDL_FreePalette(NULL)"); - error = SDL_GetError(); - SDLTest_AssertPass("Call to SDL_GetError()"); - SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL"); - if (error != NULL) { - SDLTest_AssertCheck(SDL_strcmp(error, expectedError2) == 0, - "Validate error message, expected: '%s', got: '%s'", expectedError2, error); - } - return TEST_COMPLETED; } diff --git a/vs/sdl2/test/testautomation_platform.c b/vs/sdl2/test/testautomation_platform.c index ac85eef23a..bd2aabed68 100644 --- a/vs/sdl2/test/testautomation_platform.c +++ b/vs/sdl2/test/testautomation_platform.c @@ -386,7 +386,7 @@ int platform_testSetErrorEmptyInput(void *arg) int platform_testSetErrorInvalidInput(void *arg) { int result; - const char *invalidError = NULL; + const char *invalidError = ""; const char *probeError = "Testing"; char *lastError; size_t len; diff --git a/vs/sdl2/test/testautomation_render.c b/vs/sdl2/test/testautomation_render.c index 74b9631460..45198a826e 100644 --- a/vs/sdl2/test/testautomation_render.c +++ b/vs/sdl2/test/testautomation_render.c @@ -43,6 +43,7 @@ static int _isSupported(int code); void InitCreateRenderer(void *arg) { int posX = 100, posY = 100, width = 320, height = 240; + int renderer_flags = SDL_RENDERER_ACCELERATED; renderer = NULL; window = SDL_CreateWindow("render_testCreateRenderer", posX, posY, width, height, 0); SDLTest_AssertPass("SDL_CreateWindow()"); @@ -51,7 +52,11 @@ void InitCreateRenderer(void *arg) return; } - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) { + renderer_flags = 0; + } + + renderer = SDL_CreateRenderer(window, -1, renderer_flags); SDLTest_AssertPass("SDL_CreateRenderer()"); SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result"); if (renderer == NULL) { @@ -65,13 +70,13 @@ void InitCreateRenderer(void *arg) */ void CleanupDestroyRenderer(void *arg) { - if (renderer != NULL) { + if (renderer) { SDL_DestroyRenderer(renderer); renderer = NULL; SDLTest_AssertPass("SDL_DestroyRenderer()"); } - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow"); @@ -938,12 +943,12 @@ _loadTestFace(void) SDL_Texture *tface; face = SDLTest_ImageFace(); - if (face == NULL) { + if (!face) { return NULL; } tface = SDL_CreateTextureFromSurface(renderer, face); - if (tface == NULL) { + if (!tface) { SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError()); } @@ -970,7 +975,7 @@ _hasTexColor(void) /* Get test face. */ tface = _loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } @@ -1014,7 +1019,7 @@ _hasTexAlpha(void) /* Get test face. */ tface = _loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } @@ -1043,7 +1048,7 @@ _hasTexAlpha(void) /** * @brief Compares screen pixels with image pixels. Helper function. * - * @param s Image to compare against. + * @param referenceSurface Image to compare against. * * \sa * http://wiki.libsdl.org/SDL_RenderReadPixels diff --git a/vs/sdl2/test/testautomation_stdlib.c b/vs/sdl2/test/testautomation_stdlib.c index ba7ba88f71..ed9f13ea35 100644 --- a/vs/sdl2/test/testautomation_stdlib.c +++ b/vs/sdl2/test/testautomation_stdlib.c @@ -53,7 +53,7 @@ int stdlib_snprintf(void *arg) int result; int predicted; char text[1024]; - const char *expected; + const char *expected, *expected2, *expected3, *expected4, *expected5; size_t size; result = SDL_snprintf(text, sizeof(text), "%s", "foo"); @@ -175,6 +175,61 @@ int stdlib_snprintf(void *arg) SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text); SDLTest_AssertCheck(result == 7, "Check result value, expected: 7, got: %d", result); + result = SDL_snprintf(text, sizeof(text), "%p", (void *)0x1234abcd); + expected = "0x1234abcd"; + expected2 = "1234ABCD"; + expected3 = "000000001234ABCD"; + expected4 = "1234abcd"; + expected5 = "000000001234abcd"; + SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1234abcd)"); + SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 || + SDL_strcmp(text, expected2) == 0 || + SDL_strcmp(text, expected3) == 0 || + SDL_strcmp(text, expected4) == 0 || + SDL_strcmp(text, expected5) == 0, + "Check text, expected: '%s', got: '%s'", expected, text); + SDLTest_AssertCheck(result == SDL_strlen(expected) || + result == SDL_strlen(expected2) || + result == SDL_strlen(expected3) || + result == SDL_strlen(expected4) || + result == SDL_strlen(expected5), + "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result); + + result = SDL_snprintf(text, sizeof(text), "A %p B", (void *)0x1234abcd); + expected = "A 0x1234abcd B"; + expected2 = "A 1234ABCD B"; + expected3 = "A 000000001234ABCD B"; + expected4 = "A 1234abcd B"; + expected5 = "A 000000001234abcd B"; + SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"A %%p B\", 0x1234abcd)"); + SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 || + SDL_strcmp(text, expected2) == 0 || + SDL_strcmp(text, expected3) == 0 || + SDL_strcmp(text, expected4) == 0 || + SDL_strcmp(text, expected5) == 0, + "Check text, expected: '%s', got: '%s'", expected, text); + SDLTest_AssertCheck(result == SDL_strlen(expected) || + result == SDL_strlen(expected2) || + result == SDL_strlen(expected3) || + result == SDL_strlen(expected4) || + result == SDL_strlen(expected5), + "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result); + + if (sizeof(void *) >= 8) { + result = SDL_snprintf(text, sizeof(text), "%p", (void *)0x1ba07bddf60L); + expected = "0x1ba07bddf60"; + expected2 = "000001BA07BDDF60"; + expected3 = "000001ba07bddf60"; + SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1ba07bddf60)"); + SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0 || + SDL_strcmp(text, expected2) == 0 || + SDL_strcmp(text, expected3) == 0, + "Check text, expected: '%s', got: '%s'", expected, text); + SDLTest_AssertCheck(result == SDL_strlen(expected) || + result == SDL_strlen(expected2) || + result == SDL_strlen(expected3), + "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result); + } return TEST_COMPLETED; } @@ -207,10 +262,10 @@ int stdlib_getsetenv(void *arg) text = SDL_getenv(name); SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - if (text != NULL) { + if (text) { SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, (int)SDL_strlen(text)); } - } while (text != NULL); + } while (text); /* Create random values to set */ value1 = SDLTest_RandomAsciiStringOfSize(10); @@ -339,7 +394,7 @@ int stdlib_sscanf(void *arg) long long_output, expected_long_output; long long long_long_output, expected_long_long_output; size_t size_output, expected_size_output; - char text[128]; + char text[128], text2[128]; expected_output = output = 123; expected_result = -1; @@ -403,6 +458,82 @@ int stdlib_sscanf(void *arg) SDLTest_AssertCheck(expected_size_output == size_output, "Check output, expected: %zu, got: %zu", expected_size_output, size_output); SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc def", "%s", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%s\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%s", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%s\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc,def") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[cba]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[cba]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[a-z]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[z-a]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[^,]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[^,]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 0; + text[0] = '\0'; + result = SDL_sscanf("abc,def", "%[A-Z]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[A-Z]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "") == 0, "Check output, expected: \"\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc,def", "%[abc],%[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc],%%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc,def", "%[abc]%*[,]%[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc,def\", \"%%[abc]%%*[,]%%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 2; + text[0] = '\0'; + text2[0] = '\0'; + result = SDL_sscanf("abc def", "%[abc] %[def]", text, text2); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc def\", \"%%[abc] %%[def]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc") == 0, "Check output, expected: \"abc\", got: \"%s\"", text); + SDLTest_AssertCheck(SDL_strcmp(text2, "def") == 0, "Check output, expected: \"def\", got: \"%s\"", text2); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + + expected_result = 1; + text[0] = '\0'; + result = SDL_sscanf("abc123XYZ", "%[a-zA-Z0-9]", text); + SDLTest_AssertPass("Call to SDL_sscanf(\"abc123XYZ\", \"%%[a-zA-Z0-9]\", text)"); + SDLTest_AssertCheck(SDL_strcmp(text, "abc123XYZ") == 0, "Check output, expected: \"abc123XYZ\", got: \"%s\"", text); + SDLTest_AssertCheck(expected_result == result, "Check return value, expected: %i, got: %i", expected_result, result); + return TEST_COMPLETED; } diff --git a/vs/sdl2/test/testautomation_subsystems.c b/vs/sdl2/test/testautomation_subsystems.c new file mode 100644 index 0000000000..d25edeeb7c --- /dev/null +++ b/vs/sdl2/test/testautomation_subsystems.c @@ -0,0 +1,239 @@ +/** + * Subsystem test suite + */ + +#include "SDL.h" +#include "SDL_test.h" + +/* ================= Test Case Implementation ================== */ + +/* Fixture */ + +static void subsystemsSetUp(void *arg) +{ + /* Reset each one of the SDL subsystems */ + /* CHECKME: can we use SDL_Quit here, or this will break the flow of tests? */ + SDL_Quit(); + /* Alternate variant without SDL_Quit: + while (SDL_WasInit(SDL_INIT_EVERYTHING) != 0) { + SDL_QuitSubSystem(SDL_INIT_EVERYTHING); + } + */ + SDLTest_AssertPass("Reset all subsystems before subsystems test"); + SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_EVERYTHING) == 0, "Check result from SDL_WasInit(SDL_INIT_EVERYTHING)"); +} + +static void subsystemsTearDown(void *arg) +{ + /* Reset each one of the SDL subsystems */ + SDL_Quit(); + + SDLTest_AssertPass("Cleanup of subsystems test completed"); +} + +/* Test case functions */ + +/** + * \brief Inits and Quits particular subsystem, checking its Init status. + * + * \sa SDL_InitSubSystem + * \sa SDL_QuitSubSystem + * + */ +static int subsystems_referenceCount() +{ + const int system = SDL_INIT_VIDEO; + int result; + /* Ensure that we start with a non-initialized subsystem. */ + SDLTest_AssertCheck(SDL_WasInit(system) == 0, "Check result from SDL_WasInit(0x%x)", system); + + /* Init subsystem once, and quit once */ + SDL_InitSubSystem(system); + SDLTest_AssertPass("Call to SDL_InitSubSystem(0x%x)", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == system, "Check result from SDL_WasInit(0x%x), expected: 0x%x, got: 0x%x", system, system, result); + + SDL_QuitSubSystem(system); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(0x%x)", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == 0, "Check result from SDL_WasInit(0x%x), expected: 0, got: 0x%x", system, result); + + /* Init subsystem number of times, then decrement reference count until it's disposed of. */ + SDL_InitSubSystem(system); + SDL_InitSubSystem(system); + SDL_InitSubSystem(system); + SDLTest_AssertPass("Call to SDL_InitSubSystem(0x%x) x3 times", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == system, "Check result from SDL_WasInit(0x%x), expected: 0x%x, got: 0x%x", system, system, result); + + SDL_QuitSubSystem(system); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(0x%x) x1", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == system, "Check result from SDL_WasInit(0x%x), expected: 0x%x, got: 0x%x", system, system, result); + SDL_QuitSubSystem(system); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(0x%x) x2", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == system, "Check result from SDL_WasInit(0x%x), expected: 0x%x, got: 0x%x", system, system, result); + SDL_QuitSubSystem(system); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(0x%x) x3", system); + result = SDL_WasInit(system); + SDLTest_AssertCheck(result == 0, "Check result from SDL_WasInit(0x%x), expected: 0, got: 0x%x", system, result); + + return TEST_COMPLETED; +} + +/** + * \brief Inits and Quits subsystems that have another as dependency; + * check that the dependency is not removed before the last of its dependents. + * + * \sa SDL_InitSubSystem + * \sa SDL_QuitSubSystem + * + */ +static int subsystems_dependRefCountInitAllQuitByOne() +{ + int result; + /* Ensure that we start with reset subsystems. */ + SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0, + "Check result from SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)"); + + /* Following should init SDL_INIT_EVENTS and give it +3 ref counts. */ + SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + + /* Quit systems one by one. */ + SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_VIDEO)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_JOYSTICK)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == 0, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0, got: 0x%x", result); + + return TEST_COMPLETED; +} + +/** + * \brief Inits and Quits subsystems that have another as dependency; + * check that the dependency is not removed before the last of its dependents. + * + * \sa SDL_InitSubSystem + * \sa SDL_QuitSubSystem + * + */ +static int subsystems_dependRefCountInitByOneQuitAll() +{ + int result; + /* Ensure that we start with reset subsystems. */ + SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0, + "Check result from SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)"); + + /* Following should init SDL_INIT_EVENTS and give it +3 ref counts. */ + SDL_InitSubSystem(SDL_INIT_VIDEO); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_VIDEO)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + SDL_InitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_JOYSTICK)"); + + /* Quit systems all at once. */ + SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == 0, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0, got: 0x%x", result); + + return TEST_COMPLETED; +} + +/** + * \brief Inits and Quits subsystems that have another as dependency, + * but also inits that dependency explicitly, giving it extra ref count. + * Check that the dependency is not removed before the last reference is gone. + * + * \sa SDL_InitSubSystem + * \sa SDL_QuitSubSystem + * + */ +static int subsystems_dependRefCountWithExtraInit() +{ + int result; + /* Ensure that we start with reset subsystems. */ + SDLTest_AssertCheck(SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS) == 0, + "Check result from SDL_WasInit(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_EVENTS)"); + + /* Init EVENTS explicitly, +1 ref count. */ + SDL_InitSubSystem(SDL_INIT_EVENTS); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_EVENTS)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + /* Following should init SDL_INIT_EVENTS and give it +3 ref counts. */ + SDL_InitSubSystem(SDL_INIT_VIDEO); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_VIDEO)"); + SDL_InitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_AUDIO)"); + SDL_InitSubSystem(SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_InitSubSystem(SDL_INIT_JOYSTICK)"); + + /* Quit EVENTS explicitly, -1 ref count. */ + SDL_QuitSubSystem(SDL_INIT_EVENTS); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_EVENTS)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + + /* Quit systems one by one. */ + SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_VIDEO)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + SDL_QuitSubSystem(SDL_INIT_AUDIO); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == SDL_INIT_EVENTS, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0x4000, got: 0x%x", result); + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_JOYSTICK)"); + result = SDL_WasInit(SDL_INIT_EVENTS); + SDLTest_AssertCheck(result == 0, "Check result from SDL_WasInit(SDL_INIT_EVENTS), expected: 0, got: 0x%x", result); + + return TEST_COMPLETED; +} + +/* ================= Test References ================== */ + +/* Subsystems test cases */ +static const SDLTest_TestCaseReference subsystemsTest1 = { + (SDLTest_TestCaseFp)subsystems_referenceCount, "subsystems_referenceCount", "Makes sure that subsystem stays until number of quits matches inits.", TEST_ENABLED +}; + +static const SDLTest_TestCaseReference subsystemsTest2 = { + (SDLTest_TestCaseFp)subsystems_dependRefCountInitAllQuitByOne, "subsystems_dependRefCountInitAllQuitByOne", "Check reference count of subsystem dependencies.", TEST_ENABLED +}; + +static const SDLTest_TestCaseReference subsystemsTest3 = { + (SDLTest_TestCaseFp)subsystems_dependRefCountInitByOneQuitAll, "subsystems_dependRefCountInitByOneQuitAll", "Check reference count of subsystem dependencies.", TEST_ENABLED +}; + +static const SDLTest_TestCaseReference subsystemsTest4 = { + (SDLTest_TestCaseFp)subsystems_dependRefCountWithExtraInit, "subsystems_dependRefCountWithExtraInit", "Check reference count of subsystem dependencies.", TEST_ENABLED +}; + +/* Sequence of Events test cases */ +static const SDLTest_TestCaseReference *subsystemsTests[] = { + &subsystemsTest1, &subsystemsTest2, &subsystemsTest3, &subsystemsTest4, NULL +}; + +/* Events test suite (global) */ +SDLTest_TestSuiteReference subsystemsTestSuite = { + "Subsystems", + subsystemsSetUp, + subsystemsTests, + subsystemsTearDown +}; diff --git a/vs/sdl2/test/testautomation_suites.h b/vs/sdl2/test/testautomation_suites.h index 6fdcd83889..95528f271f 100644 --- a/vs/sdl2/test/testautomation_suites.h +++ b/vs/sdl2/test/testautomation_suites.h @@ -16,6 +16,7 @@ extern SDLTest_TestSuiteReference guidTestSuite; extern SDLTest_TestSuiteReference hintsTestSuite; extern SDLTest_TestSuiteReference joystickTestSuite; extern SDLTest_TestSuiteReference keyboardTestSuite; +extern SDLTest_TestSuiteReference logTestSuite; extern SDLTest_TestSuiteReference mainTestSuite; extern SDLTest_TestSuiteReference mathTestSuite; extern SDLTest_TestSuiteReference mouseTestSuite; @@ -26,6 +27,7 @@ extern SDLTest_TestSuiteReference renderTestSuite; extern SDLTest_TestSuiteReference rwopsTestSuite; extern SDLTest_TestSuiteReference sdltestTestSuite; extern SDLTest_TestSuiteReference stdlibTestSuite; +extern SDLTest_TestSuiteReference subsystemsTestSuite; extern SDLTest_TestSuiteReference surfaceTestSuite; extern SDLTest_TestSuiteReference syswmTestSuite; extern SDLTest_TestSuiteReference timerTestSuite; @@ -40,6 +42,7 @@ SDLTest_TestSuiteReference *testSuites[] = { &hintsTestSuite, &joystickTestSuite, &keyboardTestSuite, + &logTestSuite, &mainTestSuite, &mathTestSuite, &mouseTestSuite, @@ -54,6 +57,7 @@ SDLTest_TestSuiteReference *testSuites[] = { &syswmTestSuite, &timerTestSuite, &videoTestSuite, + &subsystemsTestSuite, /* run last, not interfere with other test enviroment */ NULL }; diff --git a/vs/sdl2/test/testautomation_surface.c b/vs/sdl2/test/testautomation_surface.c index 41aa24142c..e86704a6b2 100644 --- a/vs/sdl2/test/testautomation_surface.c +++ b/vs/sdl2/test/testautomation_surface.c @@ -346,7 +346,9 @@ int surface_testCompleteSurfaceConversion(void *arg) SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGRA8888, +#if 0 /* We aren't testing HDR10 colorspace conversion */ SDL_PIXELFORMAT_ARGB2101010, +#endif }; SDL_Surface *face = NULL, *cvt1, *cvt2, *final; SDL_PixelFormat *fmt1, *fmt2; @@ -668,6 +670,34 @@ int surface_testOverflow(void *arg) surface != NULL ? "(success)" : SDL_GetError()); SDL_FreeSurface(surface); + /* SDL_PIXELFORMAT_INDEX2* needs 1 byte per 4 pixels. */ + surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 12, 1, 2, 3, SDL_PIXELFORMAT_INDEX2LSB); + SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s", + surface != NULL ? "(success)" : SDL_GetError()); + SDL_FreeSurface(surface); + surface = SDL_CreateRGBSurfaceFrom(buf, 12, 1, 2, 3, 0, 0, 0, 0); + SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s", + surface != NULL ? "(success)" : SDL_GetError()); + SDL_FreeSurface(surface); + + surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 13, 1, 2, 3, SDL_PIXELFORMAT_INDEX2LSB); + SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp (%d)", surface ? surface->pitch : 0); + SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, + "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); + surface = SDL_CreateRGBSurfaceFrom(buf, 13, 1, 2, 3, 0, 0, 0, 0); + SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp"); + SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, + "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); + + surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 13, 1, 2, 4, SDL_PIXELFORMAT_INDEX2LSB); + SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s", + surface != NULL ? "(success)" : SDL_GetError()); + SDL_FreeSurface(surface); + surface = SDL_CreateRGBSurfaceFrom(buf, 13, 1, 2, 4, 0, 0, 0, 0); + SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s", + surface != NULL ? "(success)" : SDL_GetError()); + SDL_FreeSurface(surface); + /* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */ surface = SDL_CreateRGBSurfaceWithFormatFrom(buf, 16, 1, 1, 2, SDL_PIXELFORMAT_INDEX1LSB); SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s", @@ -737,19 +767,26 @@ int surface_testOverflow(void *arg) "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); if (sizeof(size_t) == 4 && sizeof(int) >= 4) { + SDL_ClearError(); expectedError = "Out of memory"; - surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32, 1, 8, SDL_PIXELFORMAT_INDEX8); + /* 0x5555'5555 * 3bpp = 0xffff'ffff which fits in size_t, but adding + * alignment padding makes it overflow */ + surface = SDL_CreateRGBSurfaceWithFormat(0, 0x55555555, 1, 24, SDL_PIXELFORMAT_RGB24); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width + alignment"); SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); - surface = SDL_CreateRGBSurfaceWithFormat(0, SDL_MAX_SINT32 / 2, 1, 32, SDL_PIXELFORMAT_ARGB8888); + SDL_ClearError(); + /* 0x4000'0000 * 4bpp = 0x1'0000'0000 which (just) overflows */ + surface = SDL_CreateRGBSurfaceWithFormat(0, 0x40000000, 1, 32, SDL_PIXELFORMAT_ARGB8888); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * bytes per pixel"); SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); + SDL_ClearError(); surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 29) - 1, (1 << 29) - 1, 8, SDL_PIXELFORMAT_INDEX8); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height"); SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, "Expected \"%s\", got \"%s\"", expectedError, SDL_GetError()); + SDL_ClearError(); surface = SDL_CreateRGBSurfaceWithFormat(0, (1 << 15) + 1, (1 << 15) + 1, 32, SDL_PIXELFORMAT_ARGB8888); SDLTest_AssertCheck(surface == NULL, "Should detect overflow in width * height * bytes per pixel"); SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0, diff --git a/vs/sdl2/test/testautomation_timer.c b/vs/sdl2/test/testautomation_timer.c index 1002a36eba..a7160e76c0 100644 --- a/vs/sdl2/test/testautomation_timer.c +++ b/vs/sdl2/test/testautomation_timer.c @@ -94,7 +94,10 @@ int timer_delayAndGetTicks(void *arg) SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu32, result2); difference = result2 - result; SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay - marginOfError, difference); +#if 0 + /* Disabled because this might fail on non-interactive systems. Moved to testtimer. */ SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%" SDL_PRIu32 ", got: %" SDL_PRIu32, testDelay + marginOfError, difference); +#endif return TEST_COMPLETED; } diff --git a/vs/sdl2/test/testautomation_video.c b/vs/sdl2/test/testautomation_video.c index aa9e7b92b3..dd8f1c5c25 100644 --- a/vs/sdl2/test/testautomation_video.c +++ b/vs/sdl2/test/testautomation_video.c @@ -28,6 +28,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) SDL_Window *window; int x, y, w, h; SDL_WindowFlags flags; + SDL_bool needs_renderer = SDL_FALSE; /* Standard window */ x = SDLTest_RandomIntegerInRange(1, 100); @@ -40,6 +41,35 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,%d)", x, y, w, h, flags); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + /* Wayland and XWayland windows require that a frame be presented before they are fully mapped and visible onscreen. + * This is required for the mouse/keyboard grab tests to pass. + */ + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) { + needs_renderer = SDL_TRUE; + } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { + /* Try to detect if the x11 driver is running under XWayland */ + const char *session_type = SDL_getenv("XDG_SESSION_TYPE"); + if (session_type && SDL_strcasecmp(session_type, "wayland") == 0) { + needs_renderer = SDL_TRUE; + } + } + + if (needs_renderer) { + SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); + if (renderer) { + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + + /* Some desktops don't display the window immediately after presentation, + * so delay to give the window time to actually appear on the desktop. + */ + SDL_Delay(100); + } else { + SDLTest_Log("Unable to create a renderer, some tests may fail on Wayland/XWayland"); + } + } + return window; } @@ -48,7 +78,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) */ void _destroyVideoSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("Call to SDL_DestroyWindow()"); @@ -278,6 +308,8 @@ int video_createWindowVariousFlags(void *arg) break; case 2: flags = SDL_WINDOW_OPENGL; + /* Skip - not every video driver supports OpenGL; comment out next line to run test */ + continue; break; case 3: flags = SDL_WINDOW_SHOWN; @@ -576,7 +608,7 @@ int video_getWindowDisplayMode(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window != NULL) { + if (window) { result = SDL_GetWindowDisplayMode(window, &mode); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()"); SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); @@ -670,7 +702,7 @@ video_getWindowGammaRamp(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; + if (!window) return TEST_ABORTED; /* Retrieve no channel */ result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL); @@ -820,13 +852,33 @@ int video_getSetWindowGrab(void *arg) const char *title = "video_getSetWindowGrab Test Window"; SDL_Window *window; SDL_bool originalMouseState, originalKeyboardState; + SDL_bool hasFocusGained = SDL_FALSE; /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } + /* Need to raise the window to have and SDL_EVENT_WINDOW_FOCUS_GAINED, + * so that the window gets the flags SDL_WINDOW_INPUT_FOCUS, + * so that it can be "grabbed" */ + SDL_RaiseWindow(window); + + { + SDL_Event evt; + SDL_zero(evt); + while (SDL_PollEvent(&evt)) { + if (evt.type == SDL_WINDOWEVENT) { + if (evt.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) { + hasFocusGained = SDL_TRUE; + } + } + } + } + + SDLTest_AssertCheck(hasFocusGained == SDL_TRUE, "Expected window with focus"); + /* Get state */ originalMouseState = SDL_GetWindowMouseGrab(window); SDLTest_AssertPass("Call to SDL_GetWindowMouseGrab()"); @@ -967,7 +1019,7 @@ int video_getWindowId(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1022,7 +1074,7 @@ int video_getWindowPixelFormat(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1085,28 +1137,58 @@ int video_getSetWindowPosition(void *arg) { const char *title = "video_getSetWindowPosition Test Window"; SDL_Window *window; + int maxxVariation, maxyVariation; int xVariation, yVariation; int referenceX, referenceY; int currentX, currentY; int desiredX, desiredY; + SDL_Rect display_bounds; + + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0) { + SDLTest_Log("Skipping test: wayland does not support window positioning"); + return TEST_SKIPPED; + } /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } - for (xVariation = 0; xVariation < 4; xVariation++) { - for (yVariation = 0; yVariation < 4; yVariation++) { + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { + /* The X11 server allows arbitrary window placement, but compositing + * window managers such as GNOME and KDE force windows to be within + * desktop bounds. + */ + maxxVariation = 2; + maxyVariation = 2; + + SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(window), &display_bounds); + } else if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "cocoa") == 0) { + /* Platform doesn't allow windows with negative Y desktop bounds */ + maxxVariation = 4; + maxyVariation = 3; + + SDL_GetDisplayUsableBounds(SDL_GetWindowDisplayIndex(window), &display_bounds); + } else { + /* Platform allows windows to be placed out of bounds */ + maxxVariation = 4; + maxyVariation = 4; + + SDL_GetDisplayBounds(SDL_GetWindowDisplayIndex(window), &display_bounds); + } + + for (xVariation = 0; xVariation < maxxVariation; xVariation++) { + for (yVariation = 0; yVariation < maxyVariation; yVariation++) { switch (xVariation) { default: case 0: /* Zero X Position */ - desiredX = 0; + desiredX = display_bounds.x > 0 ? display_bounds.x : 0; break; case 1: /* Random X position inside screen */ - desiredX = SDLTest_RandomIntegerInRange(1, 100); + desiredX = SDLTest_RandomIntegerInRange(display_bounds.x + 1, display_bounds.x + 100); break; case 2: /* Random X position outside screen (positive) */ @@ -1121,15 +1203,15 @@ int video_getSetWindowPosition(void *arg) switch (yVariation) { default: case 0: - /* Zero X Position */ - desiredY = 0; + /* Zero Y Position */ + desiredY = display_bounds.y > 0 ? display_bounds.y : 0; break; case 1: - /* Random X position inside screen */ - desiredY = SDLTest_RandomIntegerInRange(1, 100); + /* Random Y position inside screen */ + desiredY = SDLTest_RandomIntegerInRange(display_bounds.y + 1, display_bounds.y + 100); break; case 2: - /* Random X position outside screen (positive) */ + /* Random Y position outside screen (positive) */ desiredY = SDLTest_RandomIntegerInRange(10000, 11000); break; case 3: @@ -1255,7 +1337,7 @@ int video_getSetWindowSize(void *arg) int desiredW, desiredH; /* Get display bounds for size range */ - result = SDL_GetDisplayBounds(0, &display); + result = SDL_GetDisplayUsableBounds(0, &display); SDLTest_AssertPass("SDL_GetDisplayBounds()"); SDLTest_AssertCheck(result == 0, "Verify return value; expected: 0, got: %d", result); if (result != 0) { @@ -1264,19 +1346,20 @@ int video_getSetWindowSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } -#ifdef __WIN32__ - /* Platform clips window size to screen size */ - maxwVariation = 4; - maxhVariation = 4; -#else - /* Platform allows window size >= screen size */ - maxwVariation = 5; - maxhVariation = 5; -#endif + if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "windows") == 0 || + SDL_strcmp(SDL_GetCurrentVideoDriver(), "x11") == 0) { + /* Platform clips window size to screen size */ + maxwVariation = 4; + maxhVariation = 4; + } else { + /* Platform allows window size >= screen size */ + maxwVariation = 5; + maxhVariation = 5; + } for (wVariation = 0; wVariation < maxwVariation; wVariation++) { for (hVariation = 0; hVariation < maxhVariation; hVariation++) { @@ -1355,7 +1438,6 @@ int video_getSetWindowSize(void *arg) } } - /* Get just width */ currentW = desiredW + 1; SDL_GetWindowSize(window, ¤tW, NULL); @@ -1447,7 +1529,7 @@ int video_getSetWindowMinimumSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1589,7 +1671,7 @@ int video_getSetWindowMaximumSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1727,30 +1809,30 @@ int video_getSetWindowData(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } /* Create testdata */ datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata == NULL) { + if (!referenceUserdata) { returnValue = TEST_ABORTED; goto cleanup; } userdata = SDL_strdup(referenceUserdata); - if (userdata == NULL) { + if (!userdata) { returnValue = TEST_ABORTED; goto cleanup; } datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata2 == NULL) { + if (!referenceUserdata2) { returnValue = TEST_ABORTED; goto cleanup; } userdata2 = SDL_strdup(referenceUserdata2); - if (userdata2 == NULL) { + if (!userdata2) { returnValue = TEST_ABORTED; goto cleanup; } @@ -1935,6 +2017,11 @@ int video_setWindowCenteredOnDisplay(void *arg) SDL_Rect display0, display1; displayNum = SDL_GetNumVideoDisplays(); + SDLTest_AssertPass("SDL_GetNumVideoDisplays()"); + SDLTest_AssertCheck(displayNum >= 1, "Validate result (current: %d, expected >= 1)", displayNum); + if (displayNum <= 0) { + return TEST_ABORTED; + } /* Get display bounds */ result = SDL_GetDisplayBounds(0 % displayNum, &display0); @@ -1959,6 +2046,7 @@ int video_setWindowCenteredOnDisplay(void *arg) int currentDisplay; int expectedDisplay; SDL_Rect expectedDisplayRect; + SDL_bool video_driver_is_wayland = SDL_strcmp(SDL_GetCurrentVideoDriver(), "wayland") == 0; /* xVariation is the display we start on */ expectedDisplay = xVariation % displayNum; @@ -1970,20 +2058,46 @@ int video_setWindowCenteredOnDisplay(void *arg) expectedX = (expectedDisplayRect.x + ((expectedDisplayRect.w - w) / 2)); expectedY = (expectedDisplayRect.y + ((expectedDisplayRect.h - h) / 2)); - window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); + window = SDL_CreateWindow(title, x, y, w, h, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI | SDL_WINDOW_BORDERLESS); SDLTest_AssertPass("Call to SDL_CreateWindow('Title',%d,%d,%d,%d,SHOWN)", x, y, w, h); SDLTest_AssertCheck(window != NULL, "Validate that returned window struct is not NULL"); + /* Wayland windows require that a frame be presented before they are fully mapped and visible onscreen. */ + if (video_driver_is_wayland) { + SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); + + if (renderer) { + SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); + SDL_RenderClear(renderer); + SDL_RenderPresent(renderer); + + /* Some desktops don't display the window immediately after presentation, + * so delay to give the window time to actually appear on the desktop. + */ + SDL_Delay(100); + } else { + SDLTest_Log("Unable to create a renderer, tests may fail under Wayland"); + } + } + /* Check the window is centered on the requested display */ currentDisplay = SDL_GetWindowDisplayIndex(window); SDL_GetWindowSize(window, ¤tW, ¤tH); SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + } else { + SDLTest_Log("Skipping display index validation: Wayland driver does not support window positioning"); + } SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); - SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); - SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); + SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + } else { + SDLTest_Log("Skipping window position validation: Wayland driver does not support window positioning"); + } /* Enter fullscreen desktop */ result = SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); @@ -1994,11 +2108,19 @@ int video_setWindowCenteredOnDisplay(void *arg) SDL_GetWindowSize(window, ¤tW, ¤tH); SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + } else { + SDLTest_Log("Skipping display index validation: Wayland driver does not support window positioning"); + } SDLTest_AssertCheck(currentW == expectedDisplayRect.w, "Validate width (current: %d, expected: %d)", currentW, expectedDisplayRect.w); SDLTest_AssertCheck(currentH == expectedDisplayRect.h, "Validate height (current: %d, expected: %d)", currentH, expectedDisplayRect.h); - SDLTest_AssertCheck(currentX == expectedDisplayRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedDisplayRect.x); - SDLTest_AssertCheck(currentY == expectedDisplayRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedDisplayRect.y); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentX == expectedDisplayRect.x, "Validate x (current: %d, expected: %d)", currentX, expectedDisplayRect.x); + SDLTest_AssertCheck(currentY == expectedDisplayRect.y, "Validate y (current: %d, expected: %d)", currentY, expectedDisplayRect.y); + } else { + SDLTest_Log("Skipping window position validation: Wayland driver does not support window positioning"); + } /* Leave fullscreen desktop */ result = SDL_SetWindowFullscreen(window, 0); @@ -2009,11 +2131,19 @@ int video_setWindowCenteredOnDisplay(void *arg) SDL_GetWindowSize(window, ¤tW, ¤tH); SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + } else { + SDLTest_Log("Skipping display index validation: Wayland driver does not support window positioning"); + } SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); - SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); - SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); + SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + } else { + SDLTest_Log("Skipping window position validation: Wayland driver does not support window positioning"); + } /* Center on display yVariation, and check window properties */ @@ -2029,11 +2159,19 @@ int video_setWindowCenteredOnDisplay(void *arg) SDL_GetWindowSize(window, ¤tW, ¤tH); SDL_GetWindowPosition(window, ¤tX, ¤tY); - SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentDisplay == expectedDisplay, "Validate display index (current: %d, expected: %d)", currentDisplay, expectedDisplay); + } else { + SDLTest_Log("Skipping display index validation: Wayland driver does not support window positioning"); + } SDLTest_AssertCheck(currentW == w, "Validate width (current: %d, expected: %d)", currentW, w); SDLTest_AssertCheck(currentH == h, "Validate height (current: %d, expected: %d)", currentH, h); - SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); - SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + if (!video_driver_is_wayland) { + SDLTest_AssertCheck(currentX == expectedX, "Validate x (current: %d, expected: %d)", currentX, expectedX); + SDLTest_AssertCheck(currentY == expectedY, "Validate y (current: %d, expected: %d)", currentY, expectedY); + } else { + SDLTest_Log("Skipping window position validation: Wayland driver does not support window positioning"); + } /* Clean up */ _destroyVideoSuiteTestWindow(window); diff --git a/vs/sdl2/test/testbounds.c b/vs/sdl2/test/testbounds.c index 42213f5464..9bd73ac962 100644 --- a/vs/sdl2/test/testbounds.c +++ b/vs/sdl2/test/testbounds.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testcustomcursor.c b/vs/sdl2/test/testcustomcursor.c index dc1c3718cc..aec3c78aa3 100644 --- a/vs/sdl2/test/testcustomcursor.c +++ b/vs/sdl2/test/testcustomcursor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -242,7 +242,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/vs/sdl2/test/testdisplayinfo.c b/vs/sdl2/test/testdisplayinfo.c index 66cc5d875a..9740ab1742 100644 --- a/vs/sdl2/test/testdisplayinfo.c +++ b/vs/sdl2/test/testdisplayinfo.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +20,7 @@ static void print_mode(const char *prefix, const SDL_DisplayMode *mode) { - if (mode == NULL) { + if (!mode) { return; } diff --git a/vs/sdl2/test/testdraw2.c b/vs/sdl2/test/testdraw2.c index f660c28458..43aa1843b1 100644 --- a/vs/sdl2/test/testdraw2.c +++ b/vs/sdl2/test/testdraw2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -227,7 +227,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/vs/sdl2/test/testdrawchessboard.c b/vs/sdl2/test/testdrawchessboard.c index 8ff21a4c4e..4dffe06bd7 100644 --- a/vs/sdl2/test/testdrawchessboard.c +++ b/vs/sdl2/test/testdrawchessboard.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,6 +50,7 @@ void DrawChessBoard() SDL_RenderFillRect(renderer, &rect); } } + SDL_RenderPresent(renderer); } void loop() @@ -106,13 +107,13 @@ int main(int argc, char *argv[]) /* Create window and renderer for given surface */ window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); return 1; } surface = SDL_GetWindowSurface(window); renderer = SDL_CreateSoftwareRenderer(surface); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError()); return 1; } diff --git a/vs/sdl2/test/testdropfile.c b/vs/sdl2/test/testdropfile.c index b806333656..2184f062ee 100644 --- a/vs/sdl2/test/testdropfile.c +++ b/vs/sdl2/test/testdropfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +35,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testerror.c b/vs/sdl2/test/testerror.c index f3f11b6617..25874d1ea7 100644 --- a/vs/sdl2/test/testerror.c +++ b/vs/sdl2/test/testerror.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +65,7 @@ int main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, NULL, "#1"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } diff --git a/vs/sdl2/test/testevdev.c b/vs/sdl2/test/testevdev.c index e615791587..67124ae0f4 100644 --- a/vs/sdl2/test/testevdev.c +++ b/vs/sdl2/test/testevdev.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright (C) 2020-2022 Collabora Ltd. This software is provided 'as-is', without any express or implied @@ -18,7 +18,7 @@ static int run_test(void); -#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX) +#if defined(HAVE_LIBUDEV_H) || defined(SDL_JOYSTICK_LINUX) #include diff --git a/vs/sdl2/test/testfile.c b/vs/sdl2/test/testfile.c index 40d52ca22b..a35da02bd7 100644 --- a/vs/sdl2/test/testfile.c +++ b/vs/sdl2/test/testfile.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,25 +107,25 @@ int main(int argc, char *argv[]) RWOP_ERR_QUIT(rwops); } rwops = SDL_RWFromFile(FBASENAME2, "wb"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "wb+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); @@ -136,7 +136,7 @@ int main(int argc, char *argv[]) test : w mode, r mode, w+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (1 != rwops->write(rwops, "1234567890", 10, 1)) { @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) rwops->close(rwops); rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) { @@ -196,7 +196,7 @@ int main(int argc, char *argv[]) /* test 3: same with w+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (1 != rwops->write(rwops, "1234567890", 10, 1)) { @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) /* test 4: same in r+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (1 != rwops->write(rwops, "1234567890", 10, 1)) { @@ -298,7 +298,7 @@ int main(int argc, char *argv[]) /* test5 : append mode */ rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (1 != rwops->write(rwops, "1234567890", 10, 1)) { diff --git a/vs/sdl2/test/testfilesystem.c b/vs/sdl2/test/testfilesystem.c index f452d7761f..af0bd9f05a 100644 --- a/vs/sdl2/test/testfilesystem.c +++ b/vs/sdl2/test/testfilesystem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ int main(int argc, char *argv[]) } base_path = SDL_GetBasePath(); - if (base_path == NULL) { + if (!base_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", SDL_GetError()); } else { @@ -37,7 +37,7 @@ int main(int argc, char *argv[]) } pref_path = SDL_GetPrefPath("libsdl", "test_filesystem"); - if (pref_path == NULL) { + if (!pref_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", SDL_GetError()); } else { @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) } pref_path = SDL_GetPrefPath(NULL, "test_filesystem"); - if (pref_path == NULL) { + if (!pref_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", SDL_GetError()); } else { diff --git a/vs/sdl2/test/testfilesystem_pre.c b/vs/sdl2/test/testfilesystem_pre.c new file mode 100644 index 0000000000..11615abd28 --- /dev/null +++ b/vs/sdl2/test/testfilesystem_pre.c @@ -0,0 +1,32 @@ +/* + Copyright (C) 1997-2024 Sam Lantinga + + 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. +*/ +/* Call SDL_GetPrefPath to warm the SHGetFolderPathW cache */ + +/** + * We noticed frequent ci timeouts running testfilesystem on 32-bit Windows. + * Internally, this functions calls Shell32.SHGetFolderPathW. + */ + +#include "SDL.h" + +int main(int argc, char *argv[]) +{ + Uint64 start; + (void)argc; + (void)argv; + SDL_Init(0); + start = SDL_GetTicks(); + SDL_GetPrefPath("libsdl", "test_filesystem"); + SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", SDL_GetTicks() - start); + SDL_Quit(); + return 0; +} diff --git a/vs/sdl2/test/testgamecontroller.c b/vs/sdl2/test/testgamecontroller.c index e2bdebdec5..52d3b2d853 100644 --- a/vs/sdl2/test/testgamecontroller.c +++ b/vs/sdl2/test/testgamecontroller.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -109,7 +109,7 @@ static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_IN static void UpdateWindowTitle() { - if (window == NULL) { + if (!window) { return; } @@ -201,13 +201,13 @@ static void AddController(int device_index, SDL_bool verbose) } controller = SDL_GameControllerOpen(device_index); - if (controller == NULL) { + if (!controller) { SDL_Log("Couldn't open controller: %s\n", SDL_GetError()); return; } controllers = (SDL_GameController **)SDL_realloc(gamecontrollers, (num_controllers + 1) * sizeof(*controllers)); - if (controllers == NULL) { + if (!controllers) { SDL_GameControllerClose(controller); return; } @@ -221,6 +221,7 @@ static void AddController(int device_index, SDL_bool verbose) const char *name = SDL_GameControllerName(gamecontroller); const char *path = SDL_GameControllerPath(gamecontroller); SDL_Log("Opened game controller %s%s%s\n", name, path ? ", " : "", path ? path : ""); + SDL_Log("Mapping: %s\n", SDL_GameControllerMapping(gamecontroller)); } firmware_version = SDL_GameControllerGetFirmwareVersion(gamecontroller); @@ -413,7 +414,7 @@ static void OpenVirtualController() SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError()); } else { virtual_joystick = SDL_JoystickOpen(virtual_index); - if (virtual_joystick == NULL) { + if (!virtual_joystick) { SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError()); } } @@ -624,7 +625,8 @@ void loop(void *arg) if (event.type == SDL_CONTROLLERBUTTONDOWN) { SetController(event.cbutton.which); } - SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); + SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), + event.cbutton.state ? "pressed" : "released"); /* Cycle PS5 trigger effects when the microphone button is pressed */ if (event.type == SDL_CONTROLLERBUTTONDOWN && @@ -896,13 +898,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Game Controller Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 2; } screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return 2; @@ -920,7 +922,7 @@ int main(int argc, char *argv[]) button_texture = LoadTexture(screen, "button.bmp", SDL_TRUE, NULL, NULL); axis_texture = LoadTexture(screen, "axis.bmp", SDL_TRUE, NULL, NULL); - if (background_front == NULL || background_back == NULL || button_texture == NULL || axis_texture == NULL) { + if (!background_front || !background_back || !button_texture || !axis_texture) { SDL_DestroyRenderer(screen); SDL_DestroyWindow(window); return 2; diff --git a/vs/sdl2/test/testgeometry.c b/vs/sdl2/test/testgeometry.c index 9742a14162..e09c38332f 100644 --- a/vs/sdl2/test/testgeometry.c +++ b/vs/sdl2/test/testgeometry.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +172,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -216,7 +216,7 @@ int main(int argc, char *argv[]) /* Create the windows, initialize the renderers, and load the textures */ sprites = (SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites)); - if (sprites == NULL) { + if (!sprites) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/vs/sdl2/test/testgesture.c b/vs/sdl2/test/testgesture.c index f37635f331..9870b6059c 100644 --- a/vs/sdl2/test/testgesture.c +++ b/vs/sdl2/test/testgesture.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +131,7 @@ DrawScreen(SDL_Window *window) SDL_Surface *screen = SDL_GetWindowSurface(window); int i; - if (screen == NULL) { + if (!screen) { return; } @@ -251,7 +251,7 @@ loop(void) break; case SDL_DOLLARRECORD: - SDL_Log("Recorded gesture: %" SDL_PRIs64 "", event.dgesture.gestureId); + SDL_Log("Recorded gesture: %" SDL_PRIs64, event.dgesture.gestureId); break; } } @@ -272,7 +272,7 @@ loop(void) int main(int argc, char *argv[]) { state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testgl2.c b/vs/sdl2/test/testgl2.c index b58798c322..d14ae16751 100644 --- a/vs/sdl2/test/testgl2.c +++ b/vs/sdl2/test/testgl2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +40,11 @@ static GL_Context ctx; static int LoadContext(GL_Context *data) { -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID +#elif defined(SDL_VIDEO_DRIVER_ANDROID) #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA +#elif defined(SDL_VIDEO_DRIVER_PANDORA) #define __SDL_NOGETPROCADDR__ #endif @@ -205,6 +205,11 @@ Render() ctx.glRotatef(5.0, 1.0, 1.0, 1.0); } +static void LogSwapInterval(void) +{ + SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); +} + int main(int argc, char *argv[]) { int fsaa, accel; @@ -226,7 +231,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -300,7 +305,9 @@ int main(int argc, char *argv[]) SDL_GetCurrentDisplayMode(0, &mode); SDL_Log("Screen BPP : %" SDL_PRIu32 "\n", SDL_BITSPERPIXEL(mode.format)); - SDL_Log("Swap Interval : %d\n", SDL_GL_GetSwapInterval()); + + LogSwapInterval(); + SDL_GetWindowSize(state->windows[0], &dw, &dh); SDL_Log("Window Size : %d,%d\n", dw, dh); SDL_GL_GetDrawableSize(state->windows[0], &dw, &dh); @@ -408,6 +415,7 @@ int main(int argc, char *argv[]) SDL_GL_MakeCurrent(state->windows[i], context); if (update_swap_interval) { SDL_GL_SetSwapInterval(swap_interval); + LogSwapInterval(); } SDL_GL_GetDrawableSize(state->windows[i], &w, &h); ctx.glViewport(0, 0, w, h); diff --git a/vs/sdl2/test/testgles.c b/vs/sdl2/test/testgles.c index 498dbce5c2..b1577cd8ef 100644 --- a/vs/sdl2/test/testgles.c +++ b/vs/sdl2/test/testgles.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +34,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -169,7 +169,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/vs/sdl2/test/testgles2.c b/vs/sdl2/test/testgles2.c index 656e5e6111..bafc524ef4 100644 --- a/vs/sdl2/test/testgles2.c +++ b/vs/sdl2/test/testgles2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +65,11 @@ static GLES2_Context ctx; static int LoadContext(GLES2_Context *data) { -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID +#elif defined(SDL_VIDEO_DRIVER_ANDROID) #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA +#elif defined(SDL_VIDEO_DRIVER_PANDORA) #define __SDL_NOGETPROCADDR__ #endif @@ -96,7 +96,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -636,7 +636,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -696,7 +696,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_Log("Out of memory!\n"); quit(2); } @@ -893,9 +893,9 @@ int main(int argc, char *argv[]) SDL_Log("%2.2f frames per second\n", ((double)frames * 1000) / (now - then)); } -#if !defined(__ANDROID__) && !defined(__NACL__) +#if !defined(__ANDROID__) && !defined(__NACL__) quit(0); -#endif +#endif return 0; } diff --git a/vs/sdl2/test/testgles2_sdf.c b/vs/sdl2/test/testgles2_sdf.c index 91f49064a6..3b15f7298f 100644 --- a/vs/sdl2/test/testgles2_sdf.c +++ b/vs/sdl2/test/testgles2_sdf.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,11 +63,11 @@ static GLES2_Context ctx; static int LoadContext(GLES2_Context *data) { -#if SDL_VIDEO_DRIVER_UIKIT +#ifdef SDL_VIDEO_DRIVER_UIKIT #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_ANDROID +#elif defined(SDL_VIDEO_DRIVER_ANDROID) #define __SDL_NOGETPROCADDR__ -#elif SDL_VIDEO_DRIVER_PANDORA +#elif defined(SDL_VIDEO_DRIVER_PANDORA) #define __SDL_NOGETPROCADDR__ #endif @@ -94,7 +94,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -445,7 +445,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -502,7 +502,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_Log("Out of memory!\n"); quit(2); } @@ -543,17 +543,17 @@ int main(int argc, char *argv[]) #if 1 path = GetNearbyFilename(f); - if (path == NULL) { + if (!path) { path = SDL_strdup(f); } - if (path == NULL) { + if (!path) { SDL_Log("out of memory\n"); exit(-1); } tmp = SDL_LoadBMP(path); - if (tmp == NULL) { + if (!tmp) { SDL_Log("missing image file: %s", path); exit(-1); } else { diff --git a/vs/sdl2/test/testhaptic.c b/vs/sdl2/test/testhaptic.c index fa41863767..56602cafb4 100644 --- a/vs/sdl2/test/testhaptic.c +++ b/vs/sdl2/test/testhaptic.c @@ -16,6 +16,8 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */ #include "SDL.h" +#include + #ifndef SDL_HAPTIC_DISABLED static SDL_Haptic *haptic; @@ -69,7 +71,7 @@ int main(int argc, char **argv) SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ - if (name == NULL) { + if (!name) { i = (index != -1) ? index : 0; } /* Try to find matching device */ @@ -88,7 +90,7 @@ int main(int argc, char **argv) } haptic = SDL_HapticOpen(i); - if (haptic == NULL) { + if (!haptic) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; @@ -279,7 +281,7 @@ int main(int argc, char **argv) } /* Quit */ - if (haptic != NULL) { + if (haptic) { SDL_HapticClose(haptic); } SDL_Quit(); diff --git a/vs/sdl2/test/testhittesting.c b/vs/sdl2/test/testhittesting.c index 92ddf8c42c..94c5ea9aea 100644 --- a/vs/sdl2/test/testhittesting.c +++ b/vs/sdl2/test/testhittesting.c @@ -106,7 +106,7 @@ int main(int argc, char **argv) if (e.key.keysym.sym == SDLK_ESCAPE) { done = 1; } else if (e.key.keysym.sym == SDLK_x) { - if (areas == NULL) { + if (!areas) { areas = drag_areas; numareas = SDL_arraysize(drag_areas); } else { diff --git a/vs/sdl2/test/testhotplug.c b/vs/sdl2/test/testhotplug.c index 1ac73a7fbb..aca1741d7c 100644 --- a/vs/sdl2/test/testhotplug.c +++ b/vs/sdl2/test/testhotplug.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +68,7 @@ int main(int argc, char *argv[]) keepGoing = SDL_FALSE; break; case SDL_JOYDEVICEADDED: - if (joystick != NULL) { + if (joystick) { SDL_Log("Only one joystick supported by this test\n"); } else { joystick = SDL_JoystickOpen(event.jdevice.which); diff --git a/vs/sdl2/test/testiconv.c b/vs/sdl2/test/testiconv.c index b2d13a6aa5..fcdd72892f 100644 --- a/vs/sdl2/test/testiconv.c +++ b/vs/sdl2/test/testiconv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) fname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "utf8.txt"); file = fopen(fname, "rb"); - if (file == NULL) { + if (!file) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname); return 1; } diff --git a/vs/sdl2/test/testime.c b/vs/sdl2/test/testime.c index 51f685b1eb..fb5756dcba 100644 --- a/vs/sdl2/test/testime.c +++ b/vs/sdl2/test/testime.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ #ifdef HAVE_SDL_TTF #ifdef __MACOSX__ #define DEFAULT_FONT "/System/Library/Fonts/åŽæ–‡ç»†é»‘.ttf" -#elif __WIN32__ +#elif defined(__WIN32__) /* Some japanese font present on at least Windows 8.1. */ #define DEFAULT_FONT "C:\\Windows\\Fonts\\yugothic.ttf" #else @@ -97,7 +97,7 @@ static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np) } n = (n << 4) | c; } - if (np != NULL) { + if (np) { *np = n; } return 1; @@ -116,7 +116,7 @@ static int unifont_init(const char *fontname) /* Allocate memory for the glyph data so the file can be closed after initialization. */ unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize); - if (unifontGlyph == NULL) { + if (!unifontGlyph) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024); return -1; } @@ -124,20 +124,20 @@ static int unifont_init(const char *fontname) /* Allocate memory for texture pointers for all renderers. */ unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize); - if (unifontTexture == NULL) { + if (!unifontTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024); return -1; } SDL_memset(unifontTexture, 0, unifontTextureSize); filename = GetResourceFilename(NULL, fontname); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); return -1; } hexFile = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (hexFile == NULL) { + if (!hexFile) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname); return -1; } @@ -269,7 +269,7 @@ static int unifont_load_texture(Uint32 textureID) } textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE); - if (textureRGBA == NULL) { + if (!textureRGBA) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024); return -1; } @@ -324,7 +324,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_Rect *dst } } texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID]; - if (texture != NULL) { + if (texture) { const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE; srcrect.x = cInTex % UNIFONT_GLYPHS_IN_ROW * 16; srcrect.y = cInTex / UNIFONT_GLYPHS_IN_ROW * 16; @@ -338,12 +338,12 @@ static void unifont_cleanup() int i, j; for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL || renderer == NULL) { + if (state->windows[i] == NULL || !renderer) { continue; } for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) { SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j]; - if (tex != NULL) { + if (tex) { SDL_DestroyTexture(tex); } } @@ -530,7 +530,7 @@ void _Redraw(int rendererID) if (cursor) { char *p = utf8_advance(markedText, cursor); char c = 0; - if (p == NULL) { + if (!p) { p = &markedText[SDL_strlen(markedText)]; } @@ -626,7 +626,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc; i++) { @@ -660,7 +660,7 @@ int main(int argc, char *argv[]) TTF_Init(); font = TTF_OpenFont(fontname, DEFAULT_PTSIZE); - if (font == NULL) { + if (!font) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError()); return -1; } diff --git a/vs/sdl2/test/testintersections.c b/vs/sdl2/test/testintersections.c index f24d9fbf52..bb95fbe937 100644 --- a/vs/sdl2/test/testintersections.c +++ b/vs/sdl2/test/testintersections.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -289,7 +289,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/vs/sdl2/test/testjoystick.c b/vs/sdl2/test/testjoystick.c index adb31dc14f..3898580494 100644 --- a/vs/sdl2/test/testjoystick.c +++ b/vs/sdl2/test/testjoystick.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ void loop(void *arg) case SDL_JOYDEVICEADDED: SDL_Log("Joystick device %d added.\n", (int)event.jdevice.which); - if (joystick == NULL) { + if (!joystick) { joystick = SDL_JoystickOpen(event.jdevice.which); if (joystick) { PrintJoystick(joystick); @@ -296,13 +296,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; diff --git a/vs/sdl2/test/testkeys.c b/vs/sdl2/test/testkeys.c index f80f0b9dcc..c7b120b4f5 100644 --- a/vs/sdl2/test/testkeys.c +++ b/vs/sdl2/test/testkeys.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testloadso.c b/vs/sdl2/test/testloadso.c index f404a68133..fa6923b97a 100644 --- a/vs/sdl2/test/testloadso.c +++ b/vs/sdl2/test/testloadso.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,13 +53,13 @@ int main(int argc, char *argv[]) } lib = SDL_LoadObject(libname); - if (lib == NULL) { + if (!lib) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", libname, SDL_GetError()); retval = 3; } else { fn = (fntype)SDL_LoadFunction(lib, symname); - if (fn == NULL) { + if (!fn) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", symname, SDL_GetError()); retval = 4; diff --git a/vs/sdl2/test/testlocale.c b/vs/sdl2/test/testlocale.c index f8ff1a37b0..6e371ca101 100644 --- a/vs/sdl2/test/testlocale.c +++ b/vs/sdl2/test/testlocale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -17,7 +17,7 @@ static void log_locales(void) { SDL_Locale *locales = SDL_GetPreferredLocales(); - if (locales == NULL) { + if (!locales) { SDL_Log("Couldn't determine locales: %s", SDL_GetError()); } else { SDL_Locale *l; diff --git a/vs/sdl2/test/testlock.c b/vs/sdl2/test/testlock.c index 544ec322b0..1af8846fac 100644 --- a/vs/sdl2/test/testlock.c +++ b/vs/sdl2/test/testlock.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) SDL_AtomicSet(&doterminate, 0); mutex = SDL_CreateMutex(); - if (mutex == NULL) { + if (!mutex) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError()); exit(1); } diff --git a/vs/sdl2/test/testmessage.c b/vs/sdl2/test/testmessage.c index f805f8301a..d3de67ee76 100644 --- a/vs/sdl2/test/testmessage.c +++ b/vs/sdl2/test/testmessage.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testmouse.c b/vs/sdl2/test/testmouse.c index d1c4edc06b..0583ead5a1 100644 --- a/vs/sdl2/test/testmouse.c +++ b/vs/sdl2/test/testmouse.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -83,7 +83,7 @@ void DrawObject(SDL_Renderer *renderer, Object *object) void DrawObjects(SDL_Renderer *renderer) { Object *next = objects; - while (next != NULL) { + while (next) { DrawObject(renderer, next); next = next->next; } @@ -93,7 +93,7 @@ void AppendObject(Object *object) { if (objects) { Object *next = objects; - while (next->next != NULL) { + while (next->next) { next = next->next; } next->next = object; @@ -130,7 +130,7 @@ void loop(void *arg) break; case SDL_MOUSEMOTION: - if (active == NULL) { + if (!active) { break; } @@ -139,7 +139,7 @@ void loop(void *arg) break; case SDL_MOUSEBUTTONDOWN: - if (active == NULL) { + if (!active) { active = SDL_calloc(1, sizeof(*active)); active->x1 = active->x2 = event.button.x; active->y1 = active->y2 = event.button.y; @@ -173,7 +173,7 @@ void loop(void *arg) break; case SDL_MOUSEBUTTONUP: - if (active == NULL) { + if (!active) { break; } @@ -266,13 +266,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Mouse Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; diff --git a/vs/sdl2/test/testmultiaudio.c b/vs/sdl2/test/testmultiaudio.c index 2fd352b52e..593942038c 100644 --- a/vs/sdl2/test/testmultiaudio.c +++ b/vs/sdl2/test/testmultiaudio.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testnative.c b/vs/sdl2/test/testnative.c index e803b822dd..ad47e4a07d 100644 --- a/vs/sdl2/test/testnative.c +++ b/vs/sdl2/test/testnative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ static void quit(int rc) { SDL_VideoQuit(); - if (native_window != NULL && factory != NULL) { + if (native_window && factory) { factory->DestroyNativeWindow(native_window); } exit(rc); @@ -119,19 +119,19 @@ int main(int argc, char *argv[]) break; } } - if (factory == NULL) { + if (!factory) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", driver); quit(2); } SDL_Log("Creating native window for %s driver\n", driver); native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H); - if (native_window == NULL) { + if (!native_window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n"); quit(3); } window = SDL_CreateWindowFrom(native_window); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError()); quit(4); } @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) /* Create the renderer */ renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(5); } @@ -149,7 +149,7 @@ int main(int argc, char *argv[]) SDL_RenderClear(renderer); sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, NULL, NULL); - if (sprite == NULL) { + if (!sprite) { quit(6); } @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); positions = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); velocities = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/vs/sdl2/test/testnative.h b/vs/sdl2/test/testnative.h index 2ba9005866..e2643902e8 100644 --- a/vs/sdl2/test/testnative.h +++ b/vs/sdl2/test/testnative.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testnativeos2.c b/vs/sdl2/test/testnativeos2.c index e0f249121a..bbdbe9025e 100644 --- a/vs/sdl2/test/testnativeos2.c +++ b/vs/sdl2/test/testnativeos2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testnativew32.c b/vs/sdl2/test/testnativew32.c index e1574583db..dfd0b63f47 100644 --- a/vs/sdl2/test/testnativew32.c +++ b/vs/sdl2/test/testnativew32.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -66,7 +66,7 @@ CreateWindowNative(int w, int h) CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), NULL); - if (hwnd == NULL) { + if (!hwnd) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; diff --git a/vs/sdl2/test/testnativex11.c b/vs/sdl2/test/testnativex11.c index 95dc3d6447..a891f466ea 100644 --- a/vs/sdl2/test/testnativex11.c +++ b/vs/sdl2/test/testnativex11.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testoffscreen.c b/vs/sdl2/test/testoffscreen.c index fa511e8cef..09ef7fcdd7 100644 --- a/vs/sdl2/test/testoffscreen.c +++ b/vs/sdl2/test/testoffscreen.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,14 +115,14 @@ int main(int argc, char *argv[]) SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, 0); - if (window == NULL) { + if (!window) { SDL_Log("Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_Log("Couldn't create renderer: %s\n", SDL_GetError()); return SDL_FALSE; diff --git a/vs/sdl2/test/testoverlay2.c b/vs/sdl2/test/testoverlay2.c index a5dba68633..ccfa8e5b40 100644 --- a/vs/sdl2/test/testoverlay2.c +++ b/vs/sdl2/test/testoverlay2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -311,21 +311,21 @@ int main(int argc, char **argv) } RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); - if (RawMooseData == NULL) { + if (!RawMooseData) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); quit(1); } /* load the trojan moose images */ filename = GetResourceFilename(NULL, "moose.dat"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); SDL_free(RawMooseData); return -1; } handle = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (handle == NULL) { + if (!handle) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); SDL_free(RawMooseData); quit(2); @@ -343,21 +343,21 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, window_w, window_h, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); SDL_free(RawMooseData); quit(4); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); SDL_free(RawMooseData); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (MooseTexture == NULL) { + if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); SDL_free(RawMooseData); quit(5); diff --git a/vs/sdl2/test/testplatform.c b/vs/sdl2/test/testplatform.c index 7e89d2f819..353758a7da 100644 --- a/vs/sdl2/test/testplatform.c +++ b/vs/sdl2/test/testplatform.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -366,7 +366,7 @@ int Test64Bit(SDL_bool verbose) LL_Test *t; int failed = 0; - for (t = LL_Tests; t->routine != NULL; t++) { + for (t = LL_Tests; t->routine; t++) { unsigned long long result = 0; unsigned int *al = (unsigned int *)&t->a; unsigned int *bl = (unsigned int *)&t->b; diff --git a/vs/sdl2/test/testpower.c b/vs/sdl2/test/testpower.c index af60258d79..1c13b4dbaf 100644 --- a/vs/sdl2/test/testpower.c +++ b/vs/sdl2/test/testpower.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testqsort.c b/vs/sdl2/test/testqsort.c index 271671e91c..9c1f7646d9 100644 --- a/vs/sdl2/test/testqsort.c +++ b/vs/sdl2/test/testqsort.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testrelative.c b/vs/sdl2/test/testrelative.c index 88ed0bf5ab..3f777cd83d 100644 --- a/vs/sdl2/test/testrelative.c +++ b/vs/sdl2/test/testrelative.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +91,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc; ++i) { diff --git a/vs/sdl2/test/testrendercopyex.c b/vs/sdl2/test/testrendercopyex.c index de7bc019a3..832101aa37 100644 --- a/vs/sdl2/test/testrendercopyex.c +++ b/vs/sdl2/test/testrendercopyex.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testrendertarget.c b/vs/sdl2/test/testrendertarget.c index 1ae6099874..9693df4f84 100644 --- a/vs/sdl2/test/testrendertarget.c +++ b/vs/sdl2/test/testrendertarget.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +138,7 @@ Draw(DrawState *s) SDL_RenderGetViewport(s->renderer, &viewport); target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); - if (target == NULL) { + if (!target) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError()); return SDL_FALSE; } @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/vs/sdl2/test/testresample.c b/vs/sdl2/test/testresample.c index 8bb603ac20..21ff8e170c 100644 --- a/vs/sdl2/test/testresample.c +++ b/vs/sdl2/test/testresample.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +57,7 @@ int main(int argc, char **argv) cvt.len = len; cvt.buf = (Uint8 *)SDL_malloc((size_t)len * cvt.len_mult); - if (cvt.buf == NULL) { + if (!cvt.buf) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); SDL_FreeWAV(data); SDL_Quit(); @@ -75,7 +75,7 @@ int main(int argc, char **argv) /* write out a WAV header... */ io = SDL_RWFromFile(argv[2], "wb"); - if (io == NULL) { + if (!io) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); diff --git a/vs/sdl2/test/testrumble.c b/vs/sdl2/test/testrumble.c index d6288d5923..401b7605e2 100644 --- a/vs/sdl2/test/testrumble.c +++ b/vs/sdl2/test/testrumble.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,7 +71,7 @@ int main(int argc, char **argv) SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ - if (name == NULL) { + if (!name) { i = (index != -1) ? index : 0; } /* Try to find matching device */ @@ -90,7 +90,7 @@ int main(int argc, char **argv) } haptic = SDL_HapticOpen(i); - if (haptic == NULL) { + if (!haptic) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; @@ -129,7 +129,7 @@ int main(int argc, char **argv) SDL_Delay(2000); /* Quit */ - if (haptic != NULL) { + if (haptic) { SDL_HapticClose(haptic); } SDL_Quit(); diff --git a/vs/sdl2/test/testscale.c b/vs/sdl2/test/testscale.c index dca3d09600..3659c91490 100644 --- a/vs/sdl2/test/testscale.c +++ b/vs/sdl2/test/testscale.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +111,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testsem.c b/vs/sdl2/test/testsem.c index c0036e882f..5740833f43 100644 --- a/vs/sdl2/test/testsem.c +++ b/vs/sdl2/test/testsem.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testsensor.c b/vs/sdl2/test/testsensor.c index 3da7e015e7..2b9af5835f 100644 --- a/vs/sdl2/test/testsensor.c +++ b/vs/sdl2/test/testsensor.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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 @@ static const char *GetSensorTypeString(SDL_SensorType type) static void HandleSensorEvent(SDL_SensorEvent *event) { SDL_Sensor *sensor = SDL_SensorFromInstanceID(event->which); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't get sensor for sensor event\n"); return; } @@ -78,7 +78,7 @@ int main(int argc, char **argv) if (SDL_SensorGetDeviceType(i) != SDL_SENSOR_UNKNOWN) { SDL_Sensor *sensor = SDL_SensorOpen(i); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't open sensor %" SDL_PRIs32 ": %s\n", SDL_SensorGetDeviceInstanceID(i), SDL_GetError()); } else { ++num_opened; diff --git a/vs/sdl2/test/testshader.c b/vs/sdl2/test/testshader.c index 2371fcefbc..48535dca78 100644 --- a/vs/sdl2/test/testshader.c +++ b/vs/sdl2/test/testshader.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -109,36 +109,36 @@ static ShaderData shaders[NUM_SHADERS] = { "}" }, }; -static PFNGLATTACHOBJECTARBPROC glAttachObjectARB; -static PFNGLCOMPILESHADERARBPROC glCompileShaderARB; -static PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; -static PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; -static PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; -static PFNGLGETINFOLOGARBPROC glGetInfoLogARB; -static PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; -static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; -static PFNGLLINKPROGRAMARBPROC glLinkProgramARB; -static PFNGLSHADERSOURCEARBPROC glShaderSourceARB; -static PFNGLUNIFORM1IARBPROC glUniform1iARB; -static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; +static PFNGLATTACHOBJECTARBPROC pglAttachObjectARB; +static PFNGLCOMPILESHADERARBPROC pglCompileShaderARB; +static PFNGLCREATEPROGRAMOBJECTARBPROC pglCreateProgramObjectARB; +static PFNGLCREATESHADEROBJECTARBPROC pglCreateShaderObjectARB; +static PFNGLDELETEOBJECTARBPROC pglDeleteObjectARB; +static PFNGLGETINFOLOGARBPROC pglGetInfoLogARB; +static PFNGLGETOBJECTPARAMETERIVARBPROC pglGetObjectParameterivARB; +static PFNGLGETUNIFORMLOCATIONARBPROC pglGetUniformLocationARB; +static PFNGLLINKPROGRAMARBPROC pglLinkProgramARB; +static PFNGLSHADERSOURCEARBPROC pglShaderSourceARB; +static PFNGLUNIFORM1IARBPROC pglUniform1iARB; +static PFNGLUSEPROGRAMOBJECTARBPROC pglUseProgramObjectARB; static SDL_bool CompileShader(GLhandleARB shader, const char *source) { GLint status = 0; - glShaderSourceARB(shader, 1, &source, NULL); - glCompileShaderARB(shader); - glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); + pglShaderSourceARB(shader, 1, &source, NULL); + pglCompileShaderARB(shader); + pglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); if (status == 0) { GLint length = 0; char *info; - glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + pglGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = (char *)SDL_malloc((size_t)length + 1); - if (info == NULL) { + if (!info) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { - glGetInfoLogARB(shader, length, NULL, info); + pglGetInfoLogARB(shader, length, NULL, info); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to compile shader:\n%s\n%s", source, info); SDL_free(info); } @@ -152,21 +152,21 @@ static SDL_bool LinkProgram(ShaderData *data) { GLint status = 0; - glAttachObjectARB(data->program, data->vert_shader); - glAttachObjectARB(data->program, data->frag_shader); - glLinkProgramARB(data->program); + pglAttachObjectARB(data->program, data->vert_shader); + pglAttachObjectARB(data->program, data->frag_shader); + pglLinkProgramARB(data->program); - glGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status); + pglGetObjectParameterivARB(data->program, GL_OBJECT_LINK_STATUS_ARB, &status); if (status == 0) { GLint length = 0; char *info; - glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + pglGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = (char *)SDL_malloc((size_t)length + 1); - if (info == NULL) { + if (!info) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { - glGetInfoLogARB(data->program, length, NULL, info); + pglGetInfoLogARB(data->program, length, NULL, info); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to link program:\n%s", info); SDL_free(info); } @@ -185,16 +185,16 @@ static SDL_bool CompileShaderProgram(ShaderData *data) glGetError(); /* Create one program object to rule them all */ - data->program = glCreateProgramObjectARB(); + data->program = pglCreateProgramObjectARB(); /* Create the vertex shader */ - data->vert_shader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + data->vert_shader = pglCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); if (!CompileShader(data->vert_shader, data->vert_source)) { return SDL_FALSE; } /* Create the fragment shader */ - data->frag_shader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + data->frag_shader = pglCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); if (!CompileShader(data->frag_shader, data->frag_source)) { return SDL_FALSE; } @@ -205,16 +205,16 @@ static SDL_bool CompileShaderProgram(ShaderData *data) } /* Set up some uniform variables */ - glUseProgramObjectARB(data->program); + pglUseProgramObjectARB(data->program); for (i = 0; i < num_tmus_bound; ++i) { char tex_name[5]; (void)SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i); - location = glGetUniformLocationARB(data->program, tex_name); + location = pglGetUniformLocationARB(data->program, tex_name); if (location >= 0) { - glUniform1iARB(location, i); + pglUniform1iARB(location, i); } } - glUseProgramObjectARB(0); + pglUseProgramObjectARB(0); return (glGetError() == GL_NO_ERROR) ? SDL_TRUE : SDL_FALSE; } @@ -222,9 +222,9 @@ static SDL_bool CompileShaderProgram(ShaderData *data) static void DestroyShaderProgram(ShaderData *data) { if (shaders_supported) { - glDeleteObjectARB(data->vert_shader); - glDeleteObjectARB(data->frag_shader); - glDeleteObjectARB(data->program); + pglDeleteObjectARB(data->vert_shader); + pglDeleteObjectARB(data->frag_shader); + pglDeleteObjectARB(data->program); } } @@ -238,30 +238,30 @@ static SDL_bool InitShaders() SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { - glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB"); - glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB"); - glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); - glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB"); - glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); - glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB"); - glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB"); - glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB"); - glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB"); - glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB"); - glUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB"); - glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); - if (glAttachObjectARB && - glCompileShaderARB && - glCreateProgramObjectARB && - glCreateShaderObjectARB && - glDeleteObjectARB && - glGetInfoLogARB && - glGetObjectParameterivARB && - glGetUniformLocationARB && - glLinkProgramARB && - glShaderSourceARB && - glUniform1iARB && - glUseProgramObjectARB) { + pglAttachObjectARB = (PFNGLATTACHOBJECTARBPROC)SDL_GL_GetProcAddress("glAttachObjectARB"); + pglCompileShaderARB = (PFNGLCOMPILESHADERARBPROC)SDL_GL_GetProcAddress("glCompileShaderARB"); + pglCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + pglCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC)SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + pglDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC)SDL_GL_GetProcAddress("glDeleteObjectARB"); + pglGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)SDL_GL_GetProcAddress("glGetInfoLogARB"); + pglGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + pglGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)SDL_GL_GetProcAddress("glGetUniformLocationARB"); + pglLinkProgramARB = (PFNGLLINKPROGRAMARBPROC)SDL_GL_GetProcAddress("glLinkProgramARB"); + pglShaderSourceARB = (PFNGLSHADERSOURCEARBPROC)SDL_GL_GetProcAddress("glShaderSourceARB"); + pglUniform1iARB = (PFNGLUNIFORM1IARBPROC)SDL_GL_GetProcAddress("glUniform1iARB"); + pglUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC)SDL_GL_GetProcAddress("glUseProgramObjectARB"); + if (pglAttachObjectARB && + pglCompileShaderARB && + pglCreateProgramObjectARB && + pglCreateShaderObjectARB && + pglDeleteObjectARB && + pglGetInfoLogARB && + pglGetObjectParameterivARB && + pglGetUniformLocationARB && + pglLinkProgramARB && + pglShaderSourceARB && + pglUniform1iARB && + pglUseProgramObjectARB) { shaders_supported = SDL_TRUE; } } @@ -329,7 +329,7 @@ SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) 0x00FF0000, 0x0000FF00, 0x000000FF #endif ); - if (image == NULL) { + if (!image) { return 0; } @@ -420,7 +420,7 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat *texcoord) glBindTexture(GL_TEXTURE_2D, texture); glColor3f(1.0f, 1.0f, 1.0f); if (shaders_supported) { - glUseProgramObjectARB(shaders[current_shader].program); + pglUseProgramObjectARB(shaders[current_shader].program); } glBegin(GL_QUADS); /* start drawing a polygon (4 sided) */ @@ -435,7 +435,7 @@ void DrawGLScene(SDL_Window *window, GLuint texture, GLfloat *texcoord) glEnd(); /* done with the polygon */ if (shaders_supported) { - glUseProgramObjectARB(0); + pglUseProgramObjectARB(0); } glDisable(GL_TEXTURE_2D); @@ -462,7 +462,7 @@ int main(int argc, char **argv) /* Create a 640x480 OpenGL screen */ window = SDL_CreateWindow("Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_OPENGL); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); @@ -475,7 +475,7 @@ int main(int argc, char **argv) } surface = SDL_LoadBMP("icon.bmp"); - if (surface == NULL) { + if (!surface) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError()); SDL_Quit(); exit(3); diff --git a/vs/sdl2/test/testshape.c b/vs/sdl2/test/testshape.c index 4e3c12cddd..112ec0c60b 100644 --- a/vs/sdl2/test/testshape.c +++ b/vs/sdl2/test/testshape.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -71,7 +71,7 @@ int main(int argc, char **argv) num_pictures = argc - 1; pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture) * num_pictures); - if (pictures == NULL) { + if (!pictures) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate memory."); exit(1); } @@ -106,7 +106,7 @@ int main(int argc, char **argv) SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION, 0); SDL_SetWindowPosition(window, SHAPED_WINDOW_X, SHAPED_WINDOW_Y); - if (window == NULL) { + if (!window) { for (i = 0; i < num_pictures; i++) { SDL_FreeSurface(pictures[i].surface); } @@ -116,7 +116,7 @@ int main(int argc, char **argv) exit(-4); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_DestroyWindow(window); for (i = 0; i < num_pictures; i++) { SDL_FreeSurface(pictures[i].surface); diff --git a/vs/sdl2/test/testsprite2.c b/vs/sdl2/test/testsprite2.c index 89037fd09c..71b565678b 100644 --- a/vs/sdl2/test/testsprite2.c +++ b/vs/sdl2/test/testsprite2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -392,22 +392,30 @@ void MoveSprites(SDL_Renderer *renderer, SDL_Texture *sprite) SDL_RenderPresent(renderer); } -void loop() +static void MoveAllSprites() { - Uint32 now; int i; - SDL_Event event; - /* Check for events */ - while (SDL_PollEvent(&event)) { - SDLTest_CommonEvent(state, &event, &done); - } for (i = 0; i < state->num_windows; ++i) { if (state->windows[i] == NULL) { continue; } MoveSprites(state->renderers[i], sprites[i]); } +} + +void loop() +{ + Uint32 now; + SDL_Event event; + + /* Check for events */ + while (SDL_PollEvent(&event)) { + SDLTest_CommonEvent(state, &event, &done); + } + + MoveAllSprites(); + #ifdef __EMSCRIPTEN__ if (done) { emscripten_cancel_main_loop(); @@ -426,6 +434,14 @@ void loop() } } +static int SDLCALL ExposeEventWatcher(void *userdata, SDL_Event *event) +{ + if (event->type == SDL_WINDOWEVENT && event->window.event == SDL_WINDOWEVENT_EXPOSED) { + MoveAllSprites(); + } + return 0; +} + int main(int argc, char *argv[]) { int i; @@ -437,7 +453,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -525,7 +541,7 @@ int main(int argc, char *argv[]) /* Create the windows, initialize the renderers, and load the textures */ sprites = (SDL_Texture **)SDL_malloc(state->num_windows * sizeof(*sprites)); - if (sprites == NULL) { + if (!sprites) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -541,7 +557,7 @@ int main(int argc, char *argv[]) /* Allocate memory for the sprite info */ positions = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); velocities = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } @@ -568,6 +584,9 @@ int main(int argc, char *argv[]) } } + /* Add an event watcher to redraw from within modal window resize/move loops */ + SDL_AddEventWatch(ExposeEventWatcher, NULL); + /* Main render loop */ frames = 0; next_fps_check = SDL_GetTicks() + fps_check_delay; diff --git a/vs/sdl2/test/testspriteminimal.c b/vs/sdl2/test/testspriteminimal.c index 16b4fa4a36..b81101eb5d 100644 --- a/vs/sdl2/test/testspriteminimal.c +++ b/vs/sdl2/test/testspriteminimal.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { quit(2); } diff --git a/vs/sdl2/test/teststreaming.c b/vs/sdl2/test/teststreaming.c index 15c1aefea3..45202a7797 100644 --- a/vs/sdl2/test/teststreaming.c +++ b/vs/sdl2/test/teststreaming.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -141,13 +141,13 @@ int main(int argc, char **argv) /* load the moose images */ filename = GetResourceFilename(NULL, "moose.dat"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); return -1; } handle = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (handle == NULL) { + if (!handle) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); quit(2); } @@ -160,19 +160,19 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); quit(3); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (MooseTexture == NULL) { + if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); quit(5); } diff --git a/vs/sdl2/test/testsurround.c b/vs/sdl2/test/testsurround.c index b28436977e..b7dc7d7818 100644 --- a/vs/sdl2/test/testsurround.c +++ b/vs/sdl2/test/testsurround.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testthread.c b/vs/sdl2/test/testthread.c index f6d967560f..5ceac05ffa 100644 --- a/vs/sdl2/test/testthread.c +++ b/vs/sdl2/test/testthread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 @@ int main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, "One", "#1"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) alive = 1; (void)signal(SIGTERM, killed); thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } diff --git a/vs/sdl2/test/testtimer.c b/vs/sdl2/test/testtimer.c index 54a903ad08..eea9730c53 100644 --- a/vs/sdl2/test/testtimer.c +++ b/vs/sdl2/test/testtimer.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,9 +18,38 @@ #include #include "SDL.h" +#include "SDL_test.h" #define DEFAULT_RESOLUTION 1 +static int test_sdl_delay_within_bounds(void) { + const int testDelay = 100; + const int marginOfError = 25; + Uint64 result; + Uint64 result2; + Sint64 difference; + + SDLTest_ResetAssertSummary(); + + /* Get ticks count - should be non-zero by now */ + result = SDL_GetTicks(); + SDLTest_AssertPass("Call to SDL_GetTicks()"); + SDLTest_AssertCheck(result > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result); + + /* Delay a bit longer and measure ticks and verify difference */ + SDL_Delay(testDelay); + SDLTest_AssertPass("Call to SDL_Delay(%d)", testDelay); + result2 = SDL_GetTicks(); + SDLTest_AssertPass("Call to SDL_GetTicks()"); + SDLTest_AssertCheck(result2 > 0, "Check result value, expected: >0, got: %" SDL_PRIu64, result2); + difference = result2 - result; + SDLTest_AssertCheck(difference > (testDelay - marginOfError), "Check difference, expected: >%d, got: %" SDL_PRIu64, testDelay - marginOfError, difference); + /* Disabled because this might fail on non-interactive systems. */ + SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %" SDL_PRIu64, testDelay + marginOfError, difference); + + return SDLTest_AssertSummaryToTestResult() == TEST_RESULT_PASSED ? 0 : 1; +} + static int ticks = 0; static Uint32 SDLCALL @@ -39,15 +68,43 @@ callback(Uint32 interval, void *param) int main(int argc, char *argv[]) { - int i, desired; + int i; + int desired = -1; SDL_TimerID t1, t2, t3; Uint64 start64, now64; Uint32 start32, now32; Uint64 start, now; + SDL_bool run_interactive_tests = SDL_FALSE; + int return_code = 0; /* Enable standard application logging */ SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO); + /* Parse commandline */ + for (i = 1; i < argc;) { + int consumed = 0; + + if (!consumed) { + if (SDL_strcmp(argv[i], "--interactive") == 0) { + run_interactive_tests = SDL_TRUE; + consumed = 1; + } else if (desired < 0) { + char *endptr; + + desired = SDL_strtoul(argv[i], &endptr, 0); + if (desired != 0 && endptr != argv[i] && *endptr == '\0') { + consumed = 1; + } + } + } + if (consumed <= 0) { + SDL_Log("Usage: %s [--interactive] [interval]", argv[0]); + return 1; + } + + i += consumed; + } + if (SDL_Init(SDL_INIT_TIMER) < 0) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError()); return 1; @@ -74,14 +131,11 @@ int main(int argc, char *argv[]) } } - /* Start the timer */ - desired = 0; - if (argv[1]) { - desired = SDL_atoi(argv[1]); - } - if (desired == 0) { + if (desired < 0) { desired = DEFAULT_RESOLUTION; } + + /* Start the timer */ t1 = SDL_AddTimer(desired, ticktock, NULL); /* Wait 10 seconds */ @@ -102,14 +156,17 @@ int main(int argc, char *argv[]) t1 = SDL_AddTimer(100, callback, (void *)1); if (!t1) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 1: %s\n", SDL_GetError()); + return_code = 1; } t2 = SDL_AddTimer(50, callback, (void *)2); if (!t2) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 2: %s\n", SDL_GetError()); + return_code = 1; } t3 = SDL_AddTimer(233, callback, (void *)3); if (!t3) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create timer 3: %s\n", SDL_GetError()); + return_code = 1; } /* Wait 10 seconds */ @@ -141,8 +198,11 @@ int main(int argc, char *argv[]) now32 = SDL_GetTicks(); SDL_Log("Delay 1 second = %d ms in ticks, %d ms in ticks64, %f ms according to performance counter\n", (int)(now32 - start32), (int)(now64 - start64), (double)((now - start) * 1000) / SDL_GetPerformanceFrequency()); + if (run_interactive_tests) { + return_code |= test_sdl_delay_within_bounds(); + } SDL_Quit(); - return 0; + return return_code; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/vs/sdl2/test/testurl.c b/vs/sdl2/test/testurl.c index ef22083ffb..2008186f3a 100644 --- a/vs/sdl2/test/testurl.c +++ b/vs/sdl2/test/testurl.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testutils.c b/vs/sdl2/test/testutils.c index 20efef027a..3b76ea8331 100644 --- a/vs/sdl2/test/testutils.c +++ b/vs/sdl2/test/testutils.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright 2022 Collabora Ltd. This software is provided 'as-is', without any express or implied @@ -28,13 +28,13 @@ GetNearbyFilename(const char *file) base = SDL_GetBasePath(); - if (base != NULL) { + if (base) { SDL_RWops *rw; size_t len = SDL_strlen(base) + SDL_strlen(file) + 1; path = SDL_malloc(len); - if (path == NULL) { + if (!path) { SDL_free(base); SDL_OutOfMemory(); return NULL; @@ -54,7 +54,7 @@ GetNearbyFilename(const char *file) } path = SDL_strdup(file); - if (path == NULL) { + if (!path) { SDL_OutOfMemory(); } return path; @@ -72,10 +72,10 @@ GetNearbyFilename(const char *file) char * GetResourceFilename(const char *user_specified, const char *def) { - if (user_specified != NULL) { + if (user_specified) { char *ret = SDL_strdup(user_specified); - if (ret == NULL) { + if (!ret) { SDL_OutOfMemory(); } @@ -105,12 +105,12 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent, path = GetNearbyFilename(file); - if (path != NULL) { + if (path) { file = path; } temp = SDL_LoadBMP(file); - if (temp == NULL) { + if (!temp) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); } else { /* Set transparent pixel as the pixel at (0,0) */ @@ -137,16 +137,16 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent, } } - if (width_out != NULL) { + if (width_out) { *width_out = temp->w; } - if (height_out != NULL) { + if (height_out) { *height_out = temp->h; } texture = SDL_CreateTextureFromSurface(renderer, temp); - if (texture == NULL) { + if (!texture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); } } diff --git a/vs/sdl2/test/testutils.h b/vs/sdl2/test/testutils.h index 1f69673ce0..a10aaadd31 100644 --- a/vs/sdl2/test/testutils.h +++ b/vs/sdl2/test/testutils.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga Copyright 2022 Collabora Ltd. This software is provided 'as-is', without any express or implied diff --git a/vs/sdl2/test/testver.c b/vs/sdl2/test/testver.c index eeecb14a69..409b1f12f3 100644 --- a/vs/sdl2/test/testver.c +++ b/vs/sdl2/test/testver.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testviewport.c b/vs/sdl2/test/testviewport.c index 932f248325..ee76a3782f 100644 --- a/vs/sdl2/test/testviewport.c +++ b/vs/sdl2/test/testviewport.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +152,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) sprite = LoadTexture(state->renderers[0], "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { quit(2); } diff --git a/vs/sdl2/test/testvulkan.c b/vs/sdl2/test/testvulkan.c index acdde28fd2..8a4ac89349 100644 --- a/vs/sdl2/test/testvulkan.c +++ b/vs/sdl2/test/testvulkan.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -236,7 +236,7 @@ static void createInstance(void) quit(2); } extensions = (const char **)SDL_malloc(sizeof(const char *) * extensionCount); - if (extensions == NULL) { + if (!extensions) { SDL_OutOfMemory(); quit(2); } @@ -312,7 +312,7 @@ static void findPhysicalDevice(void) quit(2); } physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if (physicalDevices == NULL) { + if (!physicalDevices) { SDL_OutOfMemory(); quit(2); } @@ -346,7 +346,7 @@ static void findPhysicalDevice(void) SDL_free(queueFamiliesProperties); queueFamiliesPropertiesAllocatedSize = queueFamiliesCount; queueFamiliesProperties = (VkQueueFamilyProperties *)SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize); - if (queueFamiliesProperties == NULL) { + if (!queueFamiliesProperties) { SDL_free(physicalDevices); SDL_free(deviceExtensions); SDL_OutOfMemory(); @@ -408,7 +408,7 @@ static void findPhysicalDevice(void) SDL_free(deviceExtensions); deviceExtensionsAllocatedSize = deviceExtensionCount; deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize); - if (deviceExtensions == NULL) { + if (!deviceExtensions) { SDL_free(physicalDevices); SDL_free(queueFamiliesProperties); SDL_OutOfMemory(); @@ -929,7 +929,7 @@ static void initVulkan(void) SDL_Vulkan_LoadLibrary(NULL); vulkanContexts = (VulkanContext *)SDL_calloc(state->num_windows, sizeof(VulkanContext)); - if (vulkanContexts == NULL) { + if (!vulkanContexts) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); quit(2); } @@ -1092,7 +1092,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testwm2.c b/vs/sdl2/test/testwm2.c index 7fc189bd75..5236a7f5b9 100644 --- a/vs/sdl2/test/testwm2.c +++ b/vs/sdl2/test/testwm2.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages @@ -208,7 +208,7 @@ void loop() } if (event.type == SDL_MOUSEBUTTONUP) { SDL_Window *window = SDL_GetMouseFocus(); - if (highlighted_mode != -1 && window != NULL) { + if (highlighted_mode != -1 && window) { const int display_index = SDL_GetWindowDisplayIndex(window); SDL_DisplayMode mode; if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) { @@ -223,7 +223,7 @@ void loop() for (i = 0; i < state->num_windows; ++i) { SDL_Window *window = state->windows[i]; SDL_Renderer *renderer = state->renderers[i]; - if (window != NULL && renderer != NULL) { + if (window && renderer) { int y = 0; SDL_Rect viewport, menurect; @@ -262,7 +262,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/vs/sdl2/test/testyuv.c b/vs/sdl2/test/testyuv.c index e7373a8b12..e9038ed0d3 100644 --- a/vs/sdl2/test/testyuv.c +++ b/vs/sdl2/test/testyuv.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga 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,7 +75,7 @@ static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_bool result = SDL_FALSE; rgb = (Uint8 *)SDL_malloc(size); - if (rgb == NULL) { + if (!rgb) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory"); return SDL_FALSE; } @@ -126,7 +126,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch) int yuv1_pitch, yuv2_pitch; int result = -1; - if (pattern == NULL || yuv1 == NULL || yuv2 == NULL) { + if (!pattern || !yuv1 || !yuv2) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate test surfaces"); goto done; } @@ -327,7 +327,7 @@ int main(int argc, char **argv) filename = "testyuv.bmp"; } original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24, 0); - if (original == NULL) { + if (!original) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); return 3; } @@ -339,7 +339,7 @@ int main(int argc, char **argv) pitch = CalculateYUVPitch(yuv_format, original->w); converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format); - if (converted == NULL) { + if (!converted) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError()); return 3; } @@ -356,13 +356,13 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, original->w, original->h, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 4; } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); return 4; } diff --git a/vs/sdl2/test/testyuv_cvt.c b/vs/sdl2/test/testyuv_cvt.c index 3bd2df3ff0..d78e5b1964 100644 --- a/vs/sdl2/test/testyuv_cvt.c +++ b/vs/sdl2/test/testyuv_cvt.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/testyuv_cvt.h b/vs/sdl2/test/testyuv_cvt.h index 781b632ea7..fa736be3c3 100644 --- a/vs/sdl2/test/testyuv_cvt.h +++ b/vs/sdl2/test/testyuv_cvt.h @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/torturethread.c b/vs/sdl2/test/torturethread.c index 1976800f0a..b612cda497 100644 --- a/vs/sdl2/test/torturethread.c +++ b/vs/sdl2/test/torturethread.c @@ -1,5 +1,5 @@ /* - Copyright (C) 1997-2023 Sam Lantinga + Copyright (C) 1997-2024 Sam Lantinga This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages diff --git a/vs/sdl2/test/watcom.mif b/vs/sdl2/test/watcom.mif index 2189fd49c2..aa15f66954 100644 --- a/vs/sdl2/test/watcom.mif +++ b/vs/sdl2/test/watcom.mif @@ -53,12 +53,13 @@ TASRCS = testautomation.c & testautomation_audio.c testautomation_clipboard.c & testautomation_events.c testautomation_guid.c & testautomation_hints.c testautomation_joystick.c & - testautomation_keyboard.c testautomation_main.c & - testautomation_math.c testautomation_mouse.c & - testautomation_pixels.c testautomation_platform.c & - testautomation_rect.c testautomation_render.c & - testautomation_rwops.c testautomation_sdltest.c & - testautomation_stdlib.c testautomation_surface.c & + testautomation_keyboard.c testautomation_log.c & + testautomation_main.c testautomation_math.c & + testautomation_mouse.c testautomation_pixels.c & + testautomation_platform.c testautomation_rect.c & + testautomation_render.c testautomation_rwops.c & + testautomation_sdltest.c testautomation_stdlib.c & + testautomation_subsystems.c testautomation_surface.c & testautomation_syswm.c testautomation_timer.c & testautomation_video.c @@ -69,8 +70,6 @@ TNOBJS = $(TNSRCS:.c=.obj) all: testutils.lib $(TARGETS) -.c: ../src/test - .obj.exe: wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ @@ -82,6 +81,9 @@ testvulkan.obj: testvulkan.c # new vulkan headers result in lots of W202 warnings wcc386 $(CFLAGS) -wcd=202 -fo=$^@ $< +testautomation_stdlib.obj: testautomation_stdlib.c + wcc386 $(CFLAGS) -wcd=201 -fo=$^@ $< + testautomation.exe: $(TAOBJS) wlink SYS $(SYSTEM) libpath $(LIBPATH) lib {$(LIBS)} op q op el file {$<} name $@ @@ -106,14 +108,14 @@ testutils.lib: testutils.obj check: .SYMBOLIC $(TESTS) @set SDL_AUDIODRIVER=dummy @set SDL_VIDEODRIVER=dummy - @copy "../SDL2.dll" . + @copy ..\SDL2.dll . @for %exe in ($(TESTS)) do %exe check-quick: .SYMBOLIC $(TESTS) @set SDL_TESTS_QUICK=1 @set SDL_AUDIODRIVER=dummy @set SDL_VIDEODRIVER=dummy - @copy "../SDL2.dll" . + @copy ..\SDL2.dll . @for %exe in ($(TESTS)) do %exe clean: .SYMBOLIC From fcf88b87532685318ab544d2bdf6378087ff0fd4 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Mon, 1 Jul 2024 22:41:29 +0900 Subject: [PATCH 2/4] Reapply DOSBox-X specific patches to SDL2 library --- vs/sdl2/configure.ac | 22 +++--- vs/sdl2/include/SDL_config_windows.h | 4 ++ vs/sdl2/include/SDL_keyboard.h | 1 + vs/sdl2/include/SDL_main.h | 10 ++- vs/sdl2/include/SDL_version.h | 3 + .../src/joystick/windows/SDL_xinputjoystick.c | 10 ++- vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m | 72 ++++++++++++++++++- .../src/video/windows/SDL_windowskeyboard.c | 65 ++++++++++++----- 8 files changed, 148 insertions(+), 39 deletions(-) diff --git a/vs/sdl2/configure.ac b/vs/sdl2/configure.ac index 67ef7ebfce..6fc39c351f 100644 --- a/vs/sdl2/configure.ac +++ b/vs/sdl2/configure.ac @@ -1620,22 +1620,16 @@ CheckNoErrorDeprecatedDeclarationsWerror() dnl See if GCC's -Wdeclaration-after-statement is supported. dnl This lets us catch things that would fail on a C89 compiler when using dnl a modern GCC. +dnl EDIT 2023/04/01 DOSBox-X: We don't care about ancient compilers. A compiler +dnl that old doesn't support C++ and even if it did, it wouldn't be new enough +dnl for this code base. We have to disable this because this is preventing +dnl DOSBox-X from compiling with the latest XCode on ARM-based Macbooks because +dnl the *.m files have variable declarations after statements. At no point is +dnl this code going to compile itself like it's 1993. Come on guys. --J.C. CheckDeclarationAfterStatement() { - AC_MSG_CHECKING(for GCC -Wdeclaration-after-statement option) - have_gcc_declaration_after_statement=no - - save_CFLAGS="$CFLAGS" - CFLAGS="$save_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - int x = 0; - ]],[])], [have_gcc_declaration_after_statement=yes],[]) - AC_MSG_RESULT($have_gcc_declaration_after_statement) - CFLAGS="$save_CFLAGS" - - if test x$have_gcc_declaration_after_statement = xyes; then - EXTRA_CFLAGS="$EXTRA_CFLAGS -Wdeclaration-after-statement -Werror=declaration-after-statement" - fi +dnl We don't care about C89 compilers. + true } dnl See if GCC's -Wall is supported. diff --git a/vs/sdl2/include/SDL_config_windows.h b/vs/sdl2/include/SDL_config_windows.h index aae52ebc63..cd04819d90 100644 --- a/vs/sdl2/include/SDL_config_windows.h +++ b/vs/sdl2/include/SDL_config_windows.h @@ -299,6 +299,9 @@ typedef unsigned int uintptr_t; #define SDL_VIDEO_RENDER_D3D12 1 #endif +#if defined(__WIN32__) && (defined(__arm__) || defined(__arm64__) || defined(_M_ARM) || defined(_M_ARM64)) +#define NO_OPENGL /* Don't enable for DOSBox-X on Windows ARM */ +#else /* Enable OpenGL support */ #ifndef SDL_VIDEO_OPENGL #define SDL_VIDEO_OPENGL 1 @@ -318,6 +321,7 @@ typedef unsigned int uintptr_t; #ifndef SDL_VIDEO_OPENGL_EGL #define SDL_VIDEO_OPENGL_EGL 1 #endif +#endif /* Enable Vulkan support */ #define SDL_VIDEO_VULKAN 1 diff --git a/vs/sdl2/include/SDL_keyboard.h b/vs/sdl2/include/SDL_keyboard.h index 03c7b5a370..9158d09ad2 100644 --- a/vs/sdl2/include/SDL_keyboard.h +++ b/vs/sdl2/include/SDL_keyboard.h @@ -208,6 +208,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); * \sa SDL_GetScancodeName */ extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); +extern DECLSPEC SDL_bool SDLCALL SDL_IM_Composition(int more); // Added for DOSBox-X /** * Get a human-readable name for a key. diff --git a/vs/sdl2/include/SDL_main.h b/vs/sdl2/include/SDL_main.h index a66c84b4e5..784e77f42a 100644 --- a/vs/sdl2/include/SDL_main.h +++ b/vs/sdl2/include/SDL_main.h @@ -143,6 +143,12 @@ #define main SDL_main #endif +#ifdef __cplusplus +#define SDL_MAIN_NOEXCEPT noexcept(false) // Added for DOSBox-X +#else +#define SDL_MAIN_NOEXCEPT // Added for DOSBox-X +#endif + #include "begin_code.h" #ifdef __cplusplus extern "C" { @@ -152,8 +158,8 @@ extern "C" { * The prototype for the application's main() function */ typedef int (*SDL_main_func)(int argc, char *argv[]); -extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); - +//extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); +extern SDLMAIN_DECLSPEC int SDL_main(int argc, char* argv[]) SDL_MAIN_NOEXCEPT; // Changed for DOSBox-X /** * Circumvent failure of SDL_Init() when not using SDL_main() as an entry diff --git a/vs/sdl2/include/SDL_version.h b/vs/sdl2/include/SDL_version.h index d05fed77c2..bd33871a9e 100644 --- a/vs/sdl2/include/SDL_version.h +++ b/vs/sdl2/include/SDL_version.h @@ -36,6 +36,9 @@ extern "C" { #endif +/* This is the DOSBox-X's modified SDL 2.x with IME support, not the general library */ +#define SDL_DOSBOX_X_IME 1 + /** * Information about the version of SDL in use. * diff --git a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c index 1ae7fb4899..0551b4e2f1 100644 --- a/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c +++ b/vs/sdl2/src/joystick/windows/SDL_xinputjoystick.c @@ -368,9 +368,13 @@ static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE *pXIn SDL_PrivateJoystickAxis(joystick, 0, pXInputState->Gamepad.sThumbLX); SDL_PrivateJoystickAxis(joystick, 1, ~pXInputState->Gamepad.sThumbLY); - SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); - SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX); - SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY); + //SDL_PrivateJoystickAxis(joystick, 2, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); + //SDL_PrivateJoystickAxis(joystick, 3, pXInputState->Gamepad.sThumbRX); + //SDL_PrivateJoystickAxis(joystick, 4, ~pXInputState->Gamepad.sThumbRY); + // Fixes for DOSBox-X + SDL_PrivateJoystickAxis(joystick, 2, pXInputState->Gamepad.sThumbRX); + SDL_PrivateJoystickAxis(joystick, 3, ~pXInputState->Gamepad.sThumbRY); + SDL_PrivateJoystickAxis(joystick, 4, ((int)pXInputState->Gamepad.bLeftTrigger * 257) - 32768); SDL_PrivateJoystickAxis(joystick, 5, ((int)pXInputState->Gamepad.bRightTrigger * 257) - 32768); for (button = 0; button < (Uint8)SDL_arraysize(s_XInputButtons); ++button) { diff --git a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m index 605a4d4fcf..3d65456bc6 100644 --- a/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m +++ b/vs/sdl2/src/video/cocoa/SDL_cocoakeyboard.m @@ -33,11 +33,30 @@ /*#define DEBUG_IME NSLog */ #define DEBUG_IME(...) +#if 1 // inserted for DOSBox-X +@interface IMETextView : NSView +@property (nonatomic, copy) NSAttributedString *text; +@end + +@implementation IMETextView +- (void)drawRect:(NSRect)dirtyRect +{ + CGSize size; + [super drawRect:dirtyRect]; + size = [_text size]; + [[NSColor whiteColor] set]; + NSRectFill(self.bounds); + [_text drawInRect:CGRectMake(0, 0, size.width, size.height)]; +} +@end +#endif + @interface SDLTranslatorResponder : NSView { NSString *_markedText; NSRange _markedRange; NSRange _selectedRange; SDL_Rect _inputRect; + IMETextView *_markedLabel; // inserted for DOSBox-X } - (void)doCommandBySelector:(SEL)myselector; - (void)setInputRect:(const SDL_Rect *)rect; @@ -72,6 +91,8 @@ - (void)insertText:(id)aString replacementRange:(NSRange)replacementRange } SDL_SendKeyboardText(str); + [_markedLabel setHidden:YES]; // inserted for DOSBox-X + _markedLabel.text = nil; // inserted for DOSBox-X } - (void)doCommandBySelector:(SEL)myselector @@ -97,9 +118,21 @@ - (NSRange)selectedRange return _selectedRange; } +static SDL_bool ime_incompos = 0; // inserted for DOSBox-X +static long end_ticks = 0; // inserted for DOSBox-X + - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { if ([aString isKindOfClass:[NSAttributedString class]]) { +#if 1 // inserted for DOSBox-X + CGSize size; + [aString addAttribute:NSFontAttributeName value:[NSFont systemFontOfSize:_inputRect.h] range:NSMakeRange(0, [aString length])]; + _markedLabel.text = aString; + size = [aString size]; + [_markedLabel setFrameSize:size]; + [_markedLabel setHidden:NO]; + [_markedLabel setNeedsDisplay:YES]; +#endif aString = [aString string]; } @@ -124,11 +157,34 @@ - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replaceme - (void)unmarkText { - _markedText = nil; - + //[_markedText release]; // Maybe required for DOSBox-X + _markedText = nil; + [_markedLabel setHidden:YES]; // inserted for DOSBox-X SDL_SendEditingText("", 0, 0); } +#if 1 // inserted for DOSBox-X +#define IME_END_CR_WAIT 25 +SDL_bool SDL_IM_Composition(int more) { + return ime_incompos||(end_ticks&&(TickCount()-end_ticks #ifndef SDL_DISABLE_WINDOWS_IME +static Uint32 end_ticks = 0; // added for DOSBox-X +static SDL_bool ime_incompos; // added for DOSBox-X static void IME_Init(SDL_VideoData *videodata, HWND hwnd); static void IME_Enable(SDL_VideoData *videodata, HWND hwnd); static void IME_Disable(SDL_VideoData *videodata, HWND hwnd); @@ -39,6 +41,18 @@ static void IME_Quit(SDL_VideoData *videodata); static SDL_bool IME_IsTextInputShown(SDL_VideoData *videodata); #endif /* !SDL_DISABLE_WINDOWS_IME */ +#if 1 // Added for DOSBox-X +SDL_bool SDL_IM_Composition(int more) { + (void)more; +#ifndef SDL_DISABLE_WINDOWS_IME +#define IME_END_CR_WAIT 50 + return ime_incompos || end_ticks && (GetTickCount() - end_ticks < IME_END_CR_WAIT) ? SDL_TRUE : SDL_FALSE; +#else + return SDL_FALSE; +#endif +} +#endif + #ifndef MAPVK_VK_TO_VSC #define MAPVK_VK_TO_VSC 0 #endif @@ -249,27 +263,18 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) himc = ImmGetContext(videodata->ime_hwnd_current); if (himc) { + /* //reverted for DOSBox-X COMPOSITIONFORM cof; CANDIDATEFORM caf; - - cof.dwStyle = CFS_RECT; - cof.ptCurrentPos.x = videodata->ime_rect.x; - cof.ptCurrentPos.y = videodata->ime_rect.y; - cof.rcArea.left = videodata->ime_rect.x; - cof.rcArea.right = (LONG)videodata->ime_rect.x + videodata->ime_rect.w; - cof.rcArea.top = videodata->ime_rect.y; - cof.rcArea.bottom = (LONG)videodata->ime_rect.y + videodata->ime_rect.h; - ImmSetCompositionWindow(himc, &cof); - - caf.dwIndex = 0; - caf.dwStyle = CFS_EXCLUDE; - caf.ptCurrentPos.x = videodata->ime_rect.x; - caf.ptCurrentPos.y = videodata->ime_rect.y; - caf.rcArea.left = videodata->ime_rect.x; - caf.rcArea.right = (LONG)videodata->ime_rect.x + videodata->ime_rect.w; caf.rcArea.top = videodata->ime_rect.y; caf.rcArea.bottom = (LONG)videodata->ime_rect.y + videodata->ime_rect.h; ImmSetCandidateWindow(himc, &caf); + */ + COMPOSITIONFORM cf; + cf.ptCurrentPos.x = videodata->ime_rect.x; + cf.ptCurrentPos.y = videodata->ime_rect.y; + cf.dwStyle = CFS_FORCE_POSITION; + ImmSetCompositionWindow(himc, &cf); ImmReleaseContext(videodata->ime_hwnd_current, himc); } @@ -415,11 +420,14 @@ static void IME_Init(SDL_VideoData *videodata, HWND hwnd) videodata->ime_available = SDL_TRUE; IME_UpdateInputLocale(videodata); IME_SetupAPI(videodata); + // Disabled because the candidate window will not be displayed. (for DOSBox-X) + /* if (WIN_ShouldShowNativeUI()) { videodata->ime_uiless = SDL_FALSE; } else { videodata->ime_uiless = UILess_SetupSinks(videodata); } + */ IME_UpdateInputLocale(videodata); IME_Disable(videodata, hwnd); } @@ -1018,17 +1026,37 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S case WM_INPUTLANGCHANGE: IME_InputLangChanged(videodata); break; +#if 1 // added for DOSBox-X + case WM_IME_CHAR: + if(wParam == 0x20) { + // enable IME input space + PostMessage(hwnd, WM_KEYDOWN, 0x20, 0x390001); + } + else if(wParam == 0x3000) { + // input Zenkaku space + videodata->ime_composition[0] = 0x3000; + videodata->ime_composition[1] = 0; + IME_SendEditingEvent(videodata); + IME_SendInputEvent(videodata); + } + trap = SDL_TRUE; + break; +#endif case WM_IME_SETCONTEXT: + // Disabled because the string being converted will not be displayed. (for DOSBox-X) + /* if (videodata->ime_uiless) { *lParam = 0; } break; + */ case WM_IME_STARTCOMPOSITION: videodata->ime_suppress_endcomposition_event = SDL_FALSE; - trap = SDL_TRUE; + ime_incompos = 1; /* added for DOSBox-X */ + //trap = SDL_TRUE; /* disabled for DOSBox-X */ break; case WM_IME_COMPOSITION: - trap = SDL_TRUE; + //trap = SDL_TRUE; /* disabled for DOSBox-X */ himc = ImmGetContext(hwnd); if (*lParam & GCS_RESULTSTR) { videodata->ime_suppress_endcomposition_event = SDL_TRUE; @@ -1047,6 +1075,7 @@ SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, S ImmReleaseContext(hwnd, himc); break; case WM_IME_ENDCOMPOSITION: + ime_incompos = 0; /* added for DOSBox-X */ videodata->ime_uicontext = 0; videodata->ime_composition[0] = 0; videodata->ime_readingstring[0] = 0; From 0bbbf8a971f7d7d29a7c79f5ba5a2de019cc279f Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:21:00 +0900 Subject: [PATCH 3/4] Fix SDL_ttf compile error due to SDL2 update to 2.30.4 --- vs/sdl2/include/begin_code.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vs/sdl2/include/begin_code.h b/vs/sdl2/include/begin_code.h index a47a7d2b64..124ff7cb7d 100644 --- a/vs/sdl2/include/begin_code.h +++ b/vs/sdl2/include/begin_code.h @@ -36,8 +36,8 @@ #ifndef SDL_DEPRECATED # if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */ # define SDL_DEPRECATED __attribute__((deprecated)) -# elif defined(_MSC_VER) -# define SDL_DEPRECATED __declspec(deprecated) +//# elif defined(_MSC_VER) +//# define SDL_DEPRECATED __declspec(deprecated) /* Revert this change due to compile error of SDL_ttf */ # else # define SDL_DEPRECATED # endif From 30a7dd36e670b3817c7a49d5e8010314d12d0e79 Mon Sep 17 00:00:00 2001 From: maron2000 <68574602+maron2000@users.noreply.github.com> Date: Tue, 2 Jul 2024 08:54:00 +0900 Subject: [PATCH 4/4] Update SDL.vcxproj --- vs/sdl2/VisualC/SDL/SDL.vcxproj | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/vs/sdl2/VisualC/SDL/SDL.vcxproj b/vs/sdl2/VisualC/SDL/SDL.vcxproj index 5c3e931792..696459e679 100644 --- a/vs/sdl2/VisualC/SDL/SDL.vcxproj +++ b/vs/sdl2/VisualC/SDL/SDL.vcxproj @@ -534,6 +534,7 @@ + @@ -591,7 +592,6 @@ - @@ -636,7 +636,13 @@ + + + + + + @@ -691,6 +697,7 @@ + @@ -698,6 +705,7 @@ + @@ -819,7 +827,9 @@ - + + + @@ -827,4 +837,4 @@ - \ No newline at end of file +