Squashed 'external/sdl/SDL/' changes from 399bc709b7..0d7df16812
0d7df16812 Timers are a required platform feature 518b070aa9 Fixed drop event coordinate conversion 3ca8cee874 Sync SDL3 wiki -> header 8bf74280e0 docs: Note SDL_UpdateWindowSurfaceRects can update beyond specified areas. 9408299bad Set the number of audio devices to 0 if audio hasn't been initialized be0ba78c56 Convert the coordinates in drop events as well (thanks @Dragon-Baroque!) e6c8872fdc Fixed bug #7614: Segmentation Fault in SDL_BlitSurface ce0e0675de Fixed bug #8301 - Software renderer draws long lines incorrectly / SDL_RENDERLINEMETHOD_GEOMETRY 6e48d4532c Added raw input device handle for WM_INPUT mouse button handling cf5e0637b5 Touchpads already have their right/left buttons swapped in raw input fb2d7ed83e Restore window minimum and maximum size if it is recreated 915afae514 Remove force using one thread 64a3e2d17d Remove ps2_driver from workflow 464a41411e Sync SDL3 wiki -> header 4f3d4bd110 wayland: Add the ability to import and wrap external surfaces 99f6bcf504 Sync SDL3 wiki -> header 3a4ac15a27 Make Xbox GDK code public (and fix some GDK code rot) (#8844) 649556befa win32: Let windows manage the floating state unless explicitly overridden d4a9748740 win32: Fix test failures 101f903bb1 testgeometry: allow to use arrows to move the triangle 4033a0a83b Prevent ASAN warning: like SDL_triangle.c:305:30: runtime error: left shift of negative value -672 (even if the value was correctly computed) f0b9c7f0f0 Let Windows track floating window state 98be55894e Moved window state change handling from WM_WINDOWPOSCHANGING to WM_WINDOWPOSCHANGED 7efeb36131 Pass the frame DPI to WIN_AdjustWindowRectForHWND() e4ee1cade7 Revert "SDL_windowsevents.c: fixed -Werror=unused-variable" f8cce4ead4 SDL_windowsevents.c: fixed -Werror=unused-variable 277fded7ba Refactor AdjustWindowRectEx() into WIN_AdjustWindowRectForHWND() 312160935d Removed deprecated use of __IPHONEOS__ (thanks @Dragon-Baroque!) 483155bbf9 Fixed borderless window client area calculation cf0d1d7234 Fixed ASAN warning, runtime error: left shift of 160 by 24 places cannot be represented in type 'int' 0c6b070761 Capture debug macros off by default b5bc64aa55 Fixed pause key on Windows (thanks Mikhail!) d766f68cb3 Fix compile error with XInputOnGameInput.h ec2159d492 tests: Clean up the window creation properties in the Wayland custom surface example 9a77813df0 WinMain is specified by the Win32 API as having extern "C" linkage 6407e0cc37 Added attribution for GIP protocol handling (thanks @medusalix!) 3a219caf3d wayland: Restore accidentally removed line of code ccae9c1ef6 Only initialize audio drivers that have been requested 590d0bec6f Revert "Make sure new windows have mouse and keyboard focus if there's no windowing system" 5948ea997f Make sure new windows have mouse and keyboard focus if there's no windowing system 05d18aab1c Sync SDL3 wiki -> header 4b6df89238 wayland: Add a property to allow creation of a wl_egl_window object even if OpenGL is not enabled f7dd0f9491 wayland: Allow the creation of roleless window surfaces for custom application use 4417250d0d wayland: Remove the registry from the window properties 392796e49c wayland: Eliminate redundant protocol checks 82f2c4d581 render: Renamed SDL_GetTextureRenderer to SDL_GetRendererFromTexture. 95066ce2a0 Sync SDL3 wiki -> header df438a3170 opengl: OpenGL renderers need to support texture target in properties. 8e7c0b34d7 test: If SDL_CreateRenderer() fails, say why 022ff075b9 test: When listing test-cases, say which ones are disabled 44adab7dfd Sync SDL3 wiki -> header 059fb560ba gamepad: Clarify range and direction of axes 4942027117 Sync SDL3 wiki -> header e056f52f7d include: Remove string literals from properties documentation. e8c595af5c Sync SDL3 wiki -> header adef35b9ec include: Attempt to make new properties documentation wiki bridge friendly. 4ffec098b7 Sync SDL3 wiki -> header 9bc7cfc755 render: Added SDL_GetTextureRenderer(). 7eae08cfc4 Removed SDL_GL_BindTexture() and SDL_GL_UnbindTexture() 4d5bffc323 Sync SDL3 wiki -> header 1a13dae219 Added constant definitions for SDL properties 3deefa6b43 Updated documentation for SDL_HINT_SHUTDOWN_DBUS_ON_QUIT 2348e8b6a2 Add hint to make SDL handle dbus_shutdown() d3daba791a Don't try to send the PS third-party feature request to the Logitech G815 keyboard 014a63b4b5 Renamed ShowTextInput/HideTextInput to ShowScreenKeyboard/HideScreenKeyboard on Android 3a9a52fe6c updateKeyboard should use the SDL window's screen instead of the view window's screen, which may be nil. e100992c17 Added mapping for the RX Gamepad, e.g. Pandora Box 7 139a0931a3 Fix memory barriers on ARMv5 21c80ac843 Added a practical example of confirm/cancel gamepad button handling 787a15f760 Fix Mac child windows that are created hidden showing if their parent window is shown d6b1fc9576 Add SDL_MAC_REGISTER_ACTIVATION_HANDLERS hint to allow disabling the normal application startup/activation/deactivation handlers 7c5e694022 Ignore a new warning in Visual Studio 2022 73d02184d7 docs: Add Wayland to the SysWM migration example c03c01e9b2 Make sure we get mouse events as soon as possible 5cbdeab799 Rename SDL_mslibc_x64.asm -> SDL_mslibc_x64.masm ed62d6e7de cocoa: Set the titled flag on fullscreen space windows b4b5dbd92f testcontroller.c: fixed warnings. 31851a50d2 Fixed dropping raw input because of mixing GetRawInputBuffer() and WM_INPUT handling 987744aae8 Fix Duplicated includes 2b369a14ab Fixed allocation and alignment of raw input buffers bec1b8f849 Add basic rumble support to Steam Deck 8fe4a45edf Use GetRawInputBuffer() instead processing raw input one at a time 87b8f09657 Fixed warning: no previous prototype for function 'SDL_PrivateGetGamepadButtonFromString' [-Wmissing-prototypes] c2951655ff Fixed warning: missing field 'window' initializer [-Wmissing-field-initializers] 5b3ee51c6c Updated copyright for 2024 a7b79c483c Remove unused 'window' variable from -[Cocoa_WindowListener windowWillExitFullScreen] dd2d809407 AndroidShowToast: make OneShotTask members private final 44c2f344d6 Fixed build 2faae8457d The C standard defines a boolean expression as a signed integer value. e3d50619f8 Fixed fatal error: SDL_pen.h: No such file or directory dfe1a37bab Fixed error: 'static' is not at beginning of declaration [-Werror=old-style-declaration] 423b1fafcd Fixed warning C4047: 'function': '__x_ABI_CWindows_CGaming_CInput_CIRawGameController **' differs in levels of indirection from '__x_ABI_CWindows_CGaming_CInput_CIRawGameController *' 7681695875 Revert "Fixed signed/unsigned warnings with Visual Studio when comparing SDL_bool with boolean expressions" 8f94102b04 tests: Use unsigned format specifiers for printing flags 5d0c893723 wayland: Remove bitfield specifiers from boolean values 530b41d531 Fixed warnings in SDL_pen.c 9906d6d3bc Fixed warning C4244: '=': conversion from 'SDL_bool' to 'Uint8', possible loss of data ebd7f9adbd Fixed warning C4245: 'initializing': conversion from 'int' to 'Uint32', signed/unsigned mismatch in SDL_video.c dc1c27885e Fixed warning C4389: '!=': signed/unsigned mismatch in SDL_blit.c e813c72b3c Fixed warning C4245: 'return': conversion from 'int' to 'SDL_JoystickID', signed/unsigned mismatch dce626f469 Fixed warning C4244: 'function': conversion from 'int' to 'Uint16', possible loss of data 7f376277e5 Fixed warning C4244: 'initializing': conversion from 'SDL_bool' to 'Uint8', possible loss of data 61db102da9 Fixed signed/unsigned warnings with Visual Studio when comparing SDL_bool with boolean expressions d71454da17 Store the surface properties in the reserved pointer of a surface b6a92c113f wayland: Don't apply old libdecor window dimensions 39e24e52c8 Fixed example of creating a window with properties dc450ba908 Added an example of creating a window with position ce4fe32ce3 Added documentation for getting the X11 display from an SDL window 327d31a5d9 Added documentation for getting the NSWindow from an SDL window 3976bbef2a Added documentation for getting the X11 window from an SDL window ffb8515c21 Use the Valve code name for the Steam Deck controller 43c40d30a2 Added comment for the BDA Pro Ex controller 61704b5862 Removed an assertion it's possible to hit c24b33d8d9 Fixed building with older Windows SDK 70ba3f2830 Report the D-Pad for HIDAPI gamepads as a hat ce329d60e4 Added support for alpha blending using palette alpha 9c3e831e33 uikit: Send fullscreen enter/leave events 5df3eac925 Sync SDL3 wiki -> header 0dfdf1f3f2 Fixed crash if joystick functions are passed a NULL joystick 4ce935b910 Fix static build with libdecor 0.2.0 5d6d149862 Allow passing in `extrainfo` value to `GetMouseMessageSource()` e0df963ef0 Fix wrong bit count in comment c2a55cd2c5 Add missing `(void)` in functions params a3c8f2f6cb Consolidate mouse-touch event checking logic d747daf03d Use correct touch check flag a961066d0b Add basic touch/finger support to `testpen.c` a3b5eb07b2 Removed extern "C" linkage from main() declaration 50e309bb17 Include SDL_events.h in SDL_main.h cae657140c Add Access Controller 74418e1aa8 Made the cursor list check a compile time assert instead of a runtime one d6fb0d91d8 Added testpen to the Visual Studio solution bbdd41f287 Fix windows touch using wrong axis for normalisation a28ac29aa0 Add missing cursor types 6daf2e943f Try SDL_UDEV_deviceclass to detect joysticks even if in a container 1bf78ed544 We get a resize event when the view enters fullscreen mode on iOS e3b5999bb4 Use the application requested size to determine automatic orientation on iOS 278e3f9184 Whoops, fixed setting fullscreen flag 69e60e0f1b Fixed setting fullscreen mode on iOS 0e5ea3cc4b Fixed infinite recursion when adding an accelerometer as joystick on iOS c3d84c3342 Record the initial input report mode and only restore simple mode if that's what we started with 10a8b750a0 Use common generic syscond for platforms with no cond implementation 4914e5bb78 PS2 use WaitSemaEx for waiting for semaphore with timeout bb0e0ae080 Added a runtime check for BLUETOOTH_CONNECT in addition to BLUETOOTH (thanks @perepujal!) 312f98c2a1 Make sure the string is terminated, fixed invalid read in SDL_PrivateParseGamepadConfigString() 199f7cc3b1 x11: Ignore border extents when the border hint is unset 07e9603398 Sync SDL3 wiki -> header ffd82fb7c4 Add scaleMode to SDL_SoftStretch(), remove SDL_SoftStretchLinear(). 5dba04b29b Remove SDL_{Set,Get}SurfaceScale(). Add Scale parameter to SDL_BlitSurfaceScaled() and SDL_BlitSurfaceScaledUnchecked() (see #8732) e66896406d cocoa: Set appropriate flags on fullscreen spaces windows 57fcb9044c video: Remove more assumptions about window state in the video layer cb90653695 win32: use USER_DEFAULT_SCREEN_DPI instead of explicit 96 value a2e05480d6 Use crc16 return value when calculating GUID 2ad50e9675 Make the SDL3 surface ABI compatible with SDL2 f72d6a7fd9 Use more verbose names for properties, to match upcoming public property names 1f1ee6f77c Use the original manufacturer and product strings for the joystick CRC 4bb5e1f0f9 Added migration notes for migrating Steam Input support from SDL2 to SDL3 56f111dffc Fix compilation / same as sdl2-compat 72c366bf3d Fixed whitespace 3152b98e87 win32: minor fixup in WIN_UpdateKeymap() 2c4360ce8f Sync SDL3 wiki -> header c981a597dc Added Steam Input API support for game controllers a8f4f40d08 Sync more Steam Controller header definitions for the Steam Deck e6e54b22c8 Ignore all surface comparison output files in the testautomation directory 9d13be743b Make sure we're rendering whenever the activity might be visible, even if we don't have focus. 69ec0322d3 win32: Make leaving fullscreen when the window already isn't fullscreen a no-op 8f79e0b7f8 win32: Fix high-DPI debug logging a4496f7dcf Update doc: SDL_SoftStretch() and SDL_SoftStretchLinear() #8667 43309d38ed joystick: Extract 0x02a9 and 0x0291 PIDs into separate defines. 84a0d5f623 Added SDL_SetSurfaceScaleMode() and SDL_GetSurfaceScaleMode() to control scale mode using SDL_BlitSurfaceScaled() 4d5949dcf6 Added a controller name for the Steam virtual gamepad 695846f2ed Pass through the name of the controller for the XInput mapping 1745289b1b x11: Don't move the window when restoring and ensure that resize and position events are sent when entering or leaving fullscreen 08a7ca4d53 XInput: Use XInputGetCapabilitiesEx instead of fragile GuessXInputDevice 7f75178908 Verify that the %p format specifier works for 64-bit pointers 72b7acfe8a Don't create a TLS error buffer if we're just clearing the error 240e7747c8 Fix #8702: Add SDL_hidapi_steamdeck.c to Xcode target b937c54b66 win32: Set all size and position variables for external windows 8c285828e5 Fixed return value for SDL_UDEV_AddCallback() cbf9012c74 Fixed build 5547007915 Added test for inverted cursor 0ab13f2498 joystick: fixup for Wireless Xbox 360 Controller VID/PID detection in WGI backend. 627d134b9e Add support for monochrome cursors with inverted pixels under Windows. 21879faf48 wayland: Handle mouse focus when receiving touch events 58a5f5cbe8 Allow sendCommand() to be overridden by derived classes e6d8ef1a5b Revert "Back out Steam virtual gamepad changes" b0e7b7db6f Don't unload graphics libraries until after the window has been destroyed. 69288038ed Refactor away some additional integer types. f3048e3cd2 Add new file to vcxproj files. 5a21febecb Add new steam deck HIDAPI controller to controller database. 67d44c1017 Disable lizard mode while steam deck HID device is opened. 6dd6827343 Translate steam deck HID reports to SDL events. 94f621e030 Implement steam deck HIDAPI initialization. c1a7d0f96e Add steam deck detection and HIDAPI driver scaffold. 0baee3e676 Reversed test to be easier to read, more efficient, and match other code bddbd1e317 cocoa: Check the resizable flag along with zoomed status when resizing 835c733f4d video: Only sync when programmatically entering/exiting fullscreen c790572674 Use existing XUSB driver software PID 0x02a1 instead of PID 0x02fe 581d1cab25 You should call present when using a software renderer as well. 5173b0c2cc Make built-in joystick device lists extendable by using hints 34eb24ebc4 Back out Steam virtual gamepad changes 7529d25b2b Use the Steam virtual gamepad slot as the gamepad player index 445f08a0fb Print the gamepad player index when opening a gamepad 17723381da Sort Steam virtual gamepads by Steam controller slot f3d8a2def5 audio: Fixed resource leak in unlikely failure case during device add. 63ae84e140 x11: Improve sync algorithm 7e5511d3cd x11: Move unrelated variables out of XFixes #ifdef 3c5e9e6112 We can wait up to 500ms in onNativeSurfaceDestroyed(), so wait at least that long in onDestroy() 53cda988f4 Clear any errors from a previous run a197efe3a7 pen: fix leak caused by pen subsystem fbb0914b78 wayland+x11: free system cursors when quiting video 7484d02a2e testshape: use SDL_test to create multiple windows 20250aecc5 Sync SDL3 wiki -> header 4fd778119b video: Implement asynchronous windowing ace385a134 Revert "Fixed warning C33010: Unchecked lower bound for enum scancode used as index." e482f00a17 SDL_string.c (SDL_vsscanf): fix gcc build f00ecf5f19 Fixed building with older Windows SDK 7ca43995a1 Fixed warning C4028: formal parameter 1 different from declaration aab7432f5f Fixed analyze warnings for SDL_dynapi_procs.h c484140f56 Fixed warning C33010: Unchecked lower bound for enum scancode used as index. 02a116217d Fixed Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). 91da942b33 Fixed warning C28251: Inconsistent annotation for 'SDL_RWvprintf_REAL': this instance has no annotations. b8840801cc Fixed analyze warnings in SDL_xinputhaptic.c 8e0d728c67 Fixed warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). 6a736d7766 Fixed warning C6340: Mismatch on sign: 'unsigned char' passed as _Param_(2) when some signed type is required in call to 'SDL_SetError_REAL'. 1fcc75ba81 Fixed warning C6340: Mismatch on sign: 'unsigned char' passed as _Param_(4) when some signed type is required in call to 'SDL_snprintf_REAL'. 7f2e16db8b Fixed warning C6340: Mismatch on sign: 'const unsigned short' passed as _Param_(2) when some signed type is required in call to 'SDL_SetError_REAL'. 163de8e697 Fixed warning C6001: Using uninitialized memory 'rdi'. e29393e407 Fixed warning C6001: Using uninitialized memory 'devName'. 0f34ca2e71 Fixed analyze warnings in SDL_xinputjoystick.c 2b5c7db645 Fixed analyze warnings in SDL_render_d3d12.c a28769759b Fixed warning C26052: Potentially unconstrained access using expression '(signed char *)info' 6ee34380f4 Fixed warning C6011: Dereferencing NULL pointer 'viewport'. 230581f4a8 Fixed warning C26451: Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). 3775d9be4b Fixed warning C28251: Inconsistent annotation for 'SDL_LogMessageV_REAL': this instance has no annotations. b512182222 Fixed warning C6340: Mismatch on sign: 'unsigned int' passed as _Param_(2) when some signed type is required in call to 'SDL_SetError_REAL'. 8a82f7e837 Fixed warning C33005: VARIANT '&valueX' was provided as an _In_ or _InOut_ parameter but was not initialized fda039e6f8 Fixed analyzer warnings for SDL_string.c 22f44aefe7 Fixed warning C6340: Mismatch on sign: 'int' passed as _Param_(3) when some unsigned type is required in call to 'SDL_sscanf_REAL'. eab2d97d07 Fixed warning C26451: Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2). 41bfcad5d7 Fixed warning C6340: Mismatch on sign: 'unsigned short' passed as _Param_(2) when some signed type is required in call to 'SDL_SetError_REAL'. 54dc73aa88 Fixed warning C6386: Buffer overrun while writing to 'palette_saved_alpha': the writable size is 'sizeof(Uint8)*((palette_saved_alpha_ncolors))' bytes, but '2' bytes might be written. 0dad56354c Fixed warning C6326: Potential comparison of a constant with another constant. c9b243fb56 Fixed warning C6263: Using _alloca in a loop: this can quickly overflow stack. 4ccc53edfe Fixed warning C6011: Dereferencing NULL pointer 'display'. 3db4695ac7 warning C6340: Mismatch on sign: 'unsigned int' passed as _Param_(3) when some signed type is required in call to 'SDL_LogDebug_REAL'. c7d81d936a Fixed warning C6031: Return value ignored: 'GetKeyboardState'. 69b9d44bdc Fixed warning C26451: Arithmetic overflow: Using operator '-' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '-' to avoid overflow (io.2). a9b87ee201 Fixed warning C28159: Consider using 'GetTickCount64' instead of 'GetTickCount'. Reason: GetTickCount overflows roughly every 49 days. Code that does not take that into account can loop indefinitely. GetTickCount64 operates on 64 bit values and does not have that problem 21f273ecc7 Fixed warning C6255: _alloca indicates failure by raising a stack overflow exception. Consider using _malloca instead. 0c4cb3d153 Fixed warning C26451: Arithmetic overflow: Using operator '<<' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '<<' to avoid overflow (io.2). 06f8f9a891 Fixed warning C6326: Potential comparison of a constant with another constant. 3e54061fa8 Fixed warning C6011: Dereferencing NULL pointer 'SDL_disabled_events[hi]'. 226f8fde09 Fixed warning C28182: Dereferencing NULL pointer. 'streams[j]' contains the same NULL value as 'stream' did. fe6b3ab0b0 Fixed warning C6031: Return value ignored: 'CLSIDFromString'. f3b0149756 Fixed warning C26451: Arithmetic overflow: Using operator '*' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '*' to avoid overflow (io.2). 6cfce101fb Don't call the property cleanup function if setting the property fails 14380ec48a Fixed signed/unsigned comparison warning ac0751a652 Added SDL_strnstr() 7c71e72193 SDL_render: Call InvalidateCachedState to initialise some of driverdata values (eg '*_dirty' to 1). At the earliest place, immediatly after driverdata is set. (Doing it in SDL_render.c, after creation, would be too late, because there're renderers that already use/change those values in the CreateRender() function). 058213366b Make sure we use alpha of 0 when clearing a transparent window with no content ecd56bb8f0 Removed SDL_GetErrorMsg(), trivially implemented in application code 66e532fa61 Handle out of memory errors without any allocation 579681a372 fixed SDL_SCANCODE_LEFT array position in scancodes_windows.h 675423f096 Sync SDL3 wiki -> header 744a29b88f WGI: Cleanup code a bit (#8647) e4582e6edc Sync SDL3 wiki -> header df0fd55891 wikiheaders.pl: README files are no longer in Windows endline format. 1072b6e86e docs: fixed typo f184dea16c uikit: Patched to compile. 447b508a77 error: SDL's allocators now call SDL_OutOfMemory on error. 70b65d4170 cocoa: Resync modifier keypressed on NSEventTypeFlagsChanged event. d1b831e232 include: Clarified documentation for two functions. daa38dc793 touch: Replace GetNumTouchDevices/GetTouchDevice with a single function. dd47da8a5c gamepad: Replace GetNumMappings/GetMappingByIndex with a single function. dfee3f9e92 render: Replaced SDL_RenderFlush with SDL_FlushRenderer. eef5c53668 docs: Moved CREDITS and INSTALL to markdown format. f32575dfab docs: Convert everything to Unix-style endlines. c5daf8adb1 testcontroller: Don't query the mapping list until after they are available. df05d5eff4 Fix scroll wheel handling in testmouse 63d4bd4e57 SDL_SendKeyboardText: remove workaround from 1e12d7c, fix use of iscntrl fea6e7afb1 cmake: copy sources to binary directory in separate target 9faa7977bd UWP: Add support for supplementary Unicode characters input 7b628ea4d5 Win32: Simplify Unicode text input code 411c70abb1 Fix the target membership of SDL_pen.h (thanks kanjitalk755!) 3e6513c773 document the purpose of SDL_SetTextInputRect 1e12d7cfb6 Make sure we don't pass UTF-8 to SDL_iscntrl() 9a206adbee UWP: Use Windows.UI.Core.CoreDispatcher.AcceleratorKeyActivated event for keyboard 309ea2d5f9 UWP: Simplify Win32 scan code to SDL scan code mapping acc5bb89f8 [Win32] Better keyboard button mapping to SDL scan codes 6b28065e9e Reformat Win32 scan code table 7e86b6aef2 Win32: Fix keymap for keyboard layouts that can print UTF-16 surrogates and ligatures 08c6ac1b16 test: SDLTest_PrintEvent now reports key event mod state. 571e9796b9 Fixed the GameCube HIDAPI controller mapping dd984dcd9f Removed HIDAPI controller mappings 3817f5126e cocoa: Use `-[NSApplicationDelegate applicationSupportsSecureRestorableState]`. c5b0ff77d7 test: testwm2 now displays keyboard mod state. 5772e00c3f cmake: disable oss by default on OpenBSD, not FreeBSD ceac93ade2 Set framebuffer_srgb_capable to the actual value obtained (#8634) ed3fad1880 cmake: disable oss by default on Linux, NetBSD and FreeBSD 6bb40f1d8d SDL_VideoCapture: allow add/remove device at runtime on linux f0e47f8ee0 Added support for the NACON Revolution 5 Pro controller 2f806c89b5 initial import of hidapi netbsd uhid native backend from mainstream 1b284cd415 X11 pen detection: fix misclassification due to improper init c4ca64deaf ci: do 'brew update' & don't run dependent checks on installed things d486de6349 cmake: fixed iconv detection test program 42a8139fd6 render: Clip bresenham lines against a real viewport thing. 4a40a272bd render: Patched to compile. 983f178b7d render: Clip lines before Bresenham algorithm generates points. db7f6425d0 rect: Avoid numeric overflow on massive lines in SDL_IntersectRectAndLine. e548044a82 ci: add NetBSD to test matrix dd5b8db3a6 SDL_hidapi requires libusb >= 1.0.16 6ba90f7775 render: Batching is always enabled now! b24d6bd59a opengl: Creating a texture trashes the cached `texturing` state, fix it. dcf04559db render: GL-based renderers should treat adaptive vsync as vsync being enabled. 74a2542564 x11: Deal with difference in GLX_EXT_swap_control_tear behavior. 08fac5b1b2 SDL_PenModifyForWacomID: return zero as axis_flags upon failure. aaba01aee4 hidapi: syncing with mainstream: 5730eb67f0 add HAVE_GCC_DIAGNOSTIC_PRAGMA to SDL_internal.h, use it 42c8366fdc revise iconv detection: a45b371de0 cmake: create and install SDL3::Jar target for Android 53544cabaa psp: fix copy/paste error from SDL2 in PSP_VideoQuit(). 6cde96f9a0 psp: Hook up event subsystem init/quit. e9659f5738 Removed some function declarations that don't actually exist. 3264e64738 SDL_RunApp: Make sure argc/argv are stable if the caller didn't define them. eca79e38db Removed test shape images 81fc7ded78 Removed the window shape API for SDL 3.0 45938bbfa5 Corrected comment 059e550e98 Fix 3DS Analog Values (#8581) dbf14df80f Fix joysticks returning invalid device IDs d2db3f3993 ci: cache android ndk archive d6291d4d42 alloca: use alloca from <stdlib.h> on NetBSD f26a93211f SDL_bsdjoystick: fix -Wundef warning on FreeBSD d1def7f033 cmake: add openbsd wscons sources to build, if supported 86d77bbcc5 kmsdrm: restrict KMSDRM_ReleaseVT/KMSDRM_AcquireVT to SDL_INPUT_LINUXEV 94ad1a4ae4 SDL_bsdjoystick.c: fix -Wundef warning. e761770c24 No, this wasn't right b7d7e54895 Fixed uninitialized variable 119e02f314 Always use 'm' for controllers provided by the MFI joystick driver 75df4cc5c2 Don't tickle PS4 Bluetooth controllers in simple mode 0d431015bf Extract BMP magic into separate define 0413f6fc49 Use SDL_iscntrl() call instead of manual code that is doing the same (#8593) fd91178d7f Make size cursors be double arrows on Wayland 5e9b0820f3 Add cursors for X11/Wayland window resizing 91e122316c Use SDL_small_alloc() instead of SDL_stack_alloc() in CreateMaskBitmap() b76f8de298 Hit testing tweaks for X11 and Wayland (#8582) 5b1c68c2f3 testshader: Don't make local variables with the same name as GL entry points. 30a2291d59 Fixed compatibility with sdl2-compat (thanks @sezero!) 49d58bc73a Cleanup WIN_CreateCursor() code a bit 4722269fb6 tests: Print window occluded log events 5db781cc3d Use the correct pixel formats for OpenGL ES on big endian 05e7dcf8f8 Support returning <8bpp surfaces in SDL_LoadBMP_RW 773ec1cfcb Extend blitting support for all <8bpp formats 753bbd199e Add SDL_PIXELFORMAT_INDEX2LSB and SDL_PIXELFORMAT_INDEX2MSB fda69e5e79 Test both MSB and LSB indexed surfaces in testautomation 39870031d1 use format string attributes for functions accepting va_list params, too 666301f9f9 Fixed build with older macOS SDK 238987df3b Always use physicalInputProfile on OS versions that support it e424dcca4b More fixing the build with older macOS SDKs 4ebb0c6dac Revert "Fixed build" 7abacc9f9f Fixed build ac1f896f89 Fixed building with older macOS SDK 8043dad369 Fixed build warning 5c8c3931f2 Removed outdated information about SDL_GetWindowWMInfo() e0d0d140b2 Fixed SDL_GetWindowWMInfo() code example f61c0f3dc1 SDL_HINT_TV_REMOTE_AS_JOYSTICK should only affect Siri Remotes on Apple TV 51fc134cad Added support for the second generation Siri Remote on Apple TV bfba9de43a Revert "Map Siri Remote touchpad to D-Pad for consistency with physicalInputProfile mapping" f2c12fe5f3 Removed TODO.txt d4448fe3d2 Update virtual joystick test now that we're just using abxy for mappings, for compatibility f40f272107 Fixed build 34bdd321bf Improved navigation while setting up controller mapping 57e5c7f6ee We'll just use the legacy names for face buttons in the mappings 051ed397d1 Removed testautomation_syswm.c from the Xcode project fb08c22abf Disable controller state debug messages 2999634f29 Map Siri Remote touchpad to D-Pad for consistency with physicalInputProfile mapping 2ff9255f29 Print the GUID for controllers that don't have a mapping 64939d3586 Switch the menu button on the Apple TV remote to the B button to match UI guidelines 0fe5713964 Improved GCController handling on Apple platforms aaf54b09a1 Revert "Cleanup WIN_CreateCursor() code a bit" e923a458ea audio: Protect against race conditions when closing a physical device. 8fa0746d4a audio: Fix postmix state when migrating to new default devices. 078995bbe0 x11: Set the skip taskbar and skip pager atoms on utility windows a58af6d0d1 wasapi: Reference devices when proxying to management thread. 34392db9c3 Fixed IOS_SupportedHIDDevice() returning SDL_FALSE before initialization 708f18d49e Added SDL_HINT_JOYSTICK_IOKIT and SDL_HINT_JOYSTICK_MFI to control whether the IOKit and GCController drivers should be used for joystick support. bd4966999b Replacing SDL_SCANCODE_AUDIOMUTE by SDL_SCANCODE_MUTE on Windows 15504da0b8 Fixed mouse wheel scrolling direction on iOS f5600fd9f4 Fall back to using the physical profile for Apple controllers if they don't match a standard profile 924de4df48 Enable transparent windows when using the D3D11 renderer 1c64366b80 Added SDL_CreateRendererWithProperties() and SDL_CreateTextureWithProperties() 7203641597 Note that the SDL window properties are read-only e0c45c6c98 Renamed SDL_WINDOW_FOREIGN to SDL_WINDOW_EXTERNAL 229b7b9d50 SDL_CreateWindowWithPosition() and SDL_CreateWindowFrom() have been replaced with SDL_CreateWindowWithProperties() 2c1fbe1967 Revert "Check to make sure the Windows joystick device has buttons and axes" edd044e901 Fixed the ROG PUGIO II showing up as a game controller 861b1ebd12 properties: Use a mutex instead of an RWLock to guard the hash table dd8ab67bd9 Sync wiki -> headers. 91460fc13d include: Fixed up documentation in SDL_pen.h 876c97454a Cleanup WIN_CreateCursor() code a bit 8766aa39d6 Sync wiki -> headers. e5ffd6d8eb include: Removed `\link` and `\endlink` Doxygen tags. 1c4723ac66 SDL_CreateWindowFrom() now takes a set of properties that describe the native window and options. 6afae6681b Allow casting properties of different types bd269b0f41 Added SDL_SetBooleanProperty() and SDL_GetBooleanProperty() c47ac5b2df include: Fixed copy/paste error 0efb3d90e0 audio: removed a fixed FIXME comment. 69cae07cc1 cpuinfo: Fix detection of physical memory above 2GB on NetBSD 45fc828c95 move SDL_EVENT_WINDOW_PEN_ENTER and SDL_EVENT_WINDOW_PEN_LEAVE down 0907f345cb Added property types: pointer, string, number, float 7c80ac6df7 API for pressure-sensitive pens + XInput2/Wayland d3e43668d0 Revert "Sync SDL3 wiki -> header" 43571769f1 Sync SDL3 wiki -> header 843873626c Handle window resizing on the render thread in D3D11 and D3D12 f66f61de01 Fixed missing "0" in the button list 04b6b2979f Re-add SDL_assert() with non boolean ptr syntax (#8530) b374105975 Replaced SDL_GetTextureDXGIResource() with texture properties 09d1e9defb Only update the battery status for Bluetooth Switch Pro controllers 87794d03ad Added shortened name for "Nintendo Co., Ltd." fbb6934905 Added support for the Dragonrise GameCube adapter with VID 0x1843 d98e1bdfe1 Use the standard gamepad type for Switch Pro controllers using the GameCube form factor a5a47d3bee Fixed crash if there is no controller mapping 312faf9305 Updated documentation for the controller face buttons 2991b9f6ac SDL now represents gamepad buttons as positional elements with a separate label 8708ba7393 Don't leak if realloc fails 36b2d2e463 Fix memory leak in SDL_SendDrop() dfb87e1099 Fix uninitialised variable 'properties' e54c5e0204 Fix condition in SDLTest_TrackAllocations() 89408a9705 wasapi: ResetWasapiDevice no longer blocks on management thread. aa7baf63aa Sync wiki -> headers. 74f3643bfa wayland: Add missing break to switch statement 2d6bae70b4 Older gcc does not support #pragma GCC diagnostic inside functions d8600f717e Pointer as bool (libsdl-org#7214) 23db971681 x11: Ignore deprecated declaration of XKeycodeToKeysym 61c39ce848 ci: re-enable Intel compilers on ci 4ac3f5c07e Updated Xcode project with the video capture API 59f93e20a7 Add SDL Video Capture, with back-end for linux/macos/ios/android 3ab98a3572 Removed debug print statements (thanks @stsp!) f4b61fff30 Implemented VT switching for KMSDRM on Linux 391a3d23d0 cmake: the compile-time pdb does not have a suffix, if set a6541166bc cmake: also install pdb files of static libraries 2e3f574f8f cmake: don't add the C runtime library to the .obj file (when using MSVC) bea34c5380 Fixed a memory leak at window creation. b5347c3364 Fixed emscripten and iOS builds 02f356439d Allow the application to draw while Windows is in a modal move/resize loop 1934417b4d Show the existing mapping when a controller is connected 407a3cb4e0 Fixed infinite recursion initializing properties 979214363f Added SDL_GetGlobalProperties() 151cdfa99f Added the "SDL.window.wayland.registry" property 6c91b28e71 Added the "SDL.renderer.d3d12.command_queue" property 4e8d1ec983 Fixed crash trying to create a metal view with the dummy driver fd4a2cce9e SDL_syswm.h has been removed and replaced with window properties aea6e6de6f Simplified SDL_SetProperty() and added SDL_SetPropertyWithCleanup() a1941fad6c Replaced SDL_RenderGetD3D11Device(), SDL_RenderGetD3D12Device(), and SDL_RenderGetD3D9Device() with renderer properties. 0cd4b7d3e3 Added display properties a02afbaea5 Clean up window properties when the window is destroyed 8668943746 Standardized property names for internal SDL properties a4c6b38fef Fixed FreeBSD build d9e6dcc650 Fixed FreeBSD build 7cc3e94eb2 Store the requested muted state ce9e1bd324 Don't mute the console input if we can't read the keyboard 0a1b6b270f sdlchecks.cmake: Clarified the reason why shared X11 mode doesn't work 80b2bbad21 Removed useless branch test 15bc12165a Actually we need to enumerate the 8BitDo Xbox SKUs 8049af3355 Assume all 8BitDo Xbox controllers have a share button ed1e0c1530 Make sure joysticks are locked when adding and removing them 415283ef38 Fixed checking for linux/input.h fea2504a37 Prioritize the pipewire audio driver over ALSA 04e98d2236 Added missing calls to SDL_InvalidParamError("surface") 521bbcc15e Destroy the window surface if we've created it for the software renderer 28e623c504 Added a mapping for the Atari VCS controller connected over Bluetooth (thanks @WizzardSK!) 4106697774 Make sure we include the null terminator in XLookupStringAsUTF8() b5057edf29 Remove unused SDL_TextureModulate enum 9458cbf75e Removed unused SDL_OSEvent 1a57f6bb29 wayland: Remove QtWayland extensions 5f920d6639 fix emscripten build after commit 07cb7c10 22016b4eae Enable the 5th player LED on the DualSense controller 66cf30c2de Removed misleading comment dbcd390cdf Log drag and drop position updates in SDL test programs 07cb7c10a1 Fixed connecting and disconnecting real-joysticks closing virtual joysticks in Emscripten (thanks David!) 869257a5c1 SDL_migration.cocci: Added a thing for SDL_Vulkan_CreateSurface. c6d9fb1ad7 hidapi: Avoid memcpy'ing to NULL. 4d1aecc225 vulkan: Patched to compile on iOS. fccec65afe Sync SDL3 wiki -> header 2f92807087 vulkan: SDL_Vulkan_CreateSurface now accepts an app-provided allocator. c53843a961 docs: Remove Doxygen `\brief` tags. c132295ad7 SDL_FlushEventMemory is not a public procedure. 7ac281f800 Sync wiki -> headers. f7d40b7594 Added 10-bit pixel formats in addition to SDL_PIXELFORMAT_ARGB2101010 3e4d7e48b0 Fixed memory leak in XInput code bc3d9e99f3 Only save ibus_addr_file after we've successfully read an address from it. 04dfca958a Added a note to events indicating that memory is owned by SDL 20cd789bab Improved migration documentation for the event memory change. 459f17257c cmake: fix MSVC unrecognized option link warning 761390b62f cmake: detect linker id, and assume MSVC does not support version scripts d2e005ee13 dynapi: remove duplicated SDL_LoadWAV entries 21ff699251 test: Fix popup test crash on exit 70c149c88f Automatically clean up memory associated with events 1a83bf2399 fix a possible memory leak in SDL_vasprintf() 59b37d0e5b cmake: fix Windows unrecognized option link warning 9302d7732d Fixed touch normalized coordinates ff3c20a799 Sync SDL3 wiki -> header 17a0fe3a0c Sync SDL3 wiki -> header 14d2471a8f Sync SDL3 wiki -> header 2ad22eeeb5 Sync SDL3 wiki -> header 930438dfb7 Added note that the #ifdef is for !__IOS__ c56583fe45 Fix duplicate symbol on iOS/tvOS 2b62f25a6f Add SDL_sysmain_callbacks.c to the Xcode project 4ab31ca678 Fix dropping file event 5dce4bc716 Makes SDLInputConnection and DummyEdit public classes (thanks Cole!) d3f2eb2aba Use XINPUT_STATE instead of XINPUT_STATE_EX (thanks Andrew!) 3a482ebae0 Add createSDLMainRunnable() to SDLActivity (thanks Cole!) b9784feb24 Fixed potential uninitialized memory access (thanks Mathieu!) 75ea3a8d32 Dynamically allocate long text for SDL_EVENT_TEXT_INPUT events 2a1660ab51 Additional cleanup for SDL_RWprintf() (thanks @sezero!) e5f2cea234 Sync wiki -> headers ad842dd5ad Fixed a typo in SDL_log.h f9d11807c0 Added SDL_RWprintf() and SDL_RWvprintf() to do formatted printing to an SDL_rwops stream 52c4e3eab3 events: Update self-referential pointers when copying event objects 91f0456391 Add the source application for drag and drop events (thanks Nathan!) 1a8bf31a69 include: Fixing whitespace on SDL_MixAudioFormat. d07a264a9b Use the default UCS2/UCS4 conversion rather than non-portable INTERNAL encoding 780b6612a9 wayland: Wayland_Vulkan_GetInstanceExtensions didn't set the count variable. 46b940d571 Updated documentation to note that the event callback is called on the same thread as the main iteration callback 4481754359 Make sure we only dispatch events on the main thread when using application callbacks 274da8561c Updated the migration guide to note that you can check the return value of SDL_AddEventWatch() ad9dcdbbce Clarify that you should use the other field when reading the event a19029e3c1 docs: Updated README-main-functions.md based on feedback. 019468dc59 main: Check for SDL_AddEventWatch failure, now that it can report it. 7e445da569 Added SDL_CleanupEvent() c4bf05fd9d Added subsystem refcount tests to testautomation 7f65ed6461 Handle subsystem dependencies recursively a6b85c81cc Fixed build 3ab6670cb1 Sync SDL3 wiki -> header f439ccfc1a Updated return values for SDL event functions e0379c3b37 Grab events in large chunks in SDL_IterateMainCallbacks() ad5264e54f Don't run SDL_IterateMainCallbacks() if the init call returns an exit code dad1a84be4 Fixed building Vivante video driver fe175d025f Fixed building Vivante video driver 0b460f34ba The HP HyperX controllers have a share button f3261fedcc Code cleanup now that SDL_bool is equivalent to a C boolean expression a76d8e39aa Changed SDL_bool from an enum to unsigned int cf7e5bd0e8 Sync SDL3 wiki -> header 853c28e624 docs: Added first draft of README-main-functions.md 70d75b4a23 Sync wiki -> headers ea02630143 More audio migration clarification 14980b25a8 Clarify documentation for audio callback migration 6cf84e2c5b cmake: fold HAVE_INPUT_EVENTS into HAVE_LINUX_INPUT_H 5e869d1b35 fix Cocoa_Vulkan_GetInstanceExtensions prototype for Mac 07a776f255 include: Fixed documentation for SDL_Vulkan_GetInstanceExtensions. 5b3a2c6df6 docs: Updated SDL_Vulkan_GetInstanceExtensions info in README-migration.md. 9224a0a2d8 Fix emscripten, android, uikit and windows d0d8b28df1 Change SDL_Vulkan_GetInstanceExtensions 338974bb29 SDL_test_memory.c: fix build against older windows SDKs. 618d15bce6 Fixed typo ad0af48883 Check to make sure the Windows joystick device has buttons and axes ac6b32bb02 gendynapi.py: Discard SDLMAIN_DECLSPEC functions. 9c664b0062 main: Added _optional_ callback entry points. 9323417e9c Fixed gendyapi.py parsing of SDL_RELEASE_GENERIC 759cdf6159 audio: Fixed GetFirstAudioDeviceAdded(). 0e614d9179 audio: Massive reworking on thread locking. 40fb76196c audio: Don't let simplified audio streams bind to new devices. 24e3328cca audio: Don't reset device ID counter on subsystem init/quit. 5d95cbde37 cmake: reset check state before testing -fobjc-arc f18120c83c cmake: check -fobjc-arc compiler flag on Apple platforms 4aacc4b92e cmake: file(RELATIVE_PATH) needs 2 absolute paths dcc8805c21 testaudio: Fixed compiler warning on Visual Studio. 9cb259e865 audio: Never SDL_PushEvent from anywhere but SDL_UpdateAudio(). 875e45e70b wayland: Sanity check pointers and protocols before confining 0e87b71d08 wayland: Check the relative pointer handle before destroying 6127ac0871 Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h 552bee47cb Clear any previous errors if we successfully show a message box 343da852a6 Don't try to use the Wayland messagebox if we're not in Wayland f63e9a8a3f wasapi: Handle disconnected devices that get reconnected. 5fa7b291d4 wasapi: Fixed memory leak if new audio devices fail to add. 468c386686 wasapi: Handle disconnect notifications from the management thread, too. ce3be02b48 wasapi: If device is marked as a zombie, don't try to resuscitate it. 85923049a6 wasapi: Patched to compile. 9bec57309c wasapi: Proxy default device change handling to management thread. c45b5121ce audio: Fixed potential race condition. 8b6da3c701 Fixed making the EGL context current when resuming on Android 2e9eb1073d Sync SDL3 wiki -> header e6116d399a mutex: Removed SDL_MUTEX_MAXWAIT. 82f48be3ef Sync SDL3 wiki -> header 899eb0d042 thread: Locking mutexes and rwlocks are now void functions. 082ef41566 alsa: Fix crash from invalid handle pointer a9aa15c792 CI: change FreeBSD CI runner to cross-platform-actions. 23ceae94c9 Fixed Xbox 360 Controller support using libusb on Linux ace0c2c297 mutex: Fixed bug where generic SDL_TryLockMutex would incorrectly block. f52b330ed8 Added support for the HP HyperX Clutch Gladiate controller b61706373c n3ds: Check that audio thread name starts with "SDLAudioP" 6827b3331d n3ds systhread - use 80kb thread stack size as default, remove hard cap e4cd1d4059 n3ds systhread - prefer to put audio thread on system core 1023d8ec84 SDL_n3dsaudio.c - don't risk leaving current_priority uninitialized 07171be596 SDL_n3dsaudio.h: use triple buffering 6efe957159 SDL_n3dsaudio.c: separate mixer locks from audio device locks 39a961ba41 Added support for "%[]" sscanf syntax 124a0050b6 Fixed warning: no previous prototype for function 'SDL_UpdateAudio' b16165a33f rwlock: SDL_UnlockRWLock was incorrectly tagged with SDL_RELEASE_SHARED. 865dd04068 pulseaudio: Don't use a hash for device change detection. b8cc51875a Fixed build 0413e21e54 Fixed audio device removed events for ALSA 5ba03d377a Revert "Fixed audio device removed events for ALSA" a774694be0 pulseaudio: Simplified default device change detection code. e57fef8f0b Fixed audio device removed events for ALSA 4280d4b359 Fixed warning C4210: nonstandard extension used: function given file scope 182cfc3265 pulseaudio: Rework how we manage default devices and hotplug. b2ae1e835f pulseaudio: Change debug printf calls to use SDL_Log instead. 38afd48daf Added a single source of SDL object IDs e07f6c0a17 SDL_IsJoystickProductWheel() returns SDL_TRUE for Asetek wheelbases (thanks @IOBYTE!) c98a14fdeb Renamed display added/removed events for consistency with the rest of the API c2a3112b6f Added "--substring" to the help for rename_symbols.py a844d90942 Add missing error reporting in Android_JNI_FileOpen() 4ac38d13dd alsa: Don't touch free'd memory in hotplug thread. 43d41c9dcb audio: Another attempt to make device add/remove work vs event watchers. 9abc692156 audio: Another attempt to deal with device destruction from device thread. 33c9eeec7c Revert "audio: Device threads don't increment physical device refcounts." e5a15f94e2 Revert "Check to make sure the Windows joystick device has buttons and axes" 70fd8e2ba2 Lock joysticks when adding gamepad mappings 76f81797b7 audio: Device threads don't increment physical device refcounts. 594fda4120 Sync SDL3 wiki -> header 0d7c5a2c56 Updated Android API documentation 0df888c584 Moved Android low latency audio behind a hint "SDL_ANDROID_LOW_LATENCY_AUDIO" 142366c837 Sync SDL3 wiki -> header 3a4c9d6990 Fixed build error when API logging is enabled 1f8f82b379 Removed redundant thread-safety information a6edc75fe7 Sync SDL3 wiki -> header 3c8edeb79b Clarified SDL property thread-safety information 4fa821cb3e Sync SDL3 wiki -> header 1c70760c0b Added thread-safety information for the new SDL properties API 15533dce05 Cleaned up warnings from check_stdlib_usage.py bf269571fc jack: Removed FIXME comment that has since been fixed. 797b70877d audio: Remove stub header SDL_audio_c.h. 9d7c57234a audio: Cleaned out most remaining `/* */` comments for `//` style. 0ff67dc21b video: Fix compiler warning about SDL_ReadSurfacePixel not being declared. 81c77396af opensles: Patched to compile. 442e84916a opensles: Fixed capitalization to match other SDL backends. 34914bfb49 alsa: Clean up device handles, now that hotplug thread cleanup is in place. 48d80efb51 Fixed warning C4701: potentially uninitialized local variable 'props' used f7dc63bcc3 audio: another windows wasapi build fix. dd98330076 audio: fix windows wasapi build. 7a52f7b3fd audio: Split Deinitialize into two stages. e55e556f32 alsa: Fixed minor memory leak. b45a0d9016 Updated the documentation for SDL_LoadWAV_RW() 435e7ce663 Check for device disconnection in HIDAPI_JoystickOpen() b733adb503 audio: Fix device refcounting vs ProvidesOwnCallbackThread backends. c6f08c2553 testaudio: Removed debugging code. d5dac0ad27 testaudio: Deal with a texture being unexpectedly NULL when scaling. b19e68c8ec testaudio: Properly display playback progress, regardless of data source. 8c39269279 audio: Fix audio stream format when binding to a capture device. f26b838a3e jack: Check for sample rate and buffer size changes from the server. 063cb0df6b audio: Fixed comment typo. "deref" should be "unref" 354611a0c6 testaudio: Fixed some bugs Valgrind pointed out. a17f3ba916 audio: Reworked audio device disconnect management. 6ddd96a4d0 Fix some wrong gamepad/controller event enums 8df68b4120 hashtable: Moved over to single-line comments. 1c6d996108 testaudio: if the SDL_Renderer is already gone, don't destroy SDL_Textures. b22ffb9797 audio: Fix some logic errors in the new device hashtable code. e526dc64bd Don't set unused variable 6664437748 hashtable: Don't rearrange bucket elements during SDL_FindInHashTable. 8ac5c84ad1 audio: device thread shouldn't touch `thread_alive` after object is free'd. b17151eb16 testaudio: Don't crash if renderer is NULL (happens during shutdown). 7f408e57ee audio: Keep all available devices in a hashtable instead of linked lists. 0aba2c97db hashtable: SDL_IterateHashTable might as well provide both key and value. 95a9271dbf audio: Never lock a device while holding the device_list_lock. 9aeabb0b05 Fix macOS build error by #8269 382751c4b5 testffmpeg: print usage of options to change audio/video codec f91bde64d5 testffmpeg: Only enable blending if we're using a texture format that supports it 516d6f9efc testffmpeg: added support for YUVA formats using swscale ac71831350 Sync wiki -> headers d18f910248 testffmpeg: added the ability to specify audio and video codecs 72034b9a07 wayland: Fix primary selection handling when the protocol isn't supported e152129787 Fixes #8190. From #7249, reverted the hunks other than #7239. b79db0a6ea Fixed potential wraparound issue with property IDs c9ccf0670c Add unsupported functions to dynapi 25ce87979d Always provide an implementation for all SDL3 symbols 3a36433a3c cmake: test -Wl,--version-script with minimal version script 0efa196989 dynapi: implement SDL_DYNAPI_entry even when building SDL without dynapi support bf64fecf19 testffmpeg: allow resizing of the video window efa9a45048 Clarified that testffmpeg will resize the window to the video size 4368f70ff9 Added properties to various SDL objects 973c8b3273 Added SDL properties API 2bca4671a6 audio: Allow audio streams to be created when the subsystem isn't initialized. 1ae33f6751 cmake: optionally install pdb's 0d5cad91b1 We need audio converters initialized in SDL_InitAudio() 1c3a0ade74 audio: Whoops, this stream format change is only for capture devices. 10fab3a39e pulseaudio: Stop the threaded mainloop before destroying the context. 0b71898cb1 Make it clear that the string comparison isn't a boolean check 6c8ad975c7 Like mutexes, operations on NULL rwlocks are no-ops c552cc6847 We don't require the audio system to be initialized for audio format conversion 9a5f7b17c6 Use SDL wrapped getenv function 044046bc50 audio: Fixed assertions when capture devices have wrong audio formats. bb2f767f5d testaudio: Make program usable without a 3-button mouse. 321fc18417 README-migration.md: Added note about SDL_HasRDTSC removal. 82f54af617 x11: Properly check for XInput2 support before using it. b654427537 Added support for the PowerA Nintendo Switch Nano Wired Controller dc2a5f6ab2 Fixed error C2054: expected '(' to follow 'inline' a7ae1de9a6 Fixed warning C4028: formal parameter different from declaration 3a47fb7208 The sensor and joystick instance ID generator isn't guarded by a lock. aee4862958 ci: stop FreeBSD job after 30 minutes 99fa0d6cae Disable low latency audio by default when using AAudio on Android ebfbd7327b testffmpeg: use SDL_test to parse arguments and track memory ee53e4d319 cmake: check ffmpeg capability instead of version 2d62c65a75 Fixed build warning bf72704bfd audio: Disable NEON sample conversion until test failures are fixed 0fe95cfba3 Sync wiki -> header adcace6f95 Added a "--software" option to testffmpeg 86ada8a9f0 fix testffmpeg.c build. 303f4e965c testffmpeg works with ffmpeg 5.1.3 and newer 2bd478ae65 Added SDL_GetTextureDXGIResource() to get the DXGI resource associated with a render texture. a842446f62 Added support for 0-copy decode and display using D3D11 d830cd140b Added support for 0-copy decode and display using Apple VideoToolbox 1bf913b29a Added support for 0-copy decode and display using VAAPI and EGL ce8161e0cf Make sure we're building with ffmpeg 6.0 or newer ed6381b68d Allow setting any number of sprites over the video ebf5e08fa1 cmake: use *_STATIC_* variables when linking to a static ffmpeg 88f2fb9dcf Added an example of video decoding with ffmpeg d88bf687a8 surface: Document the in-memory layout of the pixels 3698630bbc pixels: Document the naming convention 04edb38cdf shape: Use SDL[Test]_ReadSurfacePixel f5745c3a67 surface: Add a private SDL_ReadSurfacePixel 0d68f45879 test: Extract SDLTest_ReadSurfacePixel 55a1458ed0 audio: Changes to one logical device must update all sibling logical devices. 8e03ea4383 hashtable: Use Create/Destroy naming, in the SDL3 style. 568902b64e hashtable: Added src/SDL_hashtable.[ch]. 8745a9949b add-source-to-projects.pl: Fix adding files in the base src dir. 836927edf8 wayland: Try to skip the Wayland driver if not connecting to or in a Wayland session 2a9480c815 wayland: Add null check for zenity version string f30392da5b Fix assertion in LINUX_JoystickSetSensorsEnabled() 4e59bf6cb9 SDLTest_CompareSurfaces: Output RGBA values of first differing pixel b2ddfbbec3 SDLTest_CompareSurfaces: If surfaces differ, log their formats b028fd9604 SDLTest_CompareSurfaces: Log better messages if NULL or different sizes 183606d3d4 testdrawchessboard: clean up renderer and window 4f0642bf47 triangle: don't read destination pixel when you're going to discard it anyways 4cd0c13823 blit_slow: don't read destination pixel when you're going to discard it anyways 49abb9c1fa aaudio: Fixed a comment. 0eb8651d5e Do not report gyro/accelerometer if we can't read axes info ff57867516 audio: Fixed copy/paste error that was checking wrong variable. d2d4914ac3 audio: WaitDevice/WaitCaptureDevice now returns a result. a0820ed833 directsound: Cleaned up WaitDevice. 6c33a05bdb audio: Removed unused AllowsArbitraryDeviceNames variable. f1fc198278 audio: Destroy the logical audio device before sending DEVICE_REMOVED event. 64ec208479 Fix log message spelling 9111c5e178 tests: Disable mouse warp test under Wayland de5068f4e4 audio: Commented out a currently-incorrect assert. 3abb464f10 ci: disable Intel compilers 251f8fa272 Revert "Do a better job of finding default ALSA devices" 8857b0f13a Use the device audio format for the lowest latency 806e11ac00 Update sample processing bookkeeping when recovering the AAudio audio device 482c238953 aaudio: Deal with device recovery. a8813b58a6 aaudio: Change an int to an SDL_bool. 8923305f34 We don't need to wait a full 10 ms, just delay a bit 6a152676bb Wait a bit when snd_pcm_avail() returns 0 b4372de186 alsa: Cleaned up remaining debug logging. a063c943dc pulseaudio: Use pa_stream_begin_write to avoid an extra buffer copy. 0471a93706 alsa: Simplified PlayDevice and CaptureFromDevice. 776d9d0ee3 alsa: Convert `/* */` comments to `//` comments. 64fee85c69 alsa: More efficient audio thread iteration. 47cba08259 VisualC/pkg-support/cmake: remove subdir from public header include path 61e9a9dd56 pulseaudio: Just feed the device whenever it asks for any amount of data. 4f76f9b0a7 pulseaudio: Use correct buffer size of stream, wait less between fills. d95d2d7051 SDLTest_CompareSurfaces: Decode pixels correctly on big-endian platforms d65861f049 Do a better job of finding default ALSA devices ba65ef5ce7 Recover from -EPIPE in snd_pcm_avail() 5be5000fa1 cmake: make HEADERS_DIR a required argument of SDL_generate_manpages 5c1a91a4e1 ci: make sure perl is installed + build docs with MSVC toolchain 6248472c0c test: Accept small numerical differences in more mathematical tests a2c5dc6507 pulseaudio: Added typedef needed for compat with ancient Pulse installs. f24551f6d1 pulseaudio: More workarounds for extremely old Pulse installs. 441a5b707b audio: Adjusted const/static fields on some variables. 280c2c1d7d pulseaudio: Revert "pulseaudio: Require PulseAudio 5.0 or later for SDL3." 4db2b968af audio: simple-copy path should check if device is paused. 505dc4c39c wasapi: Deal with device failures when we aren't holding the device lock. ea5f59c234 Removed unused code a6854098f7 Fixed stuttering on Android when using the AAudio driver a5175e5ed0 audio: Fixed bug when setting up mixing formats. 9667aa18e6 wayland: Check that the data device supports the release method before calling it 4454dc400b wayland: Null all Wayland manager objects after freeing e1789b320e video: Streamline a little deinit code. 2a1058713c Bump libdecor feature check to look for 0.2.0 f5886f11d0 cmake: let every test depends on pretest f45761908a Move check for SDL_Delay upper bounds to testtimer a84389f6bb libm: use union for infinity 474c8d0073 testautomation: don't do float equality tests a6bc6b882c ci: always upload the artifacts 85e3099ba4 testautomation: only require accelated renderer with non-dummy video driver 26fd231151 ci: run tests on msvc workflow 0e955a9127 cmake: run testautomation with CTest 1375d2049d SDL_iconv_string() defaults to UTF-8 70a1bc6973 Check for NULL before dereferencing newly allocated memory 752f14e5a6 wayland: Convert some memcpy calls to copyp 9284a03053 wayland: Remove some unnecessary helper functions git-subtree-dir: external/sdl/SDL git-subtree-split: 0d7df16812c75c4a587d7d2673e3d1a5f2c2879b
@ -1,6 +1,9 @@
|
||||
#
|
||||
# CMake script for building the SDL tests
|
||||
#
|
||||
|
||||
include(CheckStructHasMember)
|
||||
|
||||
if(SDL_TESTS_LINK_SHARED)
|
||||
set(sdl_name_component SDL3-shared)
|
||||
else()
|
||||
@ -29,11 +32,35 @@ add_library(sdltests_utils OBJECT
|
||||
target_link_libraries(sdltests_utils PRIVATE SDL3::Headers)
|
||||
|
||||
file(GLOB RESOURCE_FILES *.bmp *.wav *.hex moose.dat utf8.txt)
|
||||
|
||||
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}$<$<BOOL:${is_multi_config}>:/$<CONFIG>>")
|
||||
endif()
|
||||
|
||||
set(RESOURCE_FILE_NAMES)
|
||||
foreach(RESOURCE_FILE IN LISTS RESOURCE_FILES)
|
||||
get_filename_component(res_file_name ${RESOURCE_FILE} NAME)
|
||||
set(RESOURCE_FILES_BINDIR)
|
||||
foreach(resource_file IN LISTS RESOURCE_FILES)
|
||||
get_filename_component(res_file_name ${resource_file} NAME)
|
||||
list(APPEND RESOURCE_FILE_NAMES "${res_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}"
|
||||
)
|
||||
|
||||
define_property(TARGET PROPERTY SDL_NONINTERACTIVE BRIEF_DOCS "If true, target is a non-interactive test executable." FULL_DOCS "If true, target is a noninteractive test executable.")
|
||||
define_property(TARGET PROPERTY SDL_NONINTERACTIVE_ARGUMENTS BRIEF_DOCS "Argument(s) to run executable in non-interactive mode." FULL_DOCS "Argument(s) to run executable in non-interactive mode.")
|
||||
@ -44,11 +71,16 @@ if(WINDOWS_STORE)
|
||||
target_link_libraries(sdl_test_main_uwp PRIVATE SDL3::Headers)
|
||||
target_compile_options(sdl_test_main_uwp PRIVATE "/ZW")
|
||||
|
||||
add_library(sdl_test_main_callbacks_uwp OBJECT main.cpp)
|
||||
target_link_libraries(sdl_test_main_callbacks_uwp PRIVATE SDL3::Headers)
|
||||
target_compile_options(sdl_test_main_callbacks_uwp PRIVATE "/ZW")
|
||||
target_compile_definitions(sdl_test_main_callbacks_uwp PRIVATE "SDL_MAIN_USE_CALLBACKS")
|
||||
|
||||
set_source_files_properties(${RESOURCE_FILES} PROPERTIES VS_DEPLOYENT_LOCATION "Assets")
|
||||
endif()
|
||||
|
||||
macro(add_sdl_test_executable TARGET)
|
||||
cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;NO_C90" "" "NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN})
|
||||
cmake_parse_arguments(AST "BUILD_DEPENDENT;NONINTERACTIVE;NEEDS_RESOURCES;TESTUTILS;NO_C90;MAIN_CALLBACKS" "" "NONINTERACTIVE_TIMEOUT;NONINTERACTIVE_ARGS;SOURCES" ${ARGN})
|
||||
if(AST_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "Unknown argument(s): ${AST_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
@ -70,8 +102,14 @@ macro(add_sdl_test_executable TARGET)
|
||||
TARGET "${TARGET}"
|
||||
)
|
||||
set_property(SOURCE "${uwp_bindir}/${TARGET}.appxmanifest" PROPERTY VS_DEPLOYMENT_CONTENT 1)
|
||||
|
||||
if(AST_MAIN_CALLBACKS)
|
||||
list(APPEND EXTRA_SOURCES "$<TARGET_OBJECTS:sdl_test_main_callbacks_uwp>")
|
||||
else()
|
||||
list(APPEND EXTRA_SOURCES "$<TARGET_OBJECTS:sdl_test_main_uwp>")
|
||||
endif()
|
||||
|
||||
list(APPEND EXTRA_SOURCES
|
||||
"$<TARGET_OBJECTS:sdl_test_main_uwp>"
|
||||
"${uwp_bindir}/${TARGET}.appxmanifest"
|
||||
"uwp/logo-50x50.png"
|
||||
"uwp/square-44x44.png"
|
||||
@ -120,8 +158,7 @@ macro(add_sdl_test_executable TARGET)
|
||||
)
|
||||
add_dependencies(${TARGET} zzz-resources-copy-${TARGET})
|
||||
else()
|
||||
add_custom_command(TARGET ${TARGET} POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${RESOURCE_FILES} $<TARGET_FILE_DIR:${TARGET}>)
|
||||
add_dependencies(${TARGET} copy-sdl-test-resources)
|
||||
endif()
|
||||
if(APPLE)
|
||||
# Make sure resource files get installed into macOS/iOS .app bundles.
|
||||
@ -182,19 +219,45 @@ if(HAVE_LIBUDEV_H)
|
||||
add_definitions(-DHAVE_LIBUDEV_H)
|
||||
endif()
|
||||
|
||||
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL SWSCALE)
|
||||
include("${SDL3_SOURCE_DIR}/cmake/FindFFmpeg.cmake")
|
||||
if(FFmpeg_FOUND)
|
||||
cmake_push_check_state()
|
||||
list(APPEND CMAKE_REQUIRED_INCLUDES "${FFmpeg_AVUTIL_INCLUDE_DIRS}")
|
||||
check_struct_has_member("AVFrame" "ch_layout" "libavutil/frame.h" LIBAVUTIL_AVFRAME_HAS_CH_LAYOUT)
|
||||
cmake_pop_check_state()
|
||||
endif()
|
||||
if(FFmpeg_FOUND AND LIBAVUTIL_AVFRAME_HAS_CH_LAYOUT)
|
||||
add_sdl_test_executable(testffmpeg NO_C90 SOURCES testffmpeg.c ${icon_bmp_header})
|
||||
if(APPLE)
|
||||
target_sources(testffmpeg PRIVATE testffmpeg_videotoolbox.m)
|
||||
target_link_options(testffmpeg PRIVATE "-Wl,-framework,CoreFoundation" "-Wl,-framework,CoreVideo" "-Wl,-framework,Metal")
|
||||
endif()
|
||||
if(HAVE_OPENGLES_V2)
|
||||
message(DEBUG "Enabling EGL support in testffmpeg")
|
||||
target_compile_definitions(testffmpeg PRIVATE HAVE_EGL)
|
||||
if(TARGET OpenGL::EGL)
|
||||
target_link_libraries(testffmpeg PRIVATE OpenGL::EGL)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(testffmpeg PRIVATE ${FFMPEG_LIBRARIES})
|
||||
else()
|
||||
message(STATUS "Can't find ffmpeg 5.1.3 or newer, skipping testffmpeg")
|
||||
endif()
|
||||
|
||||
add_sdl_test_executable(checkkeys SOURCES checkkeys.c)
|
||||
add_sdl_test_executable(checkkeysthreads SOURCES checkkeysthreads.c)
|
||||
add_sdl_test_executable(loopwave NEEDS_RESOURCES TESTUTILS SOURCES loopwave.c)
|
||||
add_sdl_test_executable(loopwave NEEDS_RESOURCES TESTUTILS MAIN_CALLBACKS SOURCES loopwave.c)
|
||||
add_sdl_test_executable(testsurround SOURCES testsurround.c)
|
||||
add_sdl_test_executable(testresample NEEDS_RESOURCES SOURCES testresample.c)
|
||||
add_sdl_test_executable(testaudioinfo SOURCES testaudioinfo.c)
|
||||
add_sdl_test_executable(testaudiostreamdynamicresample NEEDS_RESOURCES TESTUTILS SOURCES testaudiostreamdynamicresample.c)
|
||||
|
||||
file(GLOB TESTAUTOMATION_SOURCE_FILES testautomation*.c)
|
||||
add_sdl_test_executable(testautomation NEEDS_RESOURCES NO_C90 SOURCES ${TESTAUTOMATION_SOURCE_FILES})
|
||||
add_sdl_test_executable(testautomation NONINTERACTIVE NONINTERACTIVE_TIMEOUT 120 NEEDS_RESOURCES NO_C90 SOURCES ${TESTAUTOMATION_SOURCE_FILES})
|
||||
add_sdl_test_executable(testmultiaudio NEEDS_RESOURCES TESTUTILS SOURCES testmultiaudio.c)
|
||||
add_sdl_test_executable(testaudiohotplug NEEDS_RESOURCES TESTUTILS SOURCES testaudiohotplug.c)
|
||||
add_sdl_test_executable(testaudiocapture SOURCES testaudiocapture.c)
|
||||
add_sdl_test_executable(testaudiocapture MAIN_CALLBACKS SOURCES testaudiocapture.c)
|
||||
add_sdl_test_executable(testatomic NONINTERACTIVE SOURCES testatomic.c)
|
||||
add_sdl_test_executable(testintersections SOURCES testintersections.c)
|
||||
add_sdl_test_executable(testrelative SOURCES testrelative.c)
|
||||
@ -225,9 +288,20 @@ if(APPLE)
|
||||
endif()
|
||||
elseif(WINDOWS)
|
||||
add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativew32.c)
|
||||
elseif(HAVE_X11)
|
||||
add_sdl_test_executable(testnative BUILD_DEPENDENT NEEDS_RESOURCES TESTUTILS SOURCES testnative.c testnativex11.c)
|
||||
target_link_libraries(testnative PRIVATE X11)
|
||||
elseif(HAVE_X11 OR HAVE_WAYLAND)
|
||||
add_sdl_test_executable(testnative BUILD_DEPENDENT NO_C90 NEEDS_RESOURCES TESTUTILS SOURCES testnative.c)
|
||||
if(HAVE_X11)
|
||||
target_sources(testnative PRIVATE testnativex11.c)
|
||||
target_link_libraries(testnative PRIVATE X11)
|
||||
endif()
|
||||
if(HAVE_WAYLAND)
|
||||
set_property(SOURCE ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c PROPERTY GENERATED 1)
|
||||
target_sources(testnative PRIVATE testnativewayland.c ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c)
|
||||
|
||||
# Needed to silence the documentation warning in the generated header file
|
||||
target_compile_options(testnative PRIVATE -Wno-documentation-unknown-command)
|
||||
target_link_libraries(testnative PRIVATE wayland-client)
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
find_package(Python3)
|
||||
@ -275,7 +349,7 @@ files2headers(gamepad_image_headers
|
||||
)
|
||||
files2headers(icon_bmp_header icon.bmp)
|
||||
|
||||
add_sdl_test_executable(testaudio NEEDS_RESOURCES TESTUTILS SOURCES testaudio.c)
|
||||
add_sdl_test_executable(testaudio MAIN_CALLBACKS NEEDS_RESOURCES TESTUTILS SOURCES testaudio.c)
|
||||
add_sdl_test_executable(testfile NONINTERACTIVE SOURCES testfile.c)
|
||||
add_sdl_test_executable(testcontroller TESTUTILS SOURCES testcontroller.c gamepadutils.c ${gamepad_image_headers})
|
||||
add_sdl_test_executable(testgeometry TESTUTILS SOURCES testgeometry.c)
|
||||
@ -288,6 +362,7 @@ add_sdl_test_executable(testgles2 SOURCES testgles2.c)
|
||||
add_sdl_test_executable(testgles2_sdf NEEDS_RESOURCES TESTUTILS SOURCES testgles2_sdf.c)
|
||||
add_sdl_test_executable(testhaptic SOURCES testhaptic.c)
|
||||
add_sdl_test_executable(testhotplug SOURCES testhotplug.c)
|
||||
add_sdl_test_executable(testpen SOURCES testpen.c)
|
||||
add_sdl_test_executable(testrumble SOURCES testrumble.c)
|
||||
add_sdl_test_executable(testthread NONINTERACTIVE NONINTERACTIVE_TIMEOUT 40 SOURCES testthread.c)
|
||||
add_sdl_test_executable(testiconv NEEDS_RESOURCES TESTUTILS SOURCES testiconv.c)
|
||||
@ -304,7 +379,7 @@ add_sdl_test_executable(testplatform NONINTERACTIVE SOURCES testplatform.c)
|
||||
add_sdl_test_executable(testpower NONINTERACTIVE SOURCES testpower.c)
|
||||
add_sdl_test_executable(testfilesystem NONINTERACTIVE SOURCES testfilesystem.c)
|
||||
if(WIN32 AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
add_sdl_test_executable(testfilesystem_pre SOURCES testfilesystem_pre.c NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60)
|
||||
add_sdl_test_executable(pretest SOURCES pretest.c NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60)
|
||||
endif()
|
||||
add_sdl_test_executable(testrendertarget NEEDS_RESOURCES TESTUTILS SOURCES testrendertarget.c)
|
||||
add_sdl_test_executable(testscale NEEDS_RESOURCES TESTUTILS SOURCES testscale.c)
|
||||
@ -312,12 +387,14 @@ add_sdl_test_executable(testsem NONINTERACTIVE NONINTERACTIVE_ARGS 10 NONINTERAC
|
||||
add_sdl_test_executable(testsensor SOURCES testsensor.c)
|
||||
add_sdl_test_executable(testshader NEEDS_RESOURCES TESTUTILS SOURCES testshader.c)
|
||||
add_sdl_test_executable(testshape NEEDS_RESOURCES SOURCES testshape.c)
|
||||
add_sdl_test_executable(testsprite NEEDS_RESOURCES TESTUTILS SOURCES testsprite.c)
|
||||
add_sdl_test_executable(testsprite MAIN_CALLBACKS NEEDS_RESOURCES TESTUTILS SOURCES testsprite.c)
|
||||
add_sdl_test_executable(testspriteminimal SOURCES testspriteminimal.c ${icon_bmp_header})
|
||||
add_sdl_test_executable(teststreaming NEEDS_RESOURCES TESTUTILS SOURCES teststreaming.c)
|
||||
add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
|
||||
add_sdl_test_executable(testtimer NONINTERACTIVE NONINTERACTIVE_ARGS --no-interactive NONINTERACTIVE_TIMEOUT 60 SOURCES testtimer.c)
|
||||
add_sdl_test_executable(testurl SOURCES testurl.c)
|
||||
add_sdl_test_executable(testver NONINTERACTIVE SOURCES testver.c)
|
||||
add_sdl_test_executable(testvideocapture SOURCES testvideocapture.c)
|
||||
add_sdl_test_executable(testvideocaptureminimal SOURCES testvideocaptureminimal.c)
|
||||
add_sdl_test_executable(testviewport NEEDS_RESOURCES TESTUTILS SOURCES testviewport.c)
|
||||
add_sdl_test_executable(testwm SOURCES testwm.c)
|
||||
add_sdl_test_executable(testyuv NONINTERACTIVE NONINTERACTIVE_ARGS "--automated" NEEDS_RESOURCES TESTUTILS SOURCES testyuv.c testyuv_cvt.c)
|
||||
@ -332,6 +409,15 @@ add_sdl_test_executable(testvulkan NO_C90 SOURCES testvulkan.c)
|
||||
add_sdl_test_executable(testoffscreen SOURCES testoffscreen.c)
|
||||
add_sdl_test_executable(testpopup SOURCES testpopup.c)
|
||||
|
||||
if (HAVE_WAYLAND)
|
||||
# Set the GENERATED property on the protocol file, since it is first created at build time
|
||||
set_property(SOURCE ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c PROPERTY GENERATED 1)
|
||||
add_sdl_test_executable(testwaylandcustom NO_C90 NEEDS_RESOURCES SOURCES testwaylandcustom.c ${SDL3_BINARY_DIR}/wayland-generated-protocols/xdg-shell-protocol.c)
|
||||
# Needed to silence the documentation warning in the generated header file
|
||||
target_compile_options(testwaylandcustom PRIVATE -Wno-documentation-unknown-command)
|
||||
target_link_libraries(testwaylandcustom PRIVATE wayland-client)
|
||||
endif()
|
||||
|
||||
check_c_compiler_flag(-Wformat-overflow HAVE_WFORMAT_OVERFLOW)
|
||||
if(HAVE_WFORMAT_OVERFLOW)
|
||||
target_compile_definitions(testautomation PRIVATE HAVE_WFORMAT_OVERFLOW)
|
||||
@ -511,13 +597,12 @@ foreach(TEST ${SDL_TEST_EXECUTABLES})
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/installed-tests/SDL3
|
||||
)
|
||||
endif()
|
||||
if(TARGET pretest AND NOT "${TEST}" MATCHES "pretest")
|
||||
set_property(TEST ${TEST} APPEND PROPERTY DEPENDS pretest)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(TARGET testfilesystem_pre)
|
||||
set_property(TEST testfilesystem APPEND PROPERTY DEPENDS testfilesystem_pre)
|
||||
endif()
|
||||
|
||||
if(SDL_INSTALL_TESTS)
|
||||
if(RISCOS)
|
||||
install(
|
||||
@ -530,13 +615,18 @@ if(SDL_INSTALL_TESTS)
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3
|
||||
)
|
||||
endif()
|
||||
if(MSVC)
|
||||
foreach(test IN LISTS SDL_TEST_EXECUTABLES)
|
||||
SDL_install_pdb(${test} "${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3")
|
||||
endforeach()
|
||||
endif()
|
||||
install(
|
||||
FILES ${RESOURCE_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/installed-tests/SDL3
|
||||
)
|
||||
endif()
|
||||
|
||||
if(ANDROID AND TARGET SDL3-jar)
|
||||
if(ANDROID AND TARGET SDL3::Jar)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../cmake/android")
|
||||
find_package(SdlAndroid MODULE)
|
||||
if(SdlAndroid_FOUND)
|
||||
@ -593,14 +683,14 @@ if(ANDROID AND TARGET SDL3-jar)
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${classes_path}"
|
||||
COMMAND ${Java_JAVAC_EXECUTABLE}
|
||||
-source 1.8 -target 1.8
|
||||
-bootclasspath "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>"
|
||||
-bootclasspath "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>"
|
||||
"${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
"${JAVA_PACKAGE_DIR}/SDLTestActivity.java"
|
||||
$<TARGET_PROPERTY:${TEST}-apk-linked,JAVA_R>
|
||||
-cp "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>:${path_android_jar}"
|
||||
-cp "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>:${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||
-d "${classes_path}"
|
||||
COMMAND ${Java_JAR_EXECUTABLE} cf "${OUT_JAR}" -C "${classes_path}" .
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3-jar,OUTPUT>" "${JAVA_PACKAGE_DIR}/SDLTestActivity.java" "${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-apk-linked,OUTPUTS> "$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>" "${JAVA_PACKAGE_DIR}/SDLTestActivity.java" "${JAVA_PACKAGE_DIR}/SDLEntryTestActivity.java"
|
||||
)
|
||||
add_custom_target(${TEST}-jar DEPENDS "${OUT_JAR}")
|
||||
set_property(TARGET ${TEST}-jar PROPERTY OUTPUT "${OUT_JAR}")
|
||||
@ -616,10 +706,10 @@ if(ANDROID AND TARGET SDL3-jar)
|
||||
OUTPUT "${classes_dex}"
|
||||
COMMAND SdlAndroid::d8
|
||||
$<TARGET_PROPERTY:${TEST}-jar,OUTPUT>
|
||||
$<TARGET_PROPERTY:SDL3-jar,OUTPUT>
|
||||
--lib "${path_android_jar}"
|
||||
$<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||
--lib "${SDL_ANDROID_PLATFORM_ANDROID_JAR}"
|
||||
--output "${dexworkdir}"
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-jar,OUTPUT> $<TARGET_PROPERTY:SDL3-jar,OUTPUT>
|
||||
DEPENDS $<TARGET_PROPERTY:${TEST}-jar,OUTPUT> $<TARGET_PROPERTY:SDL3::Jar,JAR_FILE>
|
||||
)
|
||||
add_custom_target(${TEST}-dex DEPENDS "${classes_dex}")
|
||||
set_property(TARGET ${TEST}-dex PROPERTY OUTPUT "${classes_dex}")
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -165,7 +165,7 @@ static void loop(void)
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
|
||||
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED), (event.key.repeat > 0));
|
||||
if (event.type == SDL_EVENT_KEY_DOWN) {
|
||||
switch (event.key.keysym.sym) {
|
||||
case SDLK_BACKSPACE:
|
||||
@ -182,10 +182,6 @@ static void loop(void)
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
PrintText("EDIT", event.edit.text);
|
||||
break;
|
||||
case SDL_EVENT_TEXT_EDITING_EXT:
|
||||
PrintText("EDIT_EXT", event.editExt.text);
|
||||
SDL_free(event.editExt.text);
|
||||
break;
|
||||
case SDL_EVENT_TEXT_INPUT:
|
||||
PrintText("INPUT", event.text.text);
|
||||
SDLTest_TextWindowAddText(textwin, "%s", event.text.text);
|
||||
@ -245,7 +241,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
state->window_title = "CheckKeys Test";
|
||||
@ -261,9 +257,6 @@ int main(int argc, char *argv[])
|
||||
/* Disable mouse emulation */
|
||||
SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
|
||||
|
||||
/* Enable extended text editing events */
|
||||
SDL_SetHint(SDL_HINT_IME_SUPPORT_EXTENDED_TEXT, "1");
|
||||
|
||||
/* Initialize SDL */
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -179,7 +179,7 @@ static void loop(void)
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED) ? SDL_TRUE : SDL_FALSE, (event.key.repeat) ? SDL_TRUE : SDL_FALSE);
|
||||
PrintKey(&event.key.keysym, (event.key.state == SDL_PRESSED), (event.key.repeat > 0));
|
||||
break;
|
||||
case SDL_EVENT_TEXT_EDITING:
|
||||
PrintText("EDIT", event.text.text);
|
||||
@ -247,7 +247,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -267,7 +267,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Set 640x480 video mode */
|
||||
window = SDL_CreateWindow("CheckKeys Test", 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);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@ static const struct
|
||||
int x;
|
||||
int y;
|
||||
} button_positions[] = {
|
||||
{ 413, 190 }, /* SDL_GAMEPAD_BUTTON_A */
|
||||
{ 456, 156 }, /* SDL_GAMEPAD_BUTTON_B */
|
||||
{ 372, 159 }, /* SDL_GAMEPAD_BUTTON_X */
|
||||
{ 415, 127 }, /* SDL_GAMEPAD_BUTTON_Y */
|
||||
{ 413, 190 }, /* SDL_GAMEPAD_BUTTON_SOUTH */
|
||||
{ 456, 156 }, /* SDL_GAMEPAD_BUTTON_EAST */
|
||||
{ 372, 159 }, /* SDL_GAMEPAD_BUTTON_WEST */
|
||||
{ 415, 127 }, /* SDL_GAMEPAD_BUTTON_NORTH */
|
||||
{ 199, 157 }, /* SDL_GAMEPAD_BUTTON_BACK */
|
||||
{ 257, 153 }, /* SDL_GAMEPAD_BUTTON_GUIDE */
|
||||
{ 314, 157 }, /* SDL_GAMEPAD_BUTTON_START */
|
||||
@ -120,7 +120,7 @@ struct GamepadImage
|
||||
int y;
|
||||
SDL_bool showing_front;
|
||||
SDL_bool showing_touchpad;
|
||||
GamepadImageFaceStyle face_style;
|
||||
SDL_GamepadType type;
|
||||
ControllerDisplayMode display_mode;
|
||||
|
||||
SDL_bool elements[SDL_GAMEPAD_ELEMENT_MAX];
|
||||
@ -146,29 +146,6 @@ static SDL_Texture *CreateTexture(SDL_Renderer *renderer, unsigned char *data, u
|
||||
return texture;
|
||||
}
|
||||
|
||||
static SDL_GamepadButton GetRemappedButton(GamepadImageFaceStyle face_style, SDL_GamepadButton button)
|
||||
{
|
||||
if (face_style == GAMEPAD_IMAGE_FACE_BAYX) {
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_A:
|
||||
button = SDL_GAMEPAD_BUTTON_B;
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_B:
|
||||
button = SDL_GAMEPAD_BUTTON_A;
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_X:
|
||||
button = SDL_GAMEPAD_BUTTON_Y;
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_Y:
|
||||
button = SDL_GAMEPAD_BUTTON_X;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return button;
|
||||
}
|
||||
|
||||
GamepadImage *CreateGamepadImage(SDL_Renderer *renderer)
|
||||
{
|
||||
GamepadImage *ctx = SDL_calloc(1, sizeof(*ctx));
|
||||
@ -241,22 +218,22 @@ void SetGamepadImageShowingFront(GamepadImage *ctx, SDL_bool showing_front)
|
||||
ctx->showing_front = showing_front;
|
||||
}
|
||||
|
||||
void SetGamepadImageFaceStyle(GamepadImage *ctx, GamepadImageFaceStyle face_style)
|
||||
void SetGamepadImageFaceButtonType(GamepadImage *ctx, SDL_GamepadType type)
|
||||
{
|
||||
if (!ctx) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->face_style = face_style;
|
||||
ctx->type = type;
|
||||
}
|
||||
|
||||
GamepadImageFaceStyle GetGamepadImageFaceStyle(GamepadImage *ctx)
|
||||
SDL_GamepadType GetGamepadImageType(GamepadImage *ctx)
|
||||
{
|
||||
if (!ctx) {
|
||||
return GAMEPAD_IMAGE_FACE_BLANK;
|
||||
return SDL_GAMEPAD_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
return ctx->face_style;
|
||||
return ctx->type;
|
||||
}
|
||||
|
||||
void SetGamepadImageDisplayMode(GamepadImage *ctx, ControllerDisplayMode display_mode)
|
||||
@ -407,7 +384,7 @@ int GetGamepadImageElementAt(GamepadImage *ctx, float x, float y)
|
||||
rect.w = (float)ctx->button_width;
|
||||
rect.h = (float)ctx->button_height;
|
||||
if (SDL_PointInRectFloat(&point, &rect)) {
|
||||
return GetRemappedButton(ctx->face_style, (SDL_GamepadButton)i);
|
||||
return (SDL_GamepadButton)i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -440,29 +417,15 @@ void UpdateGamepadImageFromGamepad(GamepadImage *ctx, SDL_Gamepad *gamepad)
|
||||
return;
|
||||
}
|
||||
|
||||
ctx->type = SDL_GetGamepadType(gamepad);
|
||||
char *mapping = SDL_GetGamepadMapping(gamepad);
|
||||
SDL_GamepadType gamepad_type = SDL_GetGamepadType(gamepad);
|
||||
switch (gamepad_type) {
|
||||
case SDL_GAMEPAD_TYPE_PS3:
|
||||
case SDL_GAMEPAD_TYPE_PS4:
|
||||
case SDL_GAMEPAD_TYPE_PS5:
|
||||
ctx->face_style = GAMEPAD_IMAGE_FACE_SONY;
|
||||
break;
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO:
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT:
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT:
|
||||
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR:
|
||||
ctx->face_style = GAMEPAD_IMAGE_FACE_BAYX;
|
||||
break;
|
||||
default:
|
||||
if (mapping && SDL_strstr(mapping, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS")) {
|
||||
ctx->face_style = GAMEPAD_IMAGE_FACE_BAYX;
|
||||
} else {
|
||||
ctx->face_style = GAMEPAD_IMAGE_FACE_ABXY;
|
||||
if (mapping) {
|
||||
if (SDL_strstr(mapping, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS")) {
|
||||
/* Just for display purposes */
|
||||
ctx->type = SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO;
|
||||
}
|
||||
break;
|
||||
SDL_free(mapping);
|
||||
}
|
||||
SDL_free(mapping);
|
||||
|
||||
for (i = 0; i < SDL_GAMEPAD_BUTTON_TOUCHPAD; ++i) {
|
||||
const SDL_GamepadButton button = (SDL_GamepadButton)i;
|
||||
@ -557,7 +520,7 @@ void RenderGamepadImage(GamepadImage *ctx)
|
||||
|
||||
for (i = 0; i < SDL_arraysize(button_positions); ++i) {
|
||||
if (ctx->elements[i]) {
|
||||
SDL_GamepadButton button_position = GetRemappedButton(ctx->face_style, (SDL_GamepadButton)i);
|
||||
SDL_GamepadButton button_position = (SDL_GamepadButton)i;
|
||||
SDL_bool on_front = SDL_TRUE;
|
||||
|
||||
if (i >= SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1 && i <= SDL_GAMEPAD_BUTTON_LEFT_PADDLE2) {
|
||||
@ -579,14 +542,14 @@ void RenderGamepadImage(GamepadImage *ctx)
|
||||
dst.w = (float)ctx->face_width;
|
||||
dst.h = (float)ctx->face_height;
|
||||
|
||||
switch (ctx->face_style) {
|
||||
case GAMEPAD_IMAGE_FACE_ABXY:
|
||||
switch (SDL_GetGamepadButtonLabelForType(ctx->type, SDL_GAMEPAD_BUTTON_SOUTH)) {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_A:
|
||||
SDL_RenderTexture(ctx->renderer, ctx->face_abxy_texture, NULL, &dst);
|
||||
break;
|
||||
case GAMEPAD_IMAGE_FACE_BAYX:
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_B:
|
||||
SDL_RenderTexture(ctx->renderer, ctx->face_bayx_texture, NULL, &dst);
|
||||
break;
|
||||
case GAMEPAD_IMAGE_FACE_SONY:
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_CROSS:
|
||||
SDL_RenderTexture(ctx->renderer, ctx->face_sony_texture, NULL, &dst);
|
||||
break;
|
||||
default:
|
||||
@ -665,10 +628,10 @@ void DestroyGamepadImage(GamepadImage *ctx)
|
||||
|
||||
|
||||
static const char *gamepad_button_names[] = {
|
||||
"A",
|
||||
"B",
|
||||
"X",
|
||||
"Y",
|
||||
"South",
|
||||
"East",
|
||||
"West",
|
||||
"North",
|
||||
"Back",
|
||||
"Guide",
|
||||
"Start",
|
||||
@ -801,9 +764,49 @@ static SDL_bool GetBindingString(const char *label, char *mapping, char *text, s
|
||||
static SDL_bool GetButtonBindingString(SDL_GamepadButton button, char *mapping, char *text, size_t size)
|
||||
{
|
||||
char label[32];
|
||||
SDL_bool baxy_mapping = SDL_FALSE;
|
||||
|
||||
if (!mapping) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
||||
SDL_snprintf(label, sizeof(label), ",%s:", SDL_GetGamepadStringForButton(button));
|
||||
return GetBindingString(label, mapping, text, size);
|
||||
if (GetBindingString(label, mapping, text, size)) {
|
||||
return SDL_TRUE;
|
||||
}
|
||||
|
||||
/* Try the legacy button names */
|
||||
if (SDL_strstr(mapping, ",hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") != NULL) {
|
||||
baxy_mapping = SDL_TRUE;
|
||||
}
|
||||
switch (button) {
|
||||
case SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
if (baxy_mapping) {
|
||||
return GetBindingString(",b:", mapping, text, size);
|
||||
} else {
|
||||
return GetBindingString(",a:", mapping, text, size);
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_EAST:
|
||||
if (baxy_mapping) {
|
||||
return GetBindingString(",a:", mapping, text, size);
|
||||
} else {
|
||||
return GetBindingString(",b:", mapping, text, size);
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_WEST:
|
||||
if (baxy_mapping) {
|
||||
return GetBindingString(",y:", mapping, text, size);
|
||||
} else {
|
||||
return GetBindingString(",x:", mapping, text, size);
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_NORTH:
|
||||
if (baxy_mapping) {
|
||||
return GetBindingString(",x:", mapping, text, size);
|
||||
} else {
|
||||
return GetBindingString(",y:", mapping, text, size);
|
||||
}
|
||||
default:
|
||||
return SDL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_bool GetAxisBindingString(SDL_GamepadAxis axis, int direction, char *mapping, char *text, size_t size)
|
||||
@ -1707,7 +1710,7 @@ void RenderJoystickDisplay(JoystickDisplay *ctx, SDL_Joystick *joystick)
|
||||
highlight.h = (float)ctx->button_height;
|
||||
RenderJoystickButtonHighlight(ctx, i, &highlight);
|
||||
|
||||
SDL_snprintf(text, sizeof(text), "%2.d:", i);
|
||||
SDL_snprintf(text, sizeof(text), "%2d:", i);
|
||||
SDLTest_DrawString(ctx->renderer, x, y, text);
|
||||
|
||||
if (SDL_GetJoystickButton(joystick, (Uint8)i)) {
|
||||
@ -2224,9 +2227,11 @@ static int FindMappingKey(const MappingParts *parts, const char *key)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < parts->num_elements; ++i) {
|
||||
if (SDL_strcmp(key, parts->keys[i]) == 0) {
|
||||
return i;
|
||||
if (key) {
|
||||
for (i = 0; i < parts->num_elements; ++i) {
|
||||
if (SDL_strcmp(key, parts->keys[i]) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@ -2243,6 +2248,55 @@ static void RemoveMappingValueAt(MappingParts *parts, int index)
|
||||
}
|
||||
}
|
||||
|
||||
static void ConvertBAXYMapping(MappingParts *parts)
|
||||
{
|
||||
int i;
|
||||
SDL_bool baxy_mapping = SDL_FALSE;
|
||||
|
||||
for (i = 0; i < parts->num_elements; ++i) {
|
||||
const char *key = parts->keys[i];
|
||||
const char *value = parts->values[i];
|
||||
|
||||
if (SDL_strcmp(key, "hint") == 0 &&
|
||||
SDL_strcmp(value, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") == 0) {
|
||||
baxy_mapping = SDL_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!baxy_mapping) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Swap buttons, invert hint */
|
||||
for (i = 0; i < parts->num_elements; ++i) {
|
||||
char *key = parts->keys[i];
|
||||
char *value = parts->values[i];
|
||||
|
||||
if (SDL_strcmp(key, "a") == 0) {
|
||||
parts->keys[i] = SDL_strdup("b");
|
||||
SDL_free(key);
|
||||
} else if (SDL_strcmp(key, "b") == 0) {
|
||||
parts->keys[i] = SDL_strdup("a");
|
||||
SDL_free(key);
|
||||
} else if (SDL_strcmp(key, "x") == 0) {
|
||||
parts->keys[i] = SDL_strdup("y");
|
||||
SDL_free(key);
|
||||
} else if (SDL_strcmp(key, "y") == 0) {
|
||||
parts->keys[i] = SDL_strdup("x");
|
||||
SDL_free(key);
|
||||
} else if (SDL_strcmp(key, "hint") == 0 &&
|
||||
SDL_strcmp(value, "SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") == 0) {
|
||||
parts->values[i] = SDL_strdup("!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1");
|
||||
SDL_free(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void UpdateLegacyElements(MappingParts *parts)
|
||||
{
|
||||
ConvertBAXYMapping(parts);
|
||||
}
|
||||
|
||||
static SDL_bool CombineMappingAxes(MappingParts *parts)
|
||||
{
|
||||
int i, matching, axis;
|
||||
@ -2337,6 +2391,7 @@ static char *JoinMapping(MappingParts *parts)
|
||||
const char *name;
|
||||
MappingSortEntry *sort_order;
|
||||
|
||||
UpdateLegacyElements(parts);
|
||||
CombineMappingAxes(parts);
|
||||
|
||||
guid = parts->guid;
|
||||
@ -2420,6 +2475,43 @@ static char *RecreateMapping(MappingParts *parts, char *mapping)
|
||||
return mapping;
|
||||
}
|
||||
|
||||
static const char *GetLegacyKey(const char *key, SDL_bool baxy)
|
||||
{
|
||||
if (SDL_strcmp(key, SDL_GetGamepadStringForButton(SDL_GAMEPAD_BUTTON_SOUTH)) == 0) {
|
||||
if (baxy) {
|
||||
return "b";
|
||||
} else {
|
||||
return "a";
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_strcmp(key, SDL_GetGamepadStringForButton(SDL_GAMEPAD_BUTTON_EAST)) == 0) {
|
||||
if (baxy) {
|
||||
return "a";
|
||||
} else {
|
||||
return "b";
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_strcmp(key, SDL_GetGamepadStringForButton(SDL_GAMEPAD_BUTTON_WEST)) == 0) {
|
||||
if (baxy) {
|
||||
return "y";
|
||||
} else {
|
||||
return "x";
|
||||
}
|
||||
}
|
||||
|
||||
if (SDL_strcmp(key, SDL_GetGamepadStringForButton(SDL_GAMEPAD_BUTTON_NORTH)) == 0) {
|
||||
if (baxy) {
|
||||
return "y";
|
||||
} else {
|
||||
return "x";
|
||||
}
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
static SDL_bool MappingHasKey(const char *mapping, const char *key)
|
||||
{
|
||||
int i;
|
||||
@ -2428,6 +2520,14 @@ static SDL_bool MappingHasKey(const char *mapping, const char *key)
|
||||
|
||||
SplitMapping(mapping, &parts);
|
||||
i = FindMappingKey(&parts, key);
|
||||
if (i < 0) {
|
||||
SDL_bool baxy_mapping = SDL_FALSE;
|
||||
|
||||
if (mapping && SDL_strstr(mapping, ",hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") != NULL) {
|
||||
baxy_mapping = SDL_TRUE;
|
||||
}
|
||||
i = FindMappingKey(&parts, GetLegacyKey(key, baxy_mapping));
|
||||
}
|
||||
if (i >= 0) {
|
||||
result = SDL_TRUE;
|
||||
}
|
||||
@ -2444,6 +2544,14 @@ static char *GetMappingValue(const char *mapping, const char *key)
|
||||
|
||||
SplitMapping(mapping, &parts);
|
||||
i = FindMappingKey(&parts, key);
|
||||
if (i < 0) {
|
||||
SDL_bool baxy_mapping = SDL_FALSE;
|
||||
|
||||
if (mapping && SDL_strstr(mapping, ",hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1") != NULL) {
|
||||
baxy_mapping = SDL_TRUE;
|
||||
}
|
||||
i = FindMappingKey(&parts, GetLegacyKey(key, baxy_mapping));
|
||||
}
|
||||
if (i >= 0) {
|
||||
value = parts.values[i];
|
||||
parts.values[i] = NULL; /* So we don't free it */
|
||||
@ -2658,7 +2766,7 @@ SDL_GamepadType GetMappingType(const char *mapping)
|
||||
char *SetMappingType(char *mapping, SDL_GamepadType type)
|
||||
{
|
||||
const char *type_string = SDL_GetGamepadStringForType(type);
|
||||
if (type_string == NULL || type == SDL_GAMEPAD_TYPE_UNKNOWN) {
|
||||
if (!type_string || type == SDL_GAMEPAD_TYPE_UNKNOWN) {
|
||||
return RemoveMappingValue(mapping, "type");
|
||||
} else {
|
||||
return SetMappingValue(mapping, "type", type_string);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,6 @@ typedef enum
|
||||
CONTROLLER_MODE_BINDING,
|
||||
} ControllerDisplayMode;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GAMEPAD_IMAGE_FACE_BLANK,
|
||||
GAMEPAD_IMAGE_FACE_ABXY,
|
||||
GAMEPAD_IMAGE_FACE_BAYX,
|
||||
GAMEPAD_IMAGE_FACE_SONY,
|
||||
} GamepadImageFaceStyle;
|
||||
|
||||
enum
|
||||
{
|
||||
SDL_GAMEPAD_ELEMENT_INVALID = -1,
|
||||
@ -63,8 +55,8 @@ extern GamepadImage *CreateGamepadImage(SDL_Renderer *renderer);
|
||||
extern void SetGamepadImagePosition(GamepadImage *ctx, int x, int y);
|
||||
extern void GetGamepadImageArea(GamepadImage *ctx, SDL_Rect *area);
|
||||
extern void SetGamepadImageShowingFront(GamepadImage *ctx, SDL_bool showing_front);
|
||||
extern void SetGamepadImageFaceStyle(GamepadImage *ctx, GamepadImageFaceStyle face_style);
|
||||
extern GamepadImageFaceStyle GetGamepadImageFaceStyle(GamepadImage *ctx);
|
||||
extern void SetGamepadImageType(GamepadImage *ctx, SDL_GamepadType type);
|
||||
extern SDL_GamepadType GetGamepadImageType(GamepadImage *ctx);
|
||||
extern void SetGamepadImageDisplayMode(GamepadImage *ctx, ControllerDisplayMode display_mode);
|
||||
extern int GetGamepadImageButtonWidth(GamepadImage *ctx);
|
||||
extern int GetGamepadImageButtonHeight(GamepadImage *ctx);
|
||||
|
124
test/loopwave.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,10 +17,7 @@
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
@ -34,72 +31,28 @@ static struct
|
||||
} wave;
|
||||
|
||||
static SDL_AudioStream *stream;
|
||||
static SDLTest_CommonState *state;
|
||||
|
||||
static void fillerup(void)
|
||||
static int fillerup(void)
|
||||
{
|
||||
const int minimum = (wave.soundlen / SDL_AUDIO_FRAMESIZE(wave.spec)) / 2;
|
||||
if (SDL_GetAudioStreamQueued(stream) < minimum) {
|
||||
SDL_PutAudioStreamData(stream, wave.sound, wave.soundlen);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void
|
||||
quit(int rc)
|
||||
{
|
||||
SDL_Quit();
|
||||
/* Let 'main()' return normally */
|
||||
if (rc != 0) {
|
||||
exit(rc);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
close_audio(void)
|
||||
{
|
||||
if (stream) {
|
||||
SDL_DestroyAudioStream(stream);
|
||||
stream = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
open_audio(void)
|
||||
{
|
||||
stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, &wave.spec, NULL, NULL);
|
||||
if (!stream) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create audio stream: %s\n", SDL_GetError());
|
||||
SDL_free(wave.sound);
|
||||
quit(2);
|
||||
}
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
|
||||
}
|
||||
|
||||
|
||||
static int done = 0;
|
||||
|
||||
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
static void loop(void)
|
||||
{
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
} else {
|
||||
fillerup();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int SDL_AppInit(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
char *filename = NULL;
|
||||
SDLTest_CommonState *state;
|
||||
|
||||
/* this doesn't have to run very much, so give up tons of CPU time between iterations. */
|
||||
SDL_SetHint(SDL_HINT_MAIN_CALLBACK_RATE, "5");
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -129,22 +82,25 @@ int main(int argc, char *argv[])
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(SDL_INIT_AUDIO | SDL_INIT_EVENTS) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
if (!filename) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
quit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
quit(1);
|
||||
SDL_free(filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_free(filename);
|
||||
|
||||
/* Show the list of available drivers */
|
||||
SDL_Log("Available audio drivers:");
|
||||
for (i = 0; i < SDL_GetNumAudioDrivers(); ++i) {
|
||||
@ -153,30 +109,30 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_Log("Using audio driver: %s\n", SDL_GetCurrentAudioDriver());
|
||||
|
||||
open_audio();
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event) > 0) {
|
||||
if (event.type == SDL_EVENT_QUIT) {
|
||||
done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
fillerup();
|
||||
SDL_Delay(100);
|
||||
stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, &wave.spec, NULL, NULL);
|
||||
if (!stream) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create audio stream: %s\n", SDL_GetError());
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
|
||||
|
||||
/* Clean up on signal */
|
||||
close_audio();
|
||||
SDL_free(wave.sound);
|
||||
SDL_free(filename);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_AppEvent(const SDL_Event *event)
|
||||
{
|
||||
return (event->type == SDL_EVENT_QUIT) ? 1 : 0;
|
||||
}
|
||||
|
||||
int SDL_AppIterate(void)
|
||||
{
|
||||
return fillerup();
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void)
|
||||
{
|
||||
SDL_DestroyAudioStream(stream);
|
||||
SDL_free(wave.sound);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,12 +22,15 @@
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Uint64 start;
|
||||
Uint64 prequit;
|
||||
(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);
|
||||
prequit = SDL_GetTicks();
|
||||
SDL_Log("SDL_GetPrefPath took %" SDL_PRIu64 "ms", prequit - start);
|
||||
SDL_Quit();
|
||||
SDL_Log("SDL_Quit took %" SDL_PRIu64 "ms", SDL_GetTicks() - prequit);
|
||||
return 0;
|
||||
}
|
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 1.6 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 401 KiB |
Before Width: | Height: | Size: 192 KiB |
Before Width: | Height: | Size: 256 KiB |
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,28 +50,28 @@ static void RunBasicTest(void)
|
||||
SDL_Log("\natomic -----------------------------------------\n\n");
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
tfret = SDL_AtomicSet(&v, 10) == 0 ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = SDL_AtomicSet(&v, 10) == 0;
|
||||
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = SDL_AtomicAdd(&v, 10) == 10 ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = SDL_AtomicAdd(&v, 10) == 10;
|
||||
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 1) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicGet(&v) == 1);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 2) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicGet(&v) == 2);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 10);
|
||||
tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicCAS(&v, 0, 20) == SDL_FALSE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
value = SDL_AtomicGet(&v);
|
||||
tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE) ? SDL_TRUE : SDL_FALSE;
|
||||
tfret = (SDL_AtomicCAS(&v, value, 20) == SDL_TRUE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
}
|
||||
|
||||
@ -701,7 +701,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
589
test/testaudio.c
@ -1,9 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include <SDL3/SDL_test_common.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
@ -75,7 +70,7 @@ struct Thing
|
||||
} poof;
|
||||
struct {
|
||||
SDL_AudioStream *stream;
|
||||
int total_ticks;
|
||||
int total_bytes;
|
||||
Uint64 next_level_update;
|
||||
Uint8 levels[5];
|
||||
} stream;
|
||||
@ -103,7 +98,6 @@ struct Thing
|
||||
|
||||
|
||||
static Uint64 app_ready_ticks = 0;
|
||||
static int done = 0;
|
||||
static SDLTest_CommonState *state = NULL;
|
||||
|
||||
static Thing *things = NULL;
|
||||
@ -113,6 +107,9 @@ static Thing *mouseover_thing = NULL;
|
||||
static Thing *droppable_highlighted_thing = NULL;
|
||||
static Thing *dragging_thing = NULL;
|
||||
static int dragging_button = -1;
|
||||
static int dragging_button_real = -1;
|
||||
static SDL_bool ctrl_held = SDL_FALSE;
|
||||
static SDL_bool alt_held = SDL_FALSE;
|
||||
|
||||
static Texture *physdev_texture = NULL;
|
||||
static Texture *logdev_texture = NULL;
|
||||
@ -121,51 +118,6 @@ static Texture *trashcan_texture = NULL;
|
||||
static Texture *soundboard_texture = NULL;
|
||||
static Texture *soundboard_levels_texture = NULL;
|
||||
|
||||
static void DestroyTexture(Texture *tex);
|
||||
static void DestroyThing(Thing *thing);
|
||||
|
||||
|
||||
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
|
||||
static void Quit(int rc)
|
||||
{
|
||||
while (things != NULL) {
|
||||
DestroyThing(things); /* make sure all the audio devices are closed, etc. */
|
||||
}
|
||||
|
||||
DestroyTexture(physdev_texture);
|
||||
DestroyTexture(logdev_texture);
|
||||
DestroyTexture(audio_texture);
|
||||
DestroyTexture(trashcan_texture);
|
||||
DestroyTexture(soundboard_texture);
|
||||
DestroyTexture(soundboard_levels_texture);
|
||||
SDLTest_CommonQuit(state);
|
||||
|
||||
/* Let 'main()' return normally */
|
||||
if (rc != 0) {
|
||||
exit(rc);
|
||||
}
|
||||
}
|
||||
|
||||
static char *xstrdup(const char *str)
|
||||
{
|
||||
char *ptr = SDL_strdup(str);
|
||||
if (!ptr) {
|
||||
SDL_Log("Out of memory!");
|
||||
Quit(1);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static void *xalloc(const size_t len)
|
||||
{
|
||||
void *ptr = SDL_calloc(1, len);
|
||||
if (!ptr) {
|
||||
SDL_Log("Out of memory!");
|
||||
Quit(1);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
static void SetTitleBar(const char *fmt, ...)
|
||||
{
|
||||
@ -194,7 +146,7 @@ static Thing *FindThingAtPoint(const float x, const float y)
|
||||
const SDL_FPoint pt = { x, y };
|
||||
Thing *retval = NULL;
|
||||
Thing *i;
|
||||
for (i = things; i != NULL; i = i->next) {
|
||||
for (i = things; i; i = i->next) {
|
||||
if ((i != dragging_thing) && SDL_PointInRectFloat(&pt, &i->rect)) {
|
||||
retval = i; /* keep going, though, because things drawn on top are later in the list. */
|
||||
}
|
||||
@ -229,7 +181,12 @@ static Thing *CreateThing(ThingType what, float x, float y, float z, float w, fl
|
||||
Thing *i;
|
||||
Thing *thing;
|
||||
|
||||
thing = (Thing *) xalloc(sizeof (Thing));
|
||||
thing = (Thing *) SDL_calloc(1, sizeof (Thing));
|
||||
if (!thing) {
|
||||
SDL_Log("Out of memory!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((w < 0) || (h < 0)) {
|
||||
SDL_assert(texture != NULL);
|
||||
if (w < 0) {
|
||||
@ -253,15 +210,15 @@ static Thing *CreateThing(ThingType what, float x, float y, float z, float w, fl
|
||||
thing->scale = 1.0f;
|
||||
thing->createticks = SDL_GetTicks();
|
||||
thing->texture = texture;
|
||||
thing->titlebar = titlebar ? xstrdup(titlebar) : NULL;
|
||||
thing->titlebar = titlebar ? SDL_strdup(titlebar) : NULL; /* if allocation fails, oh well. */
|
||||
|
||||
/* insert in list by Z order (furthest from the "camera" first, so they get drawn over; negative Z is not drawn at all). */
|
||||
if (things == NULL) {
|
||||
if (!things) {
|
||||
things = thing;
|
||||
return thing;
|
||||
}
|
||||
|
||||
for (i = things; i != NULL; i = i->next) {
|
||||
for (i = things; i; i = i->next) {
|
||||
if (z > i->z) { /* insert here. */
|
||||
thing->next = i;
|
||||
thing->prev = i->prev;
|
||||
@ -313,7 +270,9 @@ static void DestroyThing(Thing *thing)
|
||||
case THING_LOGDEV:
|
||||
case THING_LOGDEV_CAPTURE:
|
||||
SDL_CloseAudioDevice(thing->data.logdev.devid);
|
||||
SDL_DestroyTexture(thing->data.logdev.visualizer);
|
||||
if (state->renderers[0] != NULL) {
|
||||
SDL_DestroyTexture(thing->data.logdev.visualizer);
|
||||
}
|
||||
SDL_DestroyMutex(thing->data.logdev.postmix_lock);
|
||||
SDL_free(thing->data.logdev.postmix_buffer);
|
||||
break;
|
||||
@ -354,9 +313,10 @@ static void DrawOneThing(SDL_Renderer *renderer, Thing *thing)
|
||||
if (thing->scale != 1.0f) {
|
||||
const float centerx = thing->rect.x + (thing->rect.w / 2);
|
||||
const float centery = thing->rect.y + (thing->rect.h / 2);
|
||||
SDL_assert(thing->texture != NULL);
|
||||
dst.w = thing->texture->w * thing->scale;
|
||||
dst.h = thing->texture->h * thing->scale;
|
||||
const int w = thing->texture ? (int) thing->texture->w : 128;
|
||||
const int h = thing->texture ? (int) thing->texture->h : 128;
|
||||
dst.w = w * thing->scale;
|
||||
dst.h = h * thing->scale;
|
||||
dst.x = centerx - (dst.w / 2);
|
||||
dst.y = centery - (dst.h / 2);
|
||||
}
|
||||
@ -413,11 +373,13 @@ static void DrawThings(SDL_Renderer *renderer)
|
||||
static void Draw(void)
|
||||
{
|
||||
SDL_Renderer *renderer = state->renderers[0];
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(renderer, 64, 0, 64, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
DrawThings(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
if (renderer) { /* might be NULL if we're shutting down. */
|
||||
SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND);
|
||||
SDL_SetRenderDrawColor(renderer, 64, 0, 64, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
DrawThings(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
static void RepositionRowOfThings(const ThingType what, const float y)
|
||||
@ -427,7 +389,7 @@ static void RepositionRowOfThings(const ThingType what, const float y)
|
||||
float texh = 0.0f;
|
||||
Thing *i;
|
||||
|
||||
for (i = things; i != NULL; i = i->next) {
|
||||
for (i = things; i; i = i->next) {
|
||||
if (i->what == what) {
|
||||
texw = i->rect.w;
|
||||
texh = i->rect.h;
|
||||
@ -440,7 +402,7 @@ static void RepositionRowOfThings(const ThingType what, const float y)
|
||||
SDL_GetWindowSize(state->windows[0], &w, &h);
|
||||
const float spacing = w / ((float) total_things);
|
||||
float x = (spacing - texw) / 2.0f;
|
||||
for (i = things; i != NULL; i = i->next) {
|
||||
for (i = things; i; i = i->next) {
|
||||
if (i->what == what) {
|
||||
i->rect.x = x;
|
||||
i->rect.y = (y >= 0.0f) ? y : ((h + y) - texh);
|
||||
@ -507,12 +469,14 @@ static Thing *CreatePoofThing(Thing *poofing_thing)
|
||||
const float centery = poofing_thing->rect.y + (poofing_thing->rect.h / 2);
|
||||
const float z = poofing_thing->z;
|
||||
Thing *thing = CreateThing(THING_POOF, poofing_thing->rect.x, poofing_thing->rect.y, z, poofing_thing->rect.w, poofing_thing->rect.h, poofing_thing->texture, NULL);
|
||||
thing->data.poof.startw = poofing_thing->rect.w;
|
||||
thing->data.poof.starth = poofing_thing->rect.h;
|
||||
thing->data.poof.centerx = centerx;
|
||||
thing->data.poof.centery = centery;
|
||||
thing->ontick = PoofThing_ontick;
|
||||
thing->ondrag = PoofThing_ondrag;
|
||||
if (thing) {
|
||||
thing->data.poof.startw = poofing_thing->rect.w;
|
||||
thing->data.poof.starth = poofing_thing->rect.h;
|
||||
thing->data.poof.centerx = centerx;
|
||||
thing->data.poof.centery = centery;
|
||||
thing->ontick = PoofThing_ontick;
|
||||
thing->ondrag = PoofThing_ondrag;
|
||||
}
|
||||
return thing;
|
||||
}
|
||||
|
||||
@ -530,7 +494,7 @@ static void DestroyThingInPoof(Thing *thing)
|
||||
static void TrashThing(Thing *thing)
|
||||
{
|
||||
Thing *i, *next;
|
||||
for (i = things; i != NULL; i = next) {
|
||||
for (i = things; i; i = next) {
|
||||
next = i->next;
|
||||
if (i->line_connected_to == thing) {
|
||||
TrashThing(i);
|
||||
@ -549,13 +513,11 @@ static void StreamThing_ontick(Thing *thing, Uint64 now)
|
||||
/* are we playing? See if we're done, or update state. */
|
||||
if (thing->line_connected_to->what == THING_LOGDEV) {
|
||||
const int available = SDL_GetAudioStreamAvailable(thing->data.stream.stream);
|
||||
SDL_AudioSpec spec;
|
||||
if (!available || (SDL_GetAudioStreamFormat(thing->data.stream.stream, NULL, &spec) < 0)) {
|
||||
if (!available) {
|
||||
DestroyThingInPoof(thing);
|
||||
return;
|
||||
} else {
|
||||
const int ticksleft = (int) ((((Uint64) (available / SDL_AUDIO_FRAMESIZE(spec))) * 1000) / spec.freq);
|
||||
const float pct = thing->data.stream.total_ticks ? (((float) (ticksleft)) / ((float) thing->data.stream.total_ticks)) : 0.0f;
|
||||
thing->progress = 1.0f - pct;
|
||||
thing->progress = 1.0f - (thing->data.stream.total_bytes ? (((float) (available)) / ((float) thing->data.stream.total_bytes)) : 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -575,6 +537,9 @@ static void StreamThing_ondrag(Thing *thing, int button, float x, float y)
|
||||
if (button == SDL_BUTTON_RIGHT) { /* this is kinda hacky, but use this to disconnect from a playing source. */
|
||||
if (thing->line_connected_to) {
|
||||
SDL_UnbindAudioStream(thing->data.stream.stream); /* unbind from current device */
|
||||
if (thing->line_connected_to->what == THING_LOGDEV_CAPTURE) {
|
||||
SDL_FlushAudioStream(thing->data.stream.stream);
|
||||
}
|
||||
thing->line_connected_to = NULL;
|
||||
}
|
||||
}
|
||||
@ -589,16 +554,14 @@ static void StreamThing_ondrop(Thing *thing, int button, float x, float y)
|
||||
/* connect to a logical device! */
|
||||
SDL_Log("Binding audio stream ('%s') to logical device %u", thing->titlebar, (unsigned int) droppable_highlighted_thing->data.logdev.devid);
|
||||
if (thing->line_connected_to) {
|
||||
const SDL_AudioSpec *spec = &droppable_highlighted_thing->data.logdev.spec;
|
||||
SDL_UnbindAudioStream(thing->data.stream.stream); /* unbind from current device */
|
||||
if (thing->line_connected_to->what == THING_LOGDEV_CAPTURE) {
|
||||
SDL_FlushAudioStream(thing->data.stream.stream);
|
||||
thing->data.stream.total_ticks = (int) ((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / SDL_AUDIO_FRAMESIZE(*spec))) * 1000) / spec->freq);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_BindAudioStream(droppable_highlighted_thing->data.logdev.devid, thing->data.stream.stream); /* bind to new device! */
|
||||
|
||||
thing->data.stream.total_bytes = SDL_GetAudioStreamAvailable(thing->data.stream.stream);
|
||||
thing->progress = 0.0f; /* ontick will adjust this if we're on an output device.*/
|
||||
thing->data.stream.next_level_update = SDL_GetTicks() + 100;
|
||||
thing->line_connected_to = droppable_highlighted_thing;
|
||||
@ -631,18 +594,20 @@ static Thing *CreateStreamThing(const SDL_AudioSpec *spec, const Uint8 *buf, con
|
||||
{
|
||||
static const ThingType can_be_dropped_onto[] = { THING_TRASHCAN, THING_LOGDEV, THING_LOGDEV_CAPTURE, THING_NULL };
|
||||
Thing *thing = CreateThing(THING_STREAM, x, y, 0, -1, -1, soundboard_texture, fname);
|
||||
SDL_Log("Adding audio stream for %s", fname ? fname : "(null)");
|
||||
thing->data.stream.stream = SDL_CreateAudioStream(spec, spec);
|
||||
if (buf && buflen) {
|
||||
SDL_PutAudioStreamData(thing->data.stream.stream, buf, (int) buflen);
|
||||
SDL_FlushAudioStream(thing->data.stream.stream);
|
||||
thing->data.stream.total_ticks = (int) ((((Uint64) (SDL_GetAudioStreamAvailable(thing->data.stream.stream) / SDL_AUDIO_FRAMESIZE(*spec))) * 1000) / spec->freq);
|
||||
if (thing) {
|
||||
SDL_Log("Adding audio stream for %s", fname ? fname : "(null)");
|
||||
thing->data.stream.stream = SDL_CreateAudioStream(spec, spec);
|
||||
if (buf && buflen) {
|
||||
SDL_PutAudioStreamData(thing->data.stream.stream, buf, (int) buflen);
|
||||
SDL_FlushAudioStream(thing->data.stream.stream);
|
||||
thing->data.stream.total_bytes = SDL_GetAudioStreamAvailable(thing->data.stream.stream);
|
||||
}
|
||||
thing->ontick = StreamThing_ontick;
|
||||
thing->ondrag = StreamThing_ondrag;
|
||||
thing->ondrop = StreamThing_ondrop;
|
||||
thing->ondraw = StreamThing_ondraw;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
}
|
||||
thing->ontick = StreamThing_ontick;
|
||||
thing->ondrag = StreamThing_ondrag;
|
||||
thing->ondrop = StreamThing_ondrop;
|
||||
thing->ondraw = StreamThing_ondraw;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
return thing;
|
||||
}
|
||||
|
||||
@ -696,13 +661,15 @@ static Thing *LoadWavThing(const char *fname, float x, float y)
|
||||
|
||||
SDL_asprintf(&titlebar, "WAV file (\"%s\", %s, %s, %uHz)", nodirs, AudioFmtToString(spec.format), AudioChansToStr(spec.channels), (unsigned int) spec.freq);
|
||||
thing = CreateThing(THING_WAV, x - (audio_texture->w / 2), y - (audio_texture->h / 2), 5, -1, -1, audio_texture, titlebar);
|
||||
SDL_free(titlebar);
|
||||
SDL_memcpy(&thing->data.wav.spec, &spec, sizeof (SDL_AudioSpec));
|
||||
thing->data.wav.buf = buf;
|
||||
thing->data.wav.buflen = buflen;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
thing->ondrag = WavThing_ondrag;
|
||||
thing->ondrop = WavThing_ondrop;
|
||||
if (thing) {
|
||||
SDL_free(titlebar);
|
||||
SDL_memcpy(&thing->data.wav.spec, &spec, sizeof (SDL_AudioSpec));
|
||||
thing->data.wav.buf = buf;
|
||||
thing->data.wav.buflen = buflen;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
thing->ondrag = WavThing_ondrag;
|
||||
thing->ondrop = WavThing_ondrop;
|
||||
}
|
||||
}
|
||||
|
||||
SDL_free(path);
|
||||
@ -727,24 +694,30 @@ static void LoadStockWavThings(void)
|
||||
static void DestroyTexture(Texture *tex)
|
||||
{
|
||||
if (tex) {
|
||||
SDL_DestroyTexture(tex->texture);
|
||||
if (state->renderers[0] != NULL) { /* if the renderer went away, this pointer is already bogus. */
|
||||
SDL_DestroyTexture(tex->texture);
|
||||
}
|
||||
SDL_free(tex);
|
||||
}
|
||||
}
|
||||
|
||||
static Texture *CreateTexture(const char *fname)
|
||||
{
|
||||
Texture *tex = (Texture *) xalloc(sizeof (Texture));
|
||||
int texw, texh;
|
||||
tex->texture = LoadTexture(state->renderers[0], fname, SDL_TRUE, &texw, &texh);
|
||||
if (!tex->texture) {
|
||||
SDL_Log("Failed to load '%s': %s", fname, SDL_GetError());
|
||||
SDL_free(tex);
|
||||
Quit(1);
|
||||
Texture *tex = (Texture *) SDL_calloc(1, sizeof (Texture));
|
||||
if (!tex) {
|
||||
SDL_Log("Out of memory!");
|
||||
} else {
|
||||
int texw, texh;
|
||||
tex->texture = LoadTexture(state->renderers[0], fname, SDL_TRUE, &texw, &texh);
|
||||
if (!tex->texture) {
|
||||
SDL_Log("Failed to load '%s': %s", fname, SDL_GetError());
|
||||
SDL_free(tex);
|
||||
return NULL;
|
||||
}
|
||||
SDL_SetTextureBlendMode(tex->texture, SDL_BLENDMODE_BLEND);
|
||||
tex->w = (float) texw;
|
||||
tex->h = (float) texh;
|
||||
}
|
||||
SDL_SetTextureBlendMode(tex->texture, SDL_BLENDMODE_BLEND);
|
||||
tex->w = (float) texw;
|
||||
tex->h = (float) texh;
|
||||
return tex;
|
||||
}
|
||||
|
||||
@ -754,9 +727,11 @@ static void DeviceThing_ondrag(Thing *thing, int button, float x, float y)
|
||||
{
|
||||
if ((button == SDL_BUTTON_MIDDLE) && (thing->what == THING_LOGDEV_CAPTURE)) { /* drag out a new stream. This is a UX mess. :/ */
|
||||
dragging_thing = CreateStreamThing(&thing->data.logdev.spec, NULL, 0, NULL, x, y);
|
||||
dragging_thing->data.stream.next_level_update = SDL_GetTicks() + 100;
|
||||
SDL_BindAudioStream(thing->data.logdev.devid, dragging_thing->data.stream.stream); /* bind to new device! */
|
||||
dragging_thing->line_connected_to = thing;
|
||||
if (dragging_thing) {
|
||||
dragging_thing->data.stream.next_level_update = SDL_GetTicks() + 100;
|
||||
SDL_BindAudioStream(thing->data.logdev.devid, dragging_thing->data.stream.stream); /* bind to new device! */
|
||||
dragging_thing->line_connected_to = thing;
|
||||
}
|
||||
} else if (button == SDL_BUTTON_RIGHT) { /* drag out a new logical device. */
|
||||
const SDL_AudioDeviceID which = ((thing->what == THING_LOGDEV) || (thing->what == THING_LOGDEV_CAPTURE)) ? thing->data.logdev.devid : thing->data.physdev.devid;
|
||||
const SDL_AudioDeviceID devid = SDL_OpenAudioDevice(which, NULL);
|
||||
@ -858,7 +833,7 @@ static void UpdateVisualizer(SDL_Renderer *renderer, SDL_Texture *visualizer, co
|
||||
|
||||
static void LogicalDeviceThing_ontick(Thing *thing, Uint64 now)
|
||||
{
|
||||
const SDL_bool ismousedover = (thing == mouseover_thing) ? SDL_TRUE : SDL_FALSE;
|
||||
const SDL_bool ismousedover = (thing == mouseover_thing);
|
||||
|
||||
if (!thing->data.logdev.visualizer || !thing->data.logdev.postmix_lock) { /* need these to work, skip if they failed. */
|
||||
return;
|
||||
@ -920,22 +895,24 @@ static Thing *CreateLogicalDeviceThing(Thing *parent, const SDL_AudioDeviceID wh
|
||||
|
||||
SDL_Log("Adding logical audio device %u", (unsigned int) which);
|
||||
thing = CreateThing(iscapture ? THING_LOGDEV_CAPTURE : THING_LOGDEV, x, y, 5, -1, -1, logdev_texture, NULL);
|
||||
thing->data.logdev.devid = which;
|
||||
thing->data.logdev.iscapture = iscapture;
|
||||
thing->data.logdev.physdev = physthing;
|
||||
thing->data.logdev.visualizer = SDL_CreateTexture(state->renderers[0], SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, VISUALIZER_WIDTH, VISUALIZER_HEIGHT);
|
||||
thing->data.logdev.postmix_lock = SDL_CreateMutex();
|
||||
if (thing->data.logdev.visualizer) {
|
||||
SDL_SetTextureBlendMode(thing->data.logdev.visualizer, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
thing->line_connected_to = physthing;
|
||||
thing->ontick = LogicalDeviceThing_ontick;
|
||||
thing->ondrag = DeviceThing_ondrag;
|
||||
thing->ondrop = LogicalDeviceThing_ondrop;
|
||||
thing->ondraw = LogicalDeviceThing_ondraw;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
if (thing) {
|
||||
thing->data.logdev.devid = which;
|
||||
thing->data.logdev.iscapture = iscapture;
|
||||
thing->data.logdev.physdev = physthing;
|
||||
thing->data.logdev.visualizer = SDL_CreateTexture(state->renderers[0], SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, VISUALIZER_WIDTH, VISUALIZER_HEIGHT);
|
||||
thing->data.logdev.postmix_lock = SDL_CreateMutex();
|
||||
if (thing->data.logdev.visualizer) {
|
||||
SDL_SetTextureBlendMode(thing->data.logdev.visualizer, SDL_BLENDMODE_BLEND);
|
||||
}
|
||||
thing->line_connected_to = physthing;
|
||||
thing->ontick = LogicalDeviceThing_ontick;
|
||||
thing->ondrag = DeviceThing_ondrag;
|
||||
thing->ondrop = LogicalDeviceThing_ondrop;
|
||||
thing->ondraw = LogicalDeviceThing_ondraw;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
|
||||
SetLogicalDeviceTitlebar(thing);
|
||||
SetLogicalDeviceTitlebar(thing);
|
||||
}
|
||||
return thing;
|
||||
}
|
||||
|
||||
@ -993,21 +970,23 @@ static Thing *CreatePhysicalDeviceThing(const SDL_AudioDeviceID which, const SDL
|
||||
|
||||
SDL_Log("Adding physical audio device %u", (unsigned int) which);
|
||||
thing = CreateThing(iscapture ? THING_PHYSDEV_CAPTURE : THING_PHYSDEV, next_physdev_x, 170, 5, -1, -1, physdev_texture, NULL);
|
||||
thing->data.physdev.devid = which;
|
||||
thing->data.physdev.iscapture = iscapture;
|
||||
thing->data.physdev.name = SDL_GetAudioDeviceName(which);
|
||||
thing->ondrag = DeviceThing_ondrag;
|
||||
thing->ondrop = PhysicalDeviceThing_ondrop;
|
||||
thing->ontick = PhysicalDeviceThing_ontick;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
if (thing) {
|
||||
thing->data.physdev.devid = which;
|
||||
thing->data.physdev.iscapture = iscapture;
|
||||
thing->data.physdev.name = SDL_GetAudioDeviceName(which);
|
||||
thing->ondrag = DeviceThing_ondrag;
|
||||
thing->ondrop = PhysicalDeviceThing_ondrop;
|
||||
thing->ontick = PhysicalDeviceThing_ontick;
|
||||
thing->can_be_dropped_onto = can_be_dropped_onto;
|
||||
|
||||
SetPhysicalDeviceTitlebar(thing);
|
||||
if (SDL_GetTicks() <= (app_ready_ticks + 2000)) { /* assume this is the initial batch if it happens in the first two seconds. */
|
||||
RepositionRowOfThings(THING_PHYSDEV, 10.0f); /* don't rearrange them after the initial add. */
|
||||
RepositionRowOfThings(THING_PHYSDEV_CAPTURE, 170.0f); /* don't rearrange them after the initial add. */
|
||||
next_physdev_x = 0.0f;
|
||||
} else {
|
||||
next_physdev_x += physdev_texture->w * 1.5f;
|
||||
SetPhysicalDeviceTitlebar(thing);
|
||||
if (SDL_GetTicks() <= (app_ready_ticks + 2000)) { /* assume this is the initial batch if it happens in the first two seconds. */
|
||||
RepositionRowOfThings(THING_PHYSDEV, 10.0f); /* don't rearrange them after the initial add. */
|
||||
RepositionRowOfThings(THING_PHYSDEV_CAPTURE, 170.0f); /* don't rearrange them after the initial add. */
|
||||
next_physdev_x = 0.0f;
|
||||
} else {
|
||||
next_physdev_x += physdev_texture->w * 1.5f;
|
||||
}
|
||||
}
|
||||
|
||||
return thing;
|
||||
@ -1030,7 +1009,7 @@ static void TickThings(void)
|
||||
Thing *i;
|
||||
Thing *next;
|
||||
const Uint64 now = SDL_GetTicks();
|
||||
for (i = things; i != NULL; i = next) {
|
||||
for (i = things; i; i = next) {
|
||||
next = i->next; /* in case this deletes itself. */
|
||||
if (i->ontick) {
|
||||
i->ontick(i, now);
|
||||
@ -1045,7 +1024,7 @@ static void WindowResized(const int newwinw, const int newwinh)
|
||||
const float newh = (float) newwinh;
|
||||
const float oldw = (float) state->window_w;
|
||||
const float oldh = (float) state->window_h;
|
||||
for (i = things; i != NULL; i = i->next) {
|
||||
for (i = things; i; i = i->next) {
|
||||
const float halfw = i->rect.w / 2.0f;
|
||||
const float halfh = i->rect.h / 2.0f;
|
||||
const float x = (i->rect.x + halfw) / oldw;
|
||||
@ -1057,140 +1036,13 @@ static void WindowResized(const int newwinw, const int newwinh)
|
||||
state->window_h = newwinh;
|
||||
}
|
||||
|
||||
|
||||
static void Loop(void)
|
||||
{
|
||||
SDL_Event event;
|
||||
SDL_bool saw_event = SDL_FALSE;
|
||||
|
||||
if (app_ready_ticks == 0) {
|
||||
app_ready_ticks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
Thing *thing = NULL;
|
||||
|
||||
saw_event = SDL_TRUE;
|
||||
|
||||
switch (event.type) {
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
thing = UpdateMouseOver(event.motion.x, event.motion.y);
|
||||
if ((dragging_button == -1) && event.motion.state) {
|
||||
if (event.motion.state & SDL_BUTTON_LMASK) {
|
||||
dragging_button = SDL_BUTTON_LEFT;
|
||||
} else if (event.motion.state & SDL_BUTTON_RMASK) {
|
||||
dragging_button = SDL_BUTTON_RIGHT;
|
||||
} else if (event.motion.state & SDL_BUTTON_MMASK) {
|
||||
dragging_button = SDL_BUTTON_MIDDLE;
|
||||
}
|
||||
|
||||
|
||||
if (dragging_button != -1) {
|
||||
dragging_thing = thing;
|
||||
if (thing && thing->ondrag) {
|
||||
thing->ondrag(thing, dragging_button, event.motion.x, event.motion.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
droppable_highlighted_thing = NULL;
|
||||
if (dragging_thing) {
|
||||
dragging_thing->rect.x = event.motion.x - (dragging_thing->rect.w / 2);
|
||||
dragging_thing->rect.y = event.motion.y - (dragging_thing->rect.h / 2);
|
||||
if (dragging_thing->can_be_dropped_onto) {
|
||||
thing = FindThingAtPoint(event.motion.x, event.motion.y);
|
||||
if (thing) {
|
||||
int i;
|
||||
for (i = 0; dragging_thing->can_be_dropped_onto[i]; i++) {
|
||||
if (dragging_thing->can_be_dropped_onto[i] == thing->what) {
|
||||
droppable_highlighted_thing = thing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
thing = UpdateMouseOver(event.button.x, event.button.y);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
if (dragging_button == event.button.button) {
|
||||
Thing *dropped_thing = dragging_thing;
|
||||
dragging_thing = NULL;
|
||||
dragging_button = -1;
|
||||
if (dropped_thing && dropped_thing->ondrop) {
|
||||
dropped_thing->ondrop(dropped_thing, event.button.button, event.button.x, event.button.y);
|
||||
}
|
||||
droppable_highlighted_thing = NULL;
|
||||
}
|
||||
thing = UpdateMouseOver(event.button.x, event.button.y);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
UpdateMouseOver(event.wheel.mouseX, event.wheel.mouseY);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_DROP_FILE:
|
||||
SDL_Log("Drop file! '%s'", event.drop.file);
|
||||
LoadWavThing(event.drop.file, event.drop.x, event.drop.y);
|
||||
/* SDLTest_CommonEvent will free the string, below. */
|
||||
break;
|
||||
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
WindowResized(event.window.data1, event.window.data2);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_AUDIO_DEVICE_ADDED:
|
||||
CreatePhysicalDeviceThing(event.adevice.which, event.adevice.iscapture);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_AUDIO_DEVICE_REMOVED: {
|
||||
const SDL_AudioDeviceID which = event.adevice.which;
|
||||
Thing *i, *next;
|
||||
SDL_Log("Removing audio device %u", (unsigned int) which);
|
||||
for (i = things; i != NULL; i = next) {
|
||||
next = i->next;
|
||||
if (((i->what == THING_PHYSDEV) || (i->what == THING_PHYSDEV_CAPTURE)) && (i->data.physdev.devid == which)) {
|
||||
TrashThing(i);
|
||||
next = things; /* in case we mangled the list. */
|
||||
} else if (((i->what == THING_LOGDEV) || (i->what == THING_LOGDEV_CAPTURE)) && (i->data.logdev.devid == which)) {
|
||||
TrashThing(i);
|
||||
next = things; /* in case we mangled the list. */
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
}
|
||||
|
||||
TickThings();
|
||||
Draw();
|
||||
|
||||
if (!saw_event) {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
if (done) {
|
||||
emscripten_cancel_main_loop();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int SDL_AppInit(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||
if (state == NULL) {
|
||||
Quit(1);
|
||||
if (!state) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
state->window_flags |= SDL_WINDOW_RESIZABLE;
|
||||
@ -1208,13 +1060,13 @@ int main(int argc, char *argv[])
|
||||
NULL
|
||||
};
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
Quit(1);
|
||||
return -1;
|
||||
}
|
||||
i += consumed;
|
||||
}
|
||||
|
||||
if (!SDLTest_CommonInit(state)) {
|
||||
Quit(2);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (state->audio_id) {
|
||||
@ -1224,27 +1076,174 @@ int main(int argc, char *argv[])
|
||||
|
||||
SetDefaultTitleBar();
|
||||
|
||||
physdev_texture = CreateTexture("physaudiodev.bmp");
|
||||
logdev_texture = CreateTexture("logaudiodev.bmp");
|
||||
audio_texture = CreateTexture("audiofile.bmp");
|
||||
trashcan_texture = CreateTexture("trashcan.bmp");
|
||||
soundboard_texture = CreateTexture("soundboard.bmp");
|
||||
soundboard_levels_texture = CreateTexture("soundboard_levels.bmp");
|
||||
if ((physdev_texture = CreateTexture("physaudiodev.bmp")) == NULL) { return -1; }
|
||||
if ((logdev_texture = CreateTexture("logaudiodev.bmp")) == NULL) { return -1; }
|
||||
if ((audio_texture = CreateTexture("audiofile.bmp")) == NULL) { return -1; }
|
||||
if ((trashcan_texture = CreateTexture("trashcan.bmp")) == NULL) { return -1; }
|
||||
if ((soundboard_texture = CreateTexture("soundboard.bmp")) == NULL) { return -1; }
|
||||
if ((soundboard_levels_texture = CreateTexture("soundboard_levels.bmp")) == NULL) { return -1; }
|
||||
|
||||
LoadStockWavThings();
|
||||
CreateTrashcanThing();
|
||||
CreateDefaultPhysicalDevice(SDL_FALSE);
|
||||
CreateDefaultPhysicalDevice(SDL_TRUE);
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(Loop, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
Loop();
|
||||
}
|
||||
#endif
|
||||
|
||||
Quit(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static SDL_bool saw_event = SDL_FALSE;
|
||||
|
||||
int SDL_AppEvent(const SDL_Event *event)
|
||||
{
|
||||
Thing *thing = NULL;
|
||||
|
||||
saw_event = SDL_TRUE;
|
||||
|
||||
switch (event->type) {
|
||||
case SDL_EVENT_MOUSE_MOTION:
|
||||
thing = UpdateMouseOver(event->motion.x, event->motion.y);
|
||||
if ((dragging_button == -1) && event->motion.state) {
|
||||
if (event->motion.state & SDL_BUTTON_LMASK) {
|
||||
/* for people that don't have all three buttons... */
|
||||
if (ctrl_held) {
|
||||
dragging_button = SDL_BUTTON_RIGHT;
|
||||
} else if (alt_held) {
|
||||
dragging_button = SDL_BUTTON_MIDDLE;
|
||||
} else {
|
||||
dragging_button = SDL_BUTTON_LEFT;
|
||||
}
|
||||
dragging_button_real = SDL_BUTTON_LEFT;
|
||||
} else if (event->motion.state & SDL_BUTTON_RMASK) {
|
||||
dragging_button = SDL_BUTTON_RIGHT;
|
||||
dragging_button_real = SDL_BUTTON_RIGHT;
|
||||
} else if (event->motion.state & SDL_BUTTON_MMASK) {
|
||||
dragging_button = SDL_BUTTON_MIDDLE;
|
||||
dragging_button_real = SDL_BUTTON_MIDDLE;
|
||||
}
|
||||
|
||||
if (dragging_button != -1) {
|
||||
dragging_thing = thing;
|
||||
if (thing && thing->ondrag) {
|
||||
thing->ondrag(thing, dragging_button, event->motion.x, event->motion.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
droppable_highlighted_thing = NULL;
|
||||
if (dragging_thing) {
|
||||
dragging_thing->rect.x = event->motion.x - (dragging_thing->rect.w / 2);
|
||||
dragging_thing->rect.y = event->motion.y - (dragging_thing->rect.h / 2);
|
||||
if (dragging_thing->can_be_dropped_onto) {
|
||||
thing = FindThingAtPoint(event->motion.x, event->motion.y);
|
||||
if (thing) {
|
||||
int i;
|
||||
for (i = 0; dragging_thing->can_be_dropped_onto[i]; i++) {
|
||||
if (dragging_thing->can_be_dropped_onto[i] == thing->what) {
|
||||
droppable_highlighted_thing = thing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_DOWN:
|
||||
thing = UpdateMouseOver(event->button.x, event->button.y);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_BUTTON_UP:
|
||||
if (dragging_button_real == event->button.button) {
|
||||
Thing *dropped_thing = dragging_thing;
|
||||
dragging_thing = NULL;
|
||||
dragging_button = -1;
|
||||
dragging_button_real = -1;
|
||||
if (dropped_thing && dropped_thing->ondrop) {
|
||||
dropped_thing->ondrop(dropped_thing, event->button.button, event->button.x, event->button.y);
|
||||
}
|
||||
droppable_highlighted_thing = NULL;
|
||||
}
|
||||
thing = UpdateMouseOver(event->button.x, event->button.y);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_MOUSE_WHEEL:
|
||||
UpdateMouseOver(event->wheel.mouseX, event->wheel.mouseY);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_KEY_DOWN:
|
||||
case SDL_EVENT_KEY_UP:
|
||||
ctrl_held = ((event->key.keysym.mod & SDL_KMOD_CTRL) != 0);
|
||||
alt_held = ((event->key.keysym.mod & SDL_KMOD_ALT) != 0);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_DROP_FILE:
|
||||
SDL_Log("Drop file! '%s'", event->drop.data);
|
||||
LoadWavThing(event->drop.data, event->drop.x, event->drop.y);
|
||||
/* SDL frees event->drop.data for you when you use SDL_AppEvent(). */
|
||||
break;
|
||||
|
||||
case SDL_EVENT_WINDOW_RESIZED:
|
||||
WindowResized(event->window.data1, event->window.data2);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_AUDIO_DEVICE_ADDED:
|
||||
CreatePhysicalDeviceThing(event->adevice.which, event->adevice.iscapture);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_AUDIO_DEVICE_REMOVED: {
|
||||
const SDL_AudioDeviceID which = event->adevice.which;
|
||||
Thing *i, *next;
|
||||
SDL_Log("Removing audio device %u", (unsigned int) which);
|
||||
for (i = things; i; i = next) {
|
||||
next = i->next;
|
||||
if (((i->what == THING_PHYSDEV) || (i->what == THING_PHYSDEV_CAPTURE)) && (i->data.physdev.devid == which)) {
|
||||
TrashThing(i);
|
||||
next = things; /* in case we mangled the list. */
|
||||
} else if (((i->what == THING_LOGDEV) || (i->what == THING_LOGDEV_CAPTURE)) && (i->data.logdev.devid == which)) {
|
||||
TrashThing(i);
|
||||
next = things; /* in case we mangled the list. */
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
return SDLTest_CommonEventMainCallbacks(state, event);
|
||||
}
|
||||
|
||||
int SDL_AppIterate(void)
|
||||
{
|
||||
if (app_ready_ticks == 0) {
|
||||
app_ready_ticks = SDL_GetTicks();
|
||||
}
|
||||
|
||||
TickThings();
|
||||
Draw();
|
||||
|
||||
if (saw_event) {
|
||||
saw_event = SDL_FALSE; /* reset this so we know when SDL_AppEvent() runs again */
|
||||
} else {
|
||||
SDL_Delay(10);
|
||||
}
|
||||
|
||||
return 0; /* keep going. */
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void)
|
||||
{
|
||||
while (things) {
|
||||
DestroyThing(things); /* make sure all the audio devices are closed, etc. */
|
||||
}
|
||||
|
||||
DestroyTexture(physdev_texture);
|
||||
DestroyTexture(logdev_texture);
|
||||
DestroyTexture(audio_texture);
|
||||
DestroyTexture(trashcan_texture);
|
||||
DestroyTexture(soundboard_texture);
|
||||
DestroyTexture(soundboard_levels_texture);
|
||||
SDLTest_CommonQuit(state);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -10,94 +10,20 @@
|
||||
freely.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define SDL_MAIN_USE_CALLBACKS 1
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_main.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include <emscripten/emscripten.h>
|
||||
#endif
|
||||
|
||||
static SDL_Window *window = NULL;
|
||||
static SDL_Renderer *renderer = NULL;
|
||||
static SDL_AudioStream *stream_in = NULL;
|
||||
static SDL_AudioStream *stream_out = NULL;
|
||||
static int done = 0;
|
||||
static SDLTest_CommonState *state = NULL;
|
||||
|
||||
static void loop(void)
|
||||
{
|
||||
const SDL_AudioDeviceID devid_in = SDL_GetAudioStreamDevice(stream_in);
|
||||
const SDL_AudioDeviceID devid_out = SDL_GetAudioStreamDevice(stream_out);
|
||||
SDL_bool please_quit = SDL_FALSE;
|
||||
SDL_Event e;
|
||||
|
||||
while (SDL_PollEvent(&e)) {
|
||||
if (e.type == SDL_EVENT_QUIT) {
|
||||
please_quit = SDL_TRUE;
|
||||
} else if (e.type == SDL_EVENT_KEY_DOWN) {
|
||||
if (e.key.keysym.sym == SDLK_ESCAPE) {
|
||||
please_quit = SDL_TRUE;
|
||||
}
|
||||
} else if (e.type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
||||
if (e.button.button == 1) {
|
||||
SDL_PauseAudioDevice(devid_out);
|
||||
SDL_ResumeAudioDevice(devid_in);
|
||||
}
|
||||
} else if (e.type == SDL_EVENT_MOUSE_BUTTON_UP) {
|
||||
if (e.button.button == 1) {
|
||||
SDL_PauseAudioDevice(devid_in);
|
||||
SDL_FlushAudioStream(stream_in); /* so no samples are held back for resampling purposes. */
|
||||
SDL_ResumeAudioDevice(devid_out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!SDL_AudioDevicePaused(devid_in)) {
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
}
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Feed any new data we captured to the output stream. It'll play when we unpause the device. */
|
||||
while (!please_quit && (SDL_GetAudioStreamAvailable(stream_in) > 0)) {
|
||||
Uint8 buf[1024];
|
||||
const int br = SDL_GetAudioStreamData(stream_in, buf, sizeof(buf));
|
||||
if (br < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s\n", SDL_GetError());
|
||||
please_quit = 1;
|
||||
} else if (SDL_PutAudioStreamData(stream_out, buf, br) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write to output audio stream: %s\n", SDL_GetError());
|
||||
please_quit = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (please_quit) {
|
||||
/* stop playing back, quit. */
|
||||
SDL_Log("Shutting down.\n");
|
||||
SDL_CloseAudioDevice(devid_in);
|
||||
SDL_CloseAudioDevice(devid_out);
|
||||
SDL_DestroyAudioStream(stream_in);
|
||||
SDL_DestroyAudioStream(stream_out);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_cancel_main_loop();
|
||||
#endif
|
||||
/* Let 'main()' return normally */
|
||||
done = 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int SDL_AppInit(int argc, char **argv)
|
||||
{
|
||||
SDL_AudioDeviceID *devices;
|
||||
SDLTest_CommonState *state;
|
||||
SDL_AudioSpec outspec;
|
||||
SDL_AudioSpec inspec;
|
||||
SDL_AudioDeviceID device;
|
||||
@ -105,9 +31,12 @@ int main(int argc, char **argv)
|
||||
const char *devname = NULL;
|
||||
int i;
|
||||
|
||||
/* this doesn't have to run very much, so give up tons of CPU time between iterations. */
|
||||
SDL_SetHint(SDL_HINT_MAIN_CALLBACK_RATE, "15");
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -128,7 +57,7 @@ int main(int argc, char **argv)
|
||||
if (consumed <= 0) {
|
||||
static const char *options[] = { "[device_name]", NULL };
|
||||
SDLTest_CommonLogUsage(state, argv[0], options);
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
i += consumed;
|
||||
@ -175,20 +104,17 @@ int main(int argc, char **argv)
|
||||
device = SDL_OpenAudioDevice(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, NULL);
|
||||
if (!device) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for playback: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
SDL_PauseAudioDevice(device);
|
||||
SDL_GetAudioDeviceFormat(device, &outspec, NULL);
|
||||
stream_out = SDL_CreateAudioStream(&outspec, &outspec);
|
||||
if (!stream_out) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
} else if (SDL_BindAudioStream(device, stream_out) == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_Log("Opening capture device %s%s%s...\n",
|
||||
@ -199,38 +125,89 @@ int main(int argc, char **argv)
|
||||
device = SDL_OpenAudioDevice(want_device, NULL);
|
||||
if (!device) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open an audio device for capture: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
SDL_PauseAudioDevice(device);
|
||||
SDL_GetAudioDeviceFormat(device, &inspec, NULL);
|
||||
stream_in = SDL_CreateAudioStream(&inspec, &inspec);
|
||||
if (!stream_in) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for capture: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
} else if (SDL_BindAudioStream(device, stream_in) == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for capture: %s!\n", SDL_GetError());
|
||||
SDL_Quit();
|
||||
exit(1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SDL_SetAudioStreamFormat(stream_in, NULL, &outspec); /* make sure we output at the playback format. */
|
||||
|
||||
SDL_Log("Ready! Hold down mouse or finger to record!\n");
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
emscripten_set_main_loop(loop, 0, 1);
|
||||
#else
|
||||
while (!done) {
|
||||
loop();
|
||||
if (!done) {
|
||||
SDL_Delay(16);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SDL_AppEvent(const SDL_Event *event)
|
||||
{
|
||||
if (event->type == SDL_EVENT_QUIT) {
|
||||
return 1; /* terminate as success. */
|
||||
} else if (event->type == SDL_EVENT_KEY_DOWN) {
|
||||
if (event->key.keysym.sym == SDLK_ESCAPE) {
|
||||
return 1; /* terminate as success. */
|
||||
}
|
||||
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_DOWN) {
|
||||
if (event->button.button == 1) {
|
||||
SDL_PauseAudioDevice(SDL_GetAudioStreamDevice(stream_out));
|
||||
SDL_FlushAudioStream(stream_out); /* so no samples are held back for resampling purposes. */
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream_in));
|
||||
}
|
||||
} else if (event->type == SDL_EVENT_MOUSE_BUTTON_UP) {
|
||||
if (event->button.button == 1) {
|
||||
SDL_PauseAudioDevice(SDL_GetAudioStreamDevice(stream_in));
|
||||
SDL_FlushAudioStream(stream_in); /* so no samples are held back for resampling purposes. */
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream_out));
|
||||
}
|
||||
}
|
||||
return 0; /* keep going. */
|
||||
}
|
||||
|
||||
int SDL_AppIterate(void)
|
||||
{
|
||||
if (!SDL_AudioDevicePaused(SDL_GetAudioStreamDevice(stream_in))) {
|
||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 255);
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
||||
}
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_RenderPresent(renderer);
|
||||
|
||||
/* Feed any new data we captured to the output stream. It'll play when we unpause the device. */
|
||||
while (SDL_GetAudioStreamAvailable(stream_in) > 0) {
|
||||
Uint8 buf[1024];
|
||||
const int br = SDL_GetAudioStreamData(stream_in, buf, sizeof(buf));
|
||||
if (br < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to read from input audio stream: %s\n", SDL_GetError());
|
||||
return -1; /* quit the app, report failure. */
|
||||
} else if (SDL_PutAudioStreamData(stream_out, buf, br) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to write to output audio stream: %s\n", SDL_GetError());
|
||||
return -1; /* quit the app, report failure. */
|
||||
}
|
||||
}
|
||||
|
||||
return 0; /* keep app going. */
|
||||
}
|
||||
|
||||
void SDL_AppQuit(void)
|
||||
{
|
||||
SDL_Log("Shutting down.\n");
|
||||
const SDL_AudioDeviceID devid_in = SDL_GetAudioStreamDevice(stream_in);
|
||||
const SDL_AudioDeviceID devid_out = SDL_GetAudioStreamDevice(stream_out);
|
||||
SDL_CloseAudioDevice(devid_in); /* !!! FIXME: use SDL_OpenAudioDeviceStream instead so we can dump this. */
|
||||
SDL_CloseAudioDevice(devid_out);
|
||||
SDL_DestroyAudioStream(stream_in);
|
||||
SDL_DestroyAudioStream(stream_out);
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 void iteration(void)
|
||||
const SDL_AudioDeviceID which = (SDL_AudioDeviceID) e.adevice.which;
|
||||
const SDL_bool iscapture = e.adevice.iscapture ? SDL_TRUE : SDL_FALSE;
|
||||
char *name = SDL_GetAudioDeviceName(which);
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
SDL_Log("New %s audio device at id %u: %s", devtypestr(iscapture), (unsigned int)which, name);
|
||||
} else {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device, id %u, but failed to get the name: %s",
|
||||
@ -119,7 +119,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -154,7 +154,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */
|
||||
window = SDL_CreateWindow("testaudiohotplug", 640, 480, 0);
|
||||
if (window == NULL) {
|
||||
if (!window) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed: %s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
@ -162,7 +162,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
filename = GetResourceFilename(filename, "sample.wav");
|
||||
|
||||
if (filename == NULL) {
|
||||
if (!filename) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@ print_devices(SDL_bool iscapture)
|
||||
int frames;
|
||||
SDL_AudioDeviceID *devices = iscapture ? SDL_GetAudioCaptureDevices(&n) : SDL_GetAudioOutputDevices(&n);
|
||||
|
||||
if (devices == NULL) {
|
||||
if (!devices) {
|
||||
SDL_Log(" Driver failed to report %s devices: %s\n\n", typestr, SDL_GetError());
|
||||
} else if (n == 0) {
|
||||
SDL_Log(" No %s devices found.\n\n", typestr);
|
||||
@ -31,7 +31,7 @@ print_devices(SDL_bool iscapture)
|
||||
SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : "");
|
||||
for (i = 0; i < n; i++) {
|
||||
char *name = SDL_GetAudioDeviceName(devices[i]);
|
||||
if (name != NULL) {
|
||||
if (name) {
|
||||
SDL_Log(" %d: %s\n", i, name);
|
||||
SDL_free(name);
|
||||
} else {
|
||||
@ -60,7 +60,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -158,7 +158,7 @@ static void skip_audio(float amount)
|
||||
num_frames = (int)(new_spec.freq * ((speed * amount) / 100.0f));
|
||||
buf = SDL_malloc(num_frames);
|
||||
|
||||
if (buf != NULL) {
|
||||
if (buf) {
|
||||
retval = SDL_GetAudioStreamData(stream, buf, num_frames);
|
||||
SDL_free(buf);
|
||||
}
|
||||
@ -233,9 +233,9 @@ static void loop(void)
|
||||
SDL_PauseAudioDevice(state->audio_id);
|
||||
}
|
||||
} else if (sym == SDLK_w) {
|
||||
auto_loop = auto_loop ? SDL_FALSE : SDL_TRUE;
|
||||
auto_loop = !auto_loop;
|
||||
} else if (sym == SDLK_e) {
|
||||
auto_flush = auto_flush ? SDL_FALSE : SDL_TRUE;
|
||||
auto_flush = !auto_flush;
|
||||
} else if (sym == SDLK_a) {
|
||||
SDL_ClearAudioStream(stream);
|
||||
SDL_Log("Cleared audio stream");
|
||||
@ -374,7 +374,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_AUDIO | SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,17 +33,19 @@ static SDLTest_TestSuiteReference *testSuites[] = {
|
||||
&mainTestSuite,
|
||||
&mathTestSuite,
|
||||
&mouseTestSuite,
|
||||
&penTestSuite,
|
||||
&pixelsTestSuite,
|
||||
&platformTestSuite,
|
||||
&propertiesTestSuite,
|
||||
&rectTestSuite,
|
||||
&renderTestSuite,
|
||||
&rwopsTestSuite,
|
||||
&sdltestTestSuite,
|
||||
&stdlibTestSuite,
|
||||
&surfaceTestSuite,
|
||||
&syswmTestSuite,
|
||||
&timerTestSuite,
|
||||
&videoTestSuite,
|
||||
&subsystemsTestSuite, /* run last, not interfere with other test enviroment */
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -71,7 +73,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -131,7 +133,7 @@ int main(int argc, char *argv[])
|
||||
SDL_Log("Test suite: %s", testSuite->name);
|
||||
for (testCounter = 0; testSuite->testCases[testCounter]; ++testCounter) {
|
||||
const SDLTest_TestCaseReference *testCase = testSuite->testCases[testCounter];
|
||||
SDL_Log(" test: %s", testCase->name);
|
||||
SDL_Log(" test: %s%s", testCase->name, testCase->enabled ? "" : " (disabled)");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -59,7 +59,7 @@ static SDL_AudioDeviceID g_audio_id = -1;
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Stop and restart audio subsystem
|
||||
* Stop and restart audio subsystem
|
||||
*
|
||||
* \sa SDL_QuitSubSystem
|
||||
* \sa SDL_InitSubSystem
|
||||
@ -77,7 +77,7 @@ static int audio_quitInitAudioSubSystem(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Start and stop audio directly
|
||||
* Start and stop audio directly
|
||||
*
|
||||
* \sa SDL_InitAudio
|
||||
* \sa SDL_QuitAudio
|
||||
@ -87,6 +87,7 @@ static int audio_initQuitAudio(void *arg)
|
||||
int result;
|
||||
int i, iMax;
|
||||
const char *audioDriver;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
|
||||
|
||||
/* Stop SDL audio subsystem */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
@ -102,6 +103,10 @@ static int audio_initQuitAudio(void *arg)
|
||||
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 (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Call Init */
|
||||
SDL_SetHint("SDL_AUDIO_DRIVER", audioDriver);
|
||||
result = SDL_InitSubSystem(SDL_INIT_AUDIO);
|
||||
@ -133,7 +138,7 @@ static int audio_initQuitAudio(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Start, open, close and stop audio
|
||||
* Start, open, close and stop audio
|
||||
*
|
||||
* \sa SDL_InitAudio
|
||||
* \sa SDL_OpenAudioDevice
|
||||
@ -146,6 +151,7 @@ static int audio_initOpenCloseQuitAudio(void *arg)
|
||||
int i, iMax, j, k;
|
||||
const char *audioDriver;
|
||||
SDL_AudioSpec desired;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
|
||||
|
||||
/* Stop SDL audio subsystem */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
@ -161,6 +167,10 @@ static int audio_initOpenCloseQuitAudio(void *arg)
|
||||
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 (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Change specs */
|
||||
for (j = 0; j < 2; j++) {
|
||||
|
||||
@ -219,7 +229,7 @@ static int audio_initOpenCloseQuitAudio(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Pause and unpause audio
|
||||
* Pause and unpause audio
|
||||
*
|
||||
* \sa SDL_PauseAudioDevice
|
||||
* \sa SDL_PlayAudioDevice
|
||||
@ -231,6 +241,7 @@ static int audio_pauseUnpauseAudio(void *arg)
|
||||
int result;
|
||||
const char *audioDriver;
|
||||
SDL_AudioSpec desired;
|
||||
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_DRIVER);
|
||||
|
||||
/* Stop SDL audio subsystem */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
@ -246,6 +257,10 @@ static int audio_pauseUnpauseAudio(void *arg)
|
||||
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 (hint && SDL_strcmp(audioDriver, hint) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Change specs */
|
||||
for (j = 0; j < 2; j++) {
|
||||
|
||||
@ -340,7 +355,7 @@ static int audio_pauseUnpauseAudio(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Enumerate and name available audio devices (output and capture).
|
||||
* Enumerate and name available audio devices (output and capture).
|
||||
*
|
||||
* \sa SDL_GetNumAudioDevices
|
||||
* \sa SDL_GetAudioDeviceName
|
||||
@ -381,7 +396,7 @@ static int audio_enumerateAndNameAudioDevices(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests around enumeration and naming of audio devices.
|
||||
* Negative tests around enumeration and naming of audio devices.
|
||||
*
|
||||
* \sa SDL_GetNumAudioDevices
|
||||
* \sa SDL_GetAudioDeviceName
|
||||
@ -392,7 +407,7 @@ static int audio_enumerateAndNameAudioDevicesNegativeTests(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks available audio driver names.
|
||||
* Checks available audio driver names.
|
||||
*
|
||||
* \sa SDL_GetNumAudioDrivers
|
||||
* \sa SDL_GetAudioDriver
|
||||
@ -423,7 +438,7 @@ static int audio_printAudioDrivers(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks current audio driver name with initialized audio.
|
||||
* Checks current audio driver name with initialized audio.
|
||||
*
|
||||
* \sa SDL_GetCurrentAudioDriver
|
||||
*/
|
||||
@ -470,7 +485,7 @@ SDL_COMPILE_TIME_ASSERT(SDL_AUDIO_F32LE_FORMAT, SDL_AUDIO_F32LE == (SDL_AUDIO_BI
|
||||
SDL_COMPILE_TIME_ASSERT(SDL_AUDIO_F32BE_FORMAT, SDL_AUDIO_F32BE == (SDL_AUDIO_F32LE | SDL_AUDIO_MASK_BIG_ENDIAN));
|
||||
|
||||
/**
|
||||
* \brief Builds various audio conversion structures
|
||||
* Builds various audio conversion structures
|
||||
*
|
||||
* \sa SDL_CreateAudioStream
|
||||
*/
|
||||
@ -481,6 +496,10 @@ static int audio_buildAudioStream(void *arg)
|
||||
SDL_AudioSpec spec2;
|
||||
int i, ii, j, jj, k, kk;
|
||||
|
||||
/* Call Quit */
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
SDLTest_AssertPass("Call to SDL_QuitSubSystem(SDL_INIT_AUDIO)");
|
||||
|
||||
/* No conversion needed */
|
||||
spec1.format = SDL_AUDIO_S16LE;
|
||||
spec1.channels = 2;
|
||||
@ -528,11 +547,14 @@ static int audio_buildAudioStream(void *arg)
|
||||
}
|
||||
}
|
||||
|
||||
/* Restart audio again */
|
||||
audioSetUp(NULL);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks calls with invalid input to SDL_CreateAudioStream
|
||||
* Checks calls with invalid input to SDL_CreateAudioStream
|
||||
*
|
||||
* \sa SDL_CreateAudioStream
|
||||
*/
|
||||
@ -612,7 +634,7 @@ static int audio_buildAudioStreamNegative(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Checks current audio status.
|
||||
* Checks current audio status.
|
||||
*
|
||||
* \sa SDL_GetAudioDeviceStatus
|
||||
*/
|
||||
@ -622,7 +644,7 @@ static int audio_getAudioStatus(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Opens, checks current audio status, and closes a device.
|
||||
* Opens, checks current audio status, and closes a device.
|
||||
*
|
||||
* \sa SDL_GetAudioStatus
|
||||
*/
|
||||
@ -632,7 +654,7 @@ static int audio_openCloseAndGetAudioStatus(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Locks and unlocks open audio device.
|
||||
* Locks and unlocks open audio device.
|
||||
*
|
||||
* \sa SDL_LockAudioDevice
|
||||
* \sa SDL_UnlockAudioDevice
|
||||
@ -643,7 +665,7 @@ static int audio_lockUnlockOpenAudioDevice(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Convert audio using various conversion structures
|
||||
* Convert audio using various conversion structures
|
||||
*
|
||||
* \sa SDL_CreateAudioStream
|
||||
*/
|
||||
@ -777,7 +799,7 @@ static int audio_convertAudio(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Opens, checks current connected status, and closes a device.
|
||||
* Opens, checks current connected status, and closes a device.
|
||||
*
|
||||
* \sa SDL_AudioDeviceConnected
|
||||
*/
|
||||
@ -799,7 +821,7 @@ static double sine_wave_sample(const Sint64 idx, const Sint64 rate, const Sint64
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check signal-to-noise ratio and maximum error of audio resampling.
|
||||
* Check signal-to-noise ratio and maximum error of audio resampling.
|
||||
*
|
||||
* \sa https://wiki.libsdl.org/SDL_CreateAudioStream
|
||||
* \sa https://wiki.libsdl.org/SDL_DestroyAudioStream
|
||||
@ -956,7 +978,7 @@ static int audio_resampleLoss(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check accuracy converting between audio formats.
|
||||
* Check accuracy converting between audio formats.
|
||||
*
|
||||
* \sa SDL_ConvertAudioSamples
|
||||
*/
|
||||
@ -1091,7 +1113,7 @@ static int audio_convertAccuracy(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check accuracy when switching between formats
|
||||
* Check accuracy when switching between formats
|
||||
*
|
||||
* \sa SDL_SetAudioStreamFormat
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ static void ClipboardCleanupCallback(void *userdata)
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief End-to-end test of SDL_xyzClipboardData functions
|
||||
* End-to-end test of SDL_xyzClipboardData functions
|
||||
* \sa SDL_HasClipboardData
|
||||
* \sa SDL_GetClipboardData
|
||||
* \sa SDL_SetClipboardData
|
||||
@ -373,7 +373,7 @@ static int clipboard_testClipboardDataFunctions(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief End-to-end test of SDL_xyzClipboardText functions
|
||||
* End-to-end test of SDL_xyzClipboardText functions
|
||||
* \sa SDL_HasClipboardText
|
||||
* \sa SDL_GetClipboardText
|
||||
* \sa SDL_SetClipboardText
|
||||
@ -457,7 +457,7 @@ static int clipboard_testClipboardTextFunctions(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief End-to-end test of SDL_xyzPrimarySelectionText functions
|
||||
* End-to-end test of SDL_xyzPrimarySelectionText functions
|
||||
* \sa SDL_HasPrimarySelectionText
|
||||
* \sa SDL_GetPrimarySelectionText
|
||||
* \sa SDL_SetPrimarySelectionText
|
||||
|
@ -38,7 +38,7 @@ static int SDLCALL events_sampleNullEventFilter(void *userdata, SDL_Event *event
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test pumping and peeking events.
|
||||
* Test pumping and peeking events.
|
||||
*
|
||||
* \sa SDL_PumpEvents
|
||||
* \sa SDL_PollEvent
|
||||
@ -75,7 +75,7 @@ static int events_pushPumpAndPollUserevent(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Adds and deletes an event watch function with NULL userdata
|
||||
* Adds and deletes an event watch function with NULL userdata
|
||||
*
|
||||
* \sa SDL_AddEventWatch
|
||||
* \sa SDL_DelEventWatch
|
||||
@ -125,7 +125,7 @@ static int events_addDelEventWatch(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Adds and deletes an event watch function with userdata
|
||||
* Adds and deletes an event watch function with userdata
|
||||
*
|
||||
* \sa SDL_AddEventWatch
|
||||
* \sa SDL_DelEventWatch
|
||||
|
@ -70,7 +70,7 @@ upper_lower_to_bytestring(Uint8 *out, Uint64 upper, Uint64 lower)
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Check String-to-GUID conversion
|
||||
* Check String-to-GUID conversion
|
||||
*
|
||||
* \sa SDL_GUIDFromString
|
||||
*/
|
||||
@ -95,7 +95,7 @@ TestGuidFromString(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check GUID-to-String conversion
|
||||
* Check GUID-to-String conversion
|
||||
*
|
||||
* \sa SDL_GUIDToString
|
||||
*/
|
||||
@ -126,7 +126,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);
|
||||
|
||||
|
@ -24,7 +24,6 @@ static const char *HintsEnum[] = {
|
||||
SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
|
||||
SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES,
|
||||
SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS,
|
||||
SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
|
||||
SDL_HINT_VIDEO_WIN_D3DCOMPILER,
|
||||
SDL_HINT_VIDEO_X11_XRANDR,
|
||||
SDL_HINT_XINPUT_ENABLED,
|
||||
@ -47,7 +46,6 @@ static const char *HintsVerbose[] = {
|
||||
"SDL_VIDEO_ALLOW_SCREENSAVER",
|
||||
"SDL_VIDEO_MAC_FULLSCREEN_SPACES",
|
||||
"SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS",
|
||||
"SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT",
|
||||
"SDL_VIDEO_WIN_D3DCOMPILER",
|
||||
"SDL_VIDEO_X11_XRANDR",
|
||||
"SDL_XINPUT_ENABLED"
|
||||
@ -60,7 +58,7 @@ static const int numHintsEnum = SDL_arraysize(HintsEnum);
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_GetHint
|
||||
* Call to SDL_GetHint
|
||||
*/
|
||||
static int hints_getHint(void *arg)
|
||||
{
|
||||
@ -89,7 +87,7 @@ static void SDLCALL hints_testHintChanged(void *userdata, const char *name, cons
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_SetHint
|
||||
* Call to SDL_SetHint
|
||||
*/
|
||||
static int hints_setHint(void *arg)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -528,7 +528,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlit = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the Blit test image as SDL_Surface.
|
||||
* Returns the Blit test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlit(void)
|
||||
{
|
||||
@ -1000,7 +1000,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitColor = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitColor test image as SDL_Surface.
|
||||
* Returns the BlitColor test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitColor(void)
|
||||
{
|
||||
@ -1635,7 +1635,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitAlpha = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitAlpha test image as SDL_Surface.
|
||||
* Returns the BlitAlpha test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitAlpha(void)
|
||||
{
|
||||
@ -2203,7 +2203,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAdd = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitBlendAdd test image as SDL_Surface.
|
||||
* Returns the BlitBlendAdd test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitBlendAdd(void)
|
||||
{
|
||||
@ -2792,7 +2792,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlend = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitBlend test image as SDL_Surface.
|
||||
* Returns the BlitBlend test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitBlend(void)
|
||||
{
|
||||
@ -3211,7 +3211,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendMod = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitBlendMod test image as SDL_Surface.
|
||||
* Returns the BlitBlendMod test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitBlendMod(void)
|
||||
{
|
||||
@ -4013,7 +4013,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendNone = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitBlendNone test image as SDL_Surface.
|
||||
* Returns the BlitBlendNone test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitBlendNone(void)
|
||||
{
|
||||
@ -4547,7 +4547,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageBlitBlendAll = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the BlitBlendAll test image as SDL_Surface.
|
||||
* Returns the BlitBlendAll test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageBlitBlendAll(void)
|
||||
{
|
||||
@ -4758,7 +4758,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imageFace = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the Face test image as SDL_Surface.
|
||||
* Returns the Face test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImageFace(void)
|
||||
{
|
||||
@ -5251,7 +5251,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitives = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the Primitives test image as SDL_Surface.
|
||||
* Returns the Primitives test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImagePrimitives(void)
|
||||
{
|
||||
@ -5916,7 +5916,7 @@ static const SDLTest_SurfaceImage_t SDLTest_imagePrimitivesBlend = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Returns the PrimitivesBlend test image as SDL_Surface.
|
||||
* Returns the PrimitivesBlend test image as SDL_Surface.
|
||||
*/
|
||||
SDL_Surface *SDLTest_ImagePrimitivesBlend(void)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@ static void free_arrays(void *dest, void *a, void *b) {
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Verify element-wise addition of 2 int arrays.
|
||||
* Verify element-wise addition of 2 int arrays.
|
||||
*/
|
||||
static void verify_ints_addition(const Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size, const char *desc) {
|
||||
size_t i;
|
||||
@ -106,7 +106,7 @@ static void verify_ints_addition(const Sint32 *dest, const Sint32 *a, const Sint
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Verify element-wise multiplication of 2 int arrays.
|
||||
* Verify element-wise multiplication of 2 int arrays.
|
||||
*/
|
||||
static void verify_ints_multiplication(const Sint32 *dest, const Sint32 *a, const Sint32 *b, size_t size, const char *desc) {
|
||||
size_t i;
|
||||
@ -126,7 +126,7 @@ static void verify_ints_multiplication(const Sint32 *dest, const Sint32 *a, cons
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Verify element-wise addition of 2 float arrays.
|
||||
* Verify element-wise addition of 2 float arrays.
|
||||
*/
|
||||
static void verify_floats_addition(const float *dest, const float *a, const float *b, size_t size, const char *desc) {
|
||||
size_t i;
|
||||
@ -147,7 +147,7 @@ static void verify_floats_addition(const float *dest, const float *a, const floa
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Verify element-wise addition of 2 double arrays.
|
||||
* Verify element-wise addition of 2 double arrays.
|
||||
*/
|
||||
static void verify_doubles_addition(const double *dest, const double *a, const double *b, size_t size, const char *desc) {
|
||||
size_t i;
|
||||
|
@ -12,7 +12,7 @@
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Check virtual joystick creation
|
||||
* Check virtual joystick creation
|
||||
*
|
||||
* \sa SDL_AttachVirtualJoystickEx
|
||||
*/
|
||||
@ -20,6 +20,7 @@ static int TestVirtualJoystick(void *arg)
|
||||
{
|
||||
SDL_VirtualJoystickDesc desc;
|
||||
SDL_Joystick *joystick = NULL;
|
||||
SDL_Gamepad *gamepad = NULL;
|
||||
SDL_JoystickID device_id;
|
||||
|
||||
SDLTest_AssertCheck(SDL_InitSubSystem(SDL_INIT_GAMEPAD) == 0, "SDL_InitSubSystem(SDL_INIT_GAMEPAD)");
|
||||
@ -52,13 +53,65 @@ static int TestVirtualJoystick(void *arg)
|
||||
SDLTest_AssertCheck(SDL_GetNumJoystickHats(joystick) == desc.nhats, "SDL_GetNumJoystickHats()");
|
||||
SDLTest_AssertCheck(SDL_GetNumJoystickButtons(joystick) == desc.nbuttons, "SDL_GetNumJoystickButtons()");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_A, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_A, SDL_PRESSED)");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_A) == SDL_PRESSED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_A) == SDL_PRESSED");
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_A, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_A, SDL_RELEASED)");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_A) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_A) == SDL_RELEASED");
|
||||
SDLTest_AssertCheck(SDL_GetJoystickButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetJoystickButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
gamepad = SDL_OpenGamepad(SDL_GetJoystickInstanceID(joystick));
|
||||
SDLTest_AssertCheck(gamepad != NULL, "SDL_OpenGamepad() succeeded");
|
||||
if (gamepad) {
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), desc.name) == 0, "SDL_GetGamepadName()");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadVendor(gamepad) == desc.vendor_id, "SDL_GetGamepadVendor()");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadProduct(gamepad) == desc.product_id, "SDL_GetGamepadProduct()");
|
||||
|
||||
/* Set an explicit mapping with a different name */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual Gamepad,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,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual Gamepad") == 0, "SDL_GetGamepadName() == Virtual Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_A");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
/* Set an explicit mapping with legacy Nintendo style buttons */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual Nintendo Gamepad,a:b1,b:b0,x:b3,y:b2,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,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual Nintendo Gamepad") == 0, "SDL_GetGamepadName() == Virtual Nintendo Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_B");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
/* Set an explicit mapping with PS4 style buttons */
|
||||
SDL_SetGamepadMapping(SDL_GetJoystickInstanceID(joystick), "ff0013db5669727475616c2043007601,Virtual PS4 Gamepad,type:ps4,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,");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetGamepadName(gamepad), "Virtual PS4 Gamepad") == 0, "SDL_GetGamepadName() == Virtual PS4 Gamepad");
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButtonLabel(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS, "SDL_GetGamepadButtonLabel(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_GAMEPAD_BUTTON_LABEL_CROSS");
|
||||
|
||||
/* Set the south button and verify that the gamepad responds */
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_PRESSED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_PRESSED");
|
||||
|
||||
SDLTest_AssertCheck(SDL_SetJoystickVirtualButton(joystick, SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED) == 0, "SDL_SetJoystickVirtualButton(SDL_GAMEPAD_BUTTON_SOUTH, SDL_RELEASED)");
|
||||
SDL_UpdateJoysticks();
|
||||
SDLTest_AssertCheck(SDL_GetGamepadButton(gamepad, SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED, "SDL_GetGamepadButton(SDL_GAMEPAD_BUTTON_SOUTH) == SDL_RELEASED");
|
||||
|
||||
SDL_CloseGamepad(gamepad);
|
||||
}
|
||||
|
||||
SDL_CloseJoystick(joystick);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetKeyboardState with and without numkeys reference.
|
||||
* Check call to SDL_GetKeyboardState with and without numkeys reference.
|
||||
*
|
||||
* \sa SDL_GetKeyboardState
|
||||
*/
|
||||
@ -36,7 +36,7 @@ static int keyboard_getKeyboardState(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetKeyboardFocus
|
||||
* Check call to SDL_GetKeyboardFocus
|
||||
*
|
||||
* \sa SDL_GetKeyboardFocus
|
||||
*/
|
||||
@ -50,7 +50,7 @@ static int keyboard_getKeyboardFocus(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetKeyFromName for known, unknown and invalid name.
|
||||
* Check call to SDL_GetKeyFromName for known, unknown and invalid name.
|
||||
*
|
||||
* \sa SDL_GetKeyFromName
|
||||
*/
|
||||
@ -115,7 +115,7 @@ static void checkInvalidScancodeError(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetKeyFromScancode
|
||||
* Check call to SDL_GetKeyFromScancode
|
||||
*
|
||||
* \sa SDL_GetKeyFromScancode
|
||||
*/
|
||||
@ -153,7 +153,7 @@ static int keyboard_getKeyFromScancode(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetKeyName
|
||||
* Check call to SDL_GetKeyName
|
||||
*
|
||||
* \sa SDL_GetKeyName
|
||||
*/
|
||||
@ -208,7 +208,7 @@ static int keyboard_getKeyName(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief SDL_GetScancodeName negative cases
|
||||
* SDL_GetScancodeName negative cases
|
||||
*
|
||||
* \sa SDL_GetScancodeName
|
||||
*/
|
||||
@ -234,7 +234,7 @@ static int keyboard_getScancodeNameNegative(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief SDL_GetKeyName negative cases
|
||||
* SDL_GetKeyName negative cases
|
||||
*
|
||||
* \sa SDL_GetKeyName
|
||||
*/
|
||||
@ -270,7 +270,7 @@ static int keyboard_getKeyNameNegative(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetModState and SDL_SetModState
|
||||
* Check call to SDL_GetModState and SDL_SetModState
|
||||
*
|
||||
* \sa SDL_GetModState
|
||||
* \sa SDL_SetModState
|
||||
@ -329,7 +329,7 @@ static int keyboard_getSetModState(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_StartTextInput and SDL_StopTextInput
|
||||
* Check call to SDL_StartTextInput and SDL_StopTextInput
|
||||
*
|
||||
* \sa SDL_StartTextInput
|
||||
* \sa SDL_StopTextInput
|
||||
@ -375,7 +375,7 @@ static void testSetTextInputRect(SDL_Rect refRect)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_SetTextInputRect
|
||||
* Check call to SDL_SetTextInputRect
|
||||
*
|
||||
* \sa SDL_SetTextInputRect
|
||||
*/
|
||||
@ -454,7 +454,7 @@ static int keyboard_setTextInputRect(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_SetTextInputRect with invalid data
|
||||
* Check call to SDL_SetTextInputRect with invalid data
|
||||
*
|
||||
* \sa SDL_SetTextInputRect
|
||||
*/
|
||||
@ -491,7 +491,7 @@ static int keyboard_setTextInputRectNegative(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetScancodeFromKey
|
||||
* Check call to SDL_GetScancodeFromKey
|
||||
*
|
||||
* \sa SDL_GetScancodeFromKey
|
||||
* \sa SDL_Keycode
|
||||
@ -514,7 +514,7 @@ static int keyboard_getScancodeFromKey(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetScancodeFromName
|
||||
* Check call to SDL_GetScancodeFromName
|
||||
*
|
||||
* \sa SDL_GetScancodeFromName
|
||||
* \sa SDL_Keycode
|
||||
@ -585,7 +585,7 @@ static void checkInvalidNameError(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetScancodeFromName with invalid data
|
||||
* Check call to SDL_GetScancodeFromName with invalid data
|
||||
*
|
||||
* \sa SDL_GetScancodeFromName
|
||||
* \sa SDL_Keycode
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_InitSubSystem() and SDL_QuitSubSystem()
|
||||
* Tests SDL_InitSubSystem() and SDL_QuitSubSystem()
|
||||
* \sa SDL_Init
|
||||
* \sa SDL_Quit
|
||||
*/
|
||||
|
@ -62,7 +62,7 @@ typedef double(SDLCALL *d_to_d_func)(double);
|
||||
typedef double(SDLCALL *dd_to_d_func)(double, double);
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature double -> double.
|
||||
* 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.
|
||||
@ -77,7 +77,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((result - cases[i].expected) < FLT_EPSILON,
|
||||
"%s(%f), expected %f, got %f",
|
||||
func_name,
|
||||
cases[i].input,
|
||||
@ -88,7 +88,7 @@ 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.
|
||||
* 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.
|
||||
@ -117,7 +117,7 @@ helper_dtod_inexact(const char *func_name, d_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature
|
||||
* 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.
|
||||
@ -143,7 +143,7 @@ helper_ddtod(const char *func_name, dd_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature
|
||||
* 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.
|
||||
@ -172,7 +172,7 @@ helper_ddtod_inexact(const char *func_name, dd_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs a range of values on a given function with a signature double -> double
|
||||
* Runs a range of values on a given function with a signature double -> double
|
||||
*
|
||||
* This function is only meant to test functions that returns the input value if it is
|
||||
* integral: f(x) -> x for x in N.
|
||||
@ -1139,7 +1139,7 @@ log_baseCases(void *args)
|
||||
1.0, 0.0, result);
|
||||
|
||||
result = SDL_log(EULER);
|
||||
SDLTest_AssertCheck(1.0 == result,
|
||||
SDLTest_AssertCheck((result - 1.) < FLT_EPSILON,
|
||||
"Log(%f), expected %f, got %f",
|
||||
EULER, 1.0, result);
|
||||
|
||||
@ -2275,7 +2275,7 @@ acos_limitCases(void *args)
|
||||
1.0, 0.0, result);
|
||||
|
||||
result = SDL_acos(-1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D - result) <= EPSILON,
|
||||
"Acos(%f), expected %f, got %f",
|
||||
-1.0, SDL_PI_D, result);
|
||||
|
||||
@ -2362,12 +2362,12 @@ asin_limitCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_asin(1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Asin(%f), expected %f, got %f",
|
||||
1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_asin(-1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Asin(%f), expected %f, got %f",
|
||||
-1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
@ -2554,7 +2554,7 @@ atan2_bothZeroCases(void *args)
|
||||
{ 0.0, -0.0, SDL_PI_D },
|
||||
{ -0.0, -0.0, -SDL_PI_D },
|
||||
};
|
||||
return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2573,7 +2573,7 @@ atan2_yZeroCases(void *args)
|
||||
{ -0.0, 1.0, -0.0 },
|
||||
{ -0.0, -1.0, -SDL_PI_D }
|
||||
};
|
||||
return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2589,7 +2589,7 @@ atan2_xZeroCases(void *args)
|
||||
{ 1.0, -0.0, SDL_PI_D / 2.0 },
|
||||
{ -1.0, -0.0, -SDL_PI_D / 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 */
|
||||
@ -2608,22 +2608,22 @@ atan2_bothInfCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_atan2(INFINITY, INFINITY);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, INFINITY, SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(INFINITY, -INFINITY);
|
||||
SDLTest_AssertCheck(3.0 * SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(3.0 * SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, -INFINITY, 3.0 * SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, INFINITY);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, INFINITY, -SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, -INFINITY);
|
||||
SDLTest_AssertCheck(-3.0 * SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-3.0 * SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, -INFINITY, -3.0 * SDL_PI_D / 4.0, result);
|
||||
|
||||
@ -2640,22 +2640,22 @@ atan2_yInfCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_atan2(INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, 1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, -1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, 1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, -1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
@ -2684,12 +2684,12 @@ atan2_xInfCases(void *args)
|
||||
-1.0, INFINITY, -0.0, result);
|
||||
|
||||
result = SDL_atan2(1.0, -INFINITY);
|
||||
SDLTest_AssertCheck(SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
1.0, -INFINITY, SDL_PI_D, result);
|
||||
|
||||
result = SDL_atan2(-1.0, -INFINITY);
|
||||
SDLTest_AssertCheck(-SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-1.0, -INFINITY, -SDL_PI_D, result);
|
||||
|
||||
|
@ -25,7 +25,7 @@ static int mouseStateCheck(Uint32 state)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetMouseState
|
||||
* Check call to SDL_GetMouseState
|
||||
*
|
||||
*/
|
||||
static int mouse_getMouseState(void *arg)
|
||||
@ -70,7 +70,7 @@ static int mouse_getMouseState(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetRelativeMouseState
|
||||
* Check call to SDL_GetRelativeMouseState
|
||||
*
|
||||
*/
|
||||
static int mouse_getRelativeMouseState(void *arg)
|
||||
@ -188,7 +188,7 @@ static SDL_Cursor *initArrowCursor(const char *image[])
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_CreateCursor and SDL_DestroyCursor
|
||||
* Check call to SDL_CreateCursor and SDL_DestroyCursor
|
||||
*
|
||||
* \sa SDL_CreateCursor
|
||||
* \sa SDL_DestroyCursor
|
||||
@ -213,7 +213,7 @@ static int mouse_createFreeCursor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_CreateColorCursor and SDL_DestroyCursor
|
||||
* Check call to SDL_CreateColorCursor and SDL_DestroyCursor
|
||||
*
|
||||
* \sa SDL_CreateColorCursor
|
||||
* \sa SDL_DestroyCursor
|
||||
@ -269,7 +269,7 @@ static void changeCursorVisibility(SDL_bool state)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_ShowCursor
|
||||
* Check call to SDL_ShowCursor
|
||||
*
|
||||
* \sa SDL_ShowCursor
|
||||
*/
|
||||
@ -294,7 +294,7 @@ static int mouse_showCursor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_SetCursor
|
||||
* Check call to SDL_SetCursor
|
||||
*
|
||||
* \sa SDL_SetCursor
|
||||
*/
|
||||
@ -326,7 +326,7 @@ static int mouse_setCursor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetCursor
|
||||
* Check call to SDL_GetCursor
|
||||
*
|
||||
* \sa SDL_GetCursor
|
||||
*/
|
||||
@ -343,7 +343,7 @@ static int mouse_getCursor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode
|
||||
* Check call to SDL_GetRelativeMouseMode and SDL_SetRelativeMouseMode
|
||||
*
|
||||
* \sa SDL_GetRelativeMouseMode
|
||||
* \sa SDL_SetRelativeMouseMode
|
||||
@ -418,7 +418,7 @@ static SDL_Window *createMouseSuiteTestWindow(void)
|
||||
*/
|
||||
static void destroyMouseSuiteTestWindow(SDL_Window *window)
|
||||
{
|
||||
if (window != NULL) {
|
||||
if (window) {
|
||||
SDL_DestroyWindow(window);
|
||||
window = NULL;
|
||||
SDLTest_AssertPass("SDL_DestroyWindow()");
|
||||
@ -426,7 +426,7 @@ static void destroyMouseSuiteTestWindow(SDL_Window *window)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_WarpMouseInWindow
|
||||
* Check call to SDL_WarpMouseInWindow
|
||||
*
|
||||
* \sa SDL_WarpMouseInWindow
|
||||
*/
|
||||
@ -454,7 +454,7 @@ static int mouse_warpMouseInWindow(void *arg)
|
||||
yPositions[5] = (float)h + 1;
|
||||
/* Create test window */
|
||||
window = createMouseSuiteTestWindow();
|
||||
if (window == NULL) {
|
||||
if (!window) {
|
||||
return TEST_ABORTED;
|
||||
}
|
||||
|
||||
@ -489,7 +489,7 @@ static int mouse_warpMouseInWindow(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetMouseFocus
|
||||
* Check call to SDL_GetMouseFocus
|
||||
*
|
||||
* \sa SDL_GetMouseFocus
|
||||
*/
|
||||
@ -499,6 +499,7 @@ static int mouse_getMouseFocus(void *arg)
|
||||
float 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();
|
||||
@ -506,32 +507,37 @@ static 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 = (float)SDLTest_RandomIntegerInRange(1, w - 1);
|
||||
y = (float)SDLTest_RandomIntegerInRange(1, h - 1);
|
||||
SDL_WarpMouseInWindow(window, x, y);
|
||||
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%.f,%.f)", 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 = (float)SDLTest_RandomIntegerInRange(1, w - 1);
|
||||
y = (float)SDLTest_RandomIntegerInRange(1, h - 1);
|
||||
SDL_WarpMouseInWindow(window, x, y);
|
||||
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%.f,%.f)", x, y);
|
||||
|
||||
/* Pump events to update focus state */
|
||||
SDL_Delay(100);
|
||||
SDL_PumpEvents();
|
||||
SDLTest_AssertPass("SDL_PumpEvents()");
|
||||
/* 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");
|
||||
/* 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 = (float)SDLTest_RandomIntegerInRange(-9, -1);
|
||||
y = (float)SDLTest_RandomIntegerInRange(-9, -1);
|
||||
SDL_WarpMouseInWindow(window, x, y);
|
||||
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%.f,%.f)", x, y);
|
||||
/* Mouse to random position outside window */
|
||||
x = (float)SDLTest_RandomIntegerInRange(-9, -1);
|
||||
y = (float)SDLTest_RandomIntegerInRange(-9, -1);
|
||||
SDL_WarpMouseInWindow(window, x, y);
|
||||
SDLTest_AssertPass("SDL_WarpMouseInWindow(...,%.f,%.f)", x, y);
|
||||
} else {
|
||||
SDLTest_Log("Skipping mouse warp focus tests: Wayland does not support warping the mouse pointer");
|
||||
}
|
||||
|
||||
/* Clean up test window */
|
||||
destroyMouseSuiteTestWindow(window);
|
||||
@ -549,7 +555,7 @@ static int mouse_getMouseFocus(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetDefaultCursor
|
||||
* Check call to SDL_GetDefaultCursor
|
||||
*
|
||||
* \sa SDL_GetDefaultCursor
|
||||
*/
|
||||
@ -566,7 +572,7 @@ static int mouse_getDefaultCursor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Check call to SDL_GetGlobalMouseState
|
||||
* Check call to SDL_GetGlobalMouseState
|
||||
*
|
||||
* \sa SDL_GetGlobalMouseState
|
||||
*/
|
||||
|
1909
test/testautomation_pen.c
Normal file
@ -11,6 +11,8 @@
|
||||
static const Uint32 g_AllFormats[] = {
|
||||
SDL_PIXELFORMAT_INDEX1LSB,
|
||||
SDL_PIXELFORMAT_INDEX1MSB,
|
||||
SDL_PIXELFORMAT_INDEX2LSB,
|
||||
SDL_PIXELFORMAT_INDEX2MSB,
|
||||
SDL_PIXELFORMAT_INDEX4LSB,
|
||||
SDL_PIXELFORMAT_INDEX4MSB,
|
||||
SDL_PIXELFORMAT_INDEX8,
|
||||
@ -39,7 +41,10 @@ static const Uint32 g_AllFormats[] = {
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_XRGB2101010,
|
||||
SDL_PIXELFORMAT_XBGR2101010,
|
||||
SDL_PIXELFORMAT_ARGB2101010,
|
||||
SDL_PIXELFORMAT_ABGR2101010,
|
||||
SDL_PIXELFORMAT_YV12,
|
||||
SDL_PIXELFORMAT_IYUV,
|
||||
SDL_PIXELFORMAT_YUY2,
|
||||
@ -53,6 +58,8 @@ static const int g_numAllFormats = SDL_arraysize(g_AllFormats);
|
||||
static const char *g_AllFormatsVerbose[] = {
|
||||
"SDL_PIXELFORMAT_INDEX1LSB",
|
||||
"SDL_PIXELFORMAT_INDEX1MSB",
|
||||
"SDL_PIXELFORMAT_INDEX2LSB",
|
||||
"SDL_PIXELFORMAT_INDEX2MSB",
|
||||
"SDL_PIXELFORMAT_INDEX4LSB",
|
||||
"SDL_PIXELFORMAT_INDEX4MSB",
|
||||
"SDL_PIXELFORMAT_INDEX8",
|
||||
@ -81,7 +88,10 @@ static const char *g_AllFormatsVerbose[] = {
|
||||
"SDL_PIXELFORMAT_RGBA8888",
|
||||
"SDL_PIXELFORMAT_ABGR8888",
|
||||
"SDL_PIXELFORMAT_BGRA8888",
|
||||
"SDL_PIXELFORMAT_XRGB2101010",
|
||||
"SDL_PIXELFORMAT_XBGR2101010",
|
||||
"SDL_PIXELFORMAT_ARGB2101010",
|
||||
"SDL_PIXELFORMAT_ABGR2101010",
|
||||
"SDL_PIXELFORMAT_YV12",
|
||||
"SDL_PIXELFORMAT_IYUV",
|
||||
"SDL_PIXELFORMAT_YUY2",
|
||||
@ -105,7 +115,7 @@ static const char *g_invalidPixelFormatsVerbose[] = {
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_CreatePixelFormat and SDL_DestroyPixelFormat
|
||||
* Call to SDL_CreatePixelFormat and SDL_DestroyPixelFormat
|
||||
*
|
||||
* \sa SDL_CreatePixelFormat
|
||||
* \sa SDL_DestroyPixelFormat
|
||||
@ -198,7 +208,7 @@ static int pixels_allocFreeFormat(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_GetPixelFormatName
|
||||
* Call to SDL_GetPixelFormatName
|
||||
*
|
||||
* \sa SDL_GetPixelFormatName
|
||||
*/
|
||||
@ -265,7 +275,7 @@ static int pixels_getPixelFormatName(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_CreatePalette and SDL_DestroyPalette
|
||||
* Call to SDL_CreatePalette and SDL_DestroyPalette
|
||||
*
|
||||
* \sa SDL_CreatePalette
|
||||
* \sa SDL_DestroyPalette
|
||||
|
@ -11,7 +11,7 @@
|
||||
/* Helper functions */
|
||||
|
||||
/**
|
||||
* \brief Compare sizes of types.
|
||||
* Compare sizes of types.
|
||||
*
|
||||
* @note Watcom C flags these as Warning 201: "Unreachable code" if you just
|
||||
* compare them directly, so we push it through a function to keep the
|
||||
@ -25,7 +25,7 @@ static int compareSizeOfType(size_t sizeoftype, size_t hardcodetype)
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Tests type sizes.
|
||||
* Tests type sizes.
|
||||
*/
|
||||
static int platform_testTypes(void *arg)
|
||||
{
|
||||
@ -47,7 +47,7 @@ static int platform_testTypes(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests platform endianness and SDL_SwapXY functions.
|
||||
* Tests platform endianness and SDL_SwapXY functions.
|
||||
*/
|
||||
static int platform_testEndianessAndSwap(void *arg)
|
||||
{
|
||||
@ -118,7 +118,7 @@ static int platform_testEndianessAndSwap(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetXYZ() functions
|
||||
* Tests SDL_GetXYZ() functions
|
||||
* \sa SDL_GetPlatform
|
||||
* \sa SDL_GetCPUCount
|
||||
* \sa SDL_GetRevision
|
||||
@ -162,7 +162,7 @@ static int platform_testGetFunctions(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasXYZ() functions
|
||||
* Tests SDL_HasXYZ() functions
|
||||
* \sa SDL_HasAltiVec
|
||||
* \sa SDL_HasMMX
|
||||
* \sa SDL_HasSSE
|
||||
@ -204,7 +204,7 @@ static int platform_testHasFunctions(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetVersion
|
||||
* Tests SDL_GetVersion
|
||||
* \sa SDL_GetVersion
|
||||
*/
|
||||
static int platform_testGetVersion(void *arg)
|
||||
@ -227,7 +227,7 @@ static int platform_testGetVersion(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_VERSION macro
|
||||
* Tests SDL_VERSION macro
|
||||
*/
|
||||
static int platform_testSDLVersion(void *arg)
|
||||
{
|
||||
@ -249,7 +249,7 @@ static int platform_testSDLVersion(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests default SDL_Init
|
||||
* Tests default SDL_Init
|
||||
*/
|
||||
static int platform_testDefaultInit(void *arg)
|
||||
{
|
||||
@ -271,7 +271,7 @@ static int platform_testDefaultInit(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_Get/Set/ClearError
|
||||
* Tests SDL_Get/Set/ClearError
|
||||
* \sa SDL_GetError
|
||||
* \sa SDL_SetError
|
||||
* \sa SDL_ClearError
|
||||
@ -322,7 +322,7 @@ static int platform_testGetSetClearError(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_SetError with empty input
|
||||
* Tests SDL_SetError with empty input
|
||||
* \sa SDL_SetError
|
||||
*/
|
||||
static int platform_testSetErrorEmptyInput(void *arg)
|
||||
@ -363,13 +363,13 @@ static int platform_testSetErrorEmptyInput(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_SetError with invalid input
|
||||
* Tests SDL_SetError with invalid input
|
||||
* \sa SDL_SetError
|
||||
*/
|
||||
static int platform_testSetErrorInvalidInput(void *arg)
|
||||
{
|
||||
int result;
|
||||
const char *invalidError = NULL;
|
||||
const char *invalidError = "";
|
||||
const char *probeError = "Testing";
|
||||
const char *lastError;
|
||||
size_t len;
|
||||
@ -446,7 +446,7 @@ static int platform_testSetErrorInvalidInput(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetPowerInfo
|
||||
* Tests SDL_GetPowerInfo
|
||||
* \sa SDL_GetPowerInfo
|
||||
*/
|
||||
static int platform_testGetPowerInfo(void *arg)
|
||||
|
350
test/testautomation_properties.c
Normal file
@ -0,0 +1,350 @@
|
||||
/**
|
||||
* Properties test suite
|
||||
*/
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* Test basic functionality
|
||||
*/
|
||||
static void SDLCALL count_properties(void *userdata, SDL_PropertiesID props, const char *name)
|
||||
{
|
||||
int *count = (int *)userdata;
|
||||
++(*count);
|
||||
}
|
||||
static void SDLCALL count_foo_properties(void *userdata, SDL_PropertiesID props, const char *name)
|
||||
{
|
||||
int *count = (int *)userdata;
|
||||
if (SDL_strcmp(name, "foo") == 0) {
|
||||
++(*count);
|
||||
}
|
||||
}
|
||||
static int properties_testBasic(void *arg)
|
||||
{
|
||||
SDL_PropertiesID props;
|
||||
char key[2], expected_value[2];
|
||||
SDL_PropertyType type;
|
||||
void *value;
|
||||
const char *value_string;
|
||||
Sint64 value_number;
|
||||
float value_float;
|
||||
SDL_bool value_bool;
|
||||
int i, result, count;
|
||||
|
||||
props = SDL_CreateProperties();
|
||||
SDLTest_AssertPass("Call to SDL_CreateProperties()");
|
||||
SDLTest_AssertCheck(props != 0,
|
||||
"Verify props were created, got: %" SDL_PRIu32 "", props);
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
|
||||
SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i);
|
||||
result = SDL_SetProperty(props, key, expected_value);
|
||||
SDLTest_AssertPass("Call to SDL_SetProperty()");
|
||||
SDLTest_AssertCheck(result == 0,
|
||||
"Verify property value was set, got: %d", result);
|
||||
value = SDL_GetProperty(props, key, NULL);
|
||||
SDLTest_AssertPass("Call to SDL_GetProperty()");
|
||||
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, expected_value) == 0,
|
||||
"Verify property value was set, got %s, expected %s", value ? (const char *)value : "NULL", expected_value);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
SDL_EnumerateProperties(props, count_properties, &count);
|
||||
SDLTest_AssertCheck(count == 10,
|
||||
"Verify property count, expected 10, got: %d", count);
|
||||
|
||||
for (i = 0; i < 10; ++i) {
|
||||
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
|
||||
result = SDL_SetProperty(props, key, NULL);
|
||||
SDLTest_AssertPass("Call to SDL_SetProperty(NULL)");
|
||||
SDLTest_AssertCheck(result == 0,
|
||||
"Verify property value was set, got: %d", result);
|
||||
value = SDL_GetProperty(props, key, NULL);
|
||||
SDLTest_AssertPass("Call to SDL_GetProperty()");
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property value was set, got %s, expected NULL", (const char *)value);
|
||||
}
|
||||
|
||||
count = 0;
|
||||
SDL_EnumerateProperties(props, count_properties, &count);
|
||||
SDLTest_AssertCheck(count == 0,
|
||||
"Verify property count, expected 0, got: %d", count);
|
||||
|
||||
/* Check default values */
|
||||
value = SDL_GetProperty(props, "foo", (void *)0xabcd);
|
||||
SDLTest_AssertCheck(value == (void *)0xabcd,
|
||||
"Verify property, expected 0xabcd, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", "abcd");
|
||||
SDLTest_AssertCheck(value_string && SDL_strcmp(value_string, "abcd") == 0,
|
||||
"Verify string property, expected abcd, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 1234);
|
||||
SDLTest_AssertCheck(value_number == 1234,
|
||||
"Verify number property, expected 1234, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 1234.0f);
|
||||
SDLTest_AssertCheck(value_float == 1234.0f,
|
||||
"Verify float property, expected 1234, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_TRUE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_TRUE,
|
||||
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check data value */
|
||||
SDLTest_AssertPass("Call to SDL_SetProperty(\"foo\", 0x01)");
|
||||
SDL_SetProperty(props, "foo", (void *)0x01);
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_POINTER,
|
||||
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_POINTER, type);
|
||||
value = SDL_GetProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value == (void *)0x01,
|
||||
"Verify property, expected 0x01, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string == NULL,
|
||||
"Verify string property, expected NULL, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 0,
|
||||
"Verify number property, expected 0, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 0.0f,
|
||||
"Verify float property, expected 0, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_FALSE,
|
||||
"Verify boolean property, expected SDL_FALSE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check string value */
|
||||
SDLTest_AssertPass("Call to SDL_SetStringProperty(\"foo\", \"bar\")");
|
||||
SDL_SetStringProperty(props, "foo", "bar");
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_STRING,
|
||||
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_STRING, type);
|
||||
value = SDL_GetProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property, expected NULL, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string != NULL && SDL_strcmp(value_string, "bar") == 0,
|
||||
"Verify string property, expected bar, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 0,
|
||||
"Verify number property, expected 0, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 0.0f,
|
||||
"Verify float property, expected 0, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_TRUE,
|
||||
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check number value */
|
||||
SDLTest_AssertPass("Call to SDL_SetNumberProperty(\"foo\", 1)");
|
||||
SDL_SetNumberProperty(props, "foo", 1);
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_NUMBER,
|
||||
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_NUMBER, type);
|
||||
value = SDL_GetProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property, expected NULL, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string && SDL_strcmp(value_string, "1") == 0,
|
||||
"Verify string property, expected 1, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 1,
|
||||
"Verify number property, expected 1, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 1.0f,
|
||||
"Verify float property, expected 1, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_TRUE,
|
||||
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check float value */
|
||||
SDLTest_AssertPass("Call to SDL_SetFloatProperty(\"foo\", 1)");
|
||||
SDL_SetFloatProperty(props, "foo", 1.75f);
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_FLOAT,
|
||||
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_FLOAT, type);
|
||||
value = SDL_GetProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property, expected NULL, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string && SDL_strcmp(value_string, "1.750000") == 0,
|
||||
"Verify string property, expected 1.750000, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 2,
|
||||
"Verify number property, expected 2, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 1.75f,
|
||||
"Verify float property, expected 1.75, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_TRUE,
|
||||
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Check boolean value */
|
||||
SDLTest_AssertPass("Call to SDL_SetBooleanProperty(\"foo\", SDL_TRUE)");
|
||||
SDL_SetBooleanProperty(props, "foo", 3); /* Note we're testing non-true/false value here */
|
||||
type = SDL_GetPropertyType(props, "foo");
|
||||
SDLTest_AssertCheck(type == SDL_PROPERTY_TYPE_BOOLEAN,
|
||||
"Verify property type, expected %d, got: %d", SDL_PROPERTY_TYPE_BOOLEAN, type);
|
||||
value = SDL_GetProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value == NULL,
|
||||
"Verify property, expected NULL, got: %p", value);
|
||||
value_string = SDL_GetStringProperty(props, "foo", NULL);
|
||||
SDLTest_AssertCheck(value_string && SDL_strcmp(value_string, "true") == 0,
|
||||
"Verify string property, expected true, got: %s", value_string);
|
||||
value_number = SDL_GetNumberProperty(props, "foo", 0);
|
||||
SDLTest_AssertCheck(value_number == 1,
|
||||
"Verify number property, expected 1, got: %" SDL_PRIu64 "", value_number);
|
||||
value_float = SDL_GetFloatProperty(props, "foo", 0.0f);
|
||||
SDLTest_AssertCheck(value_float == 1.0f,
|
||||
"Verify float property, expected 1, got: %f", value_float);
|
||||
value_bool = SDL_GetBooleanProperty(props, "foo", SDL_FALSE);
|
||||
SDLTest_AssertCheck(value_bool == SDL_TRUE,
|
||||
"Verify boolean property, expected SDL_TRUE, got: %s", value_bool ? "SDL_TRUE" : "SDL_FALSE");
|
||||
|
||||
/* Make sure we have exactly one property named foo */
|
||||
count = 0;
|
||||
SDL_EnumerateProperties(props, count_foo_properties, &count);
|
||||
SDLTest_AssertCheck(count == 1,
|
||||
"Verify foo property count, expected 1, got: %d", count);
|
||||
|
||||
SDL_DestroyProperties(props);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test cleanup functionality
|
||||
*/
|
||||
static void SDLCALL cleanup(void *userdata, void *value)
|
||||
{
|
||||
int *count = (int *)userdata;
|
||||
++(*count);
|
||||
}
|
||||
static int properties_testCleanup(void *arg)
|
||||
{
|
||||
SDL_PropertiesID props;
|
||||
char key[2], expected_value[2];
|
||||
int i, count;
|
||||
|
||||
props = SDL_CreateProperties();
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_SetProperty(cleanup)");
|
||||
count = 0;
|
||||
SDL_SetPropertyWithCleanup(props, "a", "0", cleanup, &count);
|
||||
SDL_SetPropertyWithCleanup(props, "a", NULL, cleanup, &count);
|
||||
SDLTest_AssertCheck(count == 1,
|
||||
"Verify cleanup for deleting property, got %d, expected 1", count);
|
||||
|
||||
SDLTest_AssertPass("Call to SDL_DestroyProperties()");
|
||||
count = 0;
|
||||
for (i = 0; i < 10; ++i) {
|
||||
SDL_snprintf(key, SDL_arraysize(key), "%c", 'a' + i);
|
||||
SDL_snprintf(expected_value, SDL_arraysize(expected_value), "%c", 'a' + i);
|
||||
SDL_SetPropertyWithCleanup(props, key, expected_value, cleanup, &count);
|
||||
}
|
||||
SDL_DestroyProperties(props);
|
||||
SDLTest_AssertCheck(count == 10,
|
||||
"Verify cleanup for destroying properties, got %d, expected 10", count);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test locking functionality
|
||||
*/
|
||||
struct properties_thread_data
|
||||
{
|
||||
SDL_bool done;
|
||||
SDL_PropertiesID props;
|
||||
};
|
||||
static int properties_thread(void *arg)
|
||||
{
|
||||
struct properties_thread_data *data = (struct properties_thread_data *)arg;
|
||||
|
||||
while (!data->done) {
|
||||
SDL_LockProperties(data->props);
|
||||
SDL_SetProperty(data->props, "a", "thread_loop");
|
||||
SDL_UnlockProperties(data->props);
|
||||
}
|
||||
SDL_LockProperties(data->props);
|
||||
SDL_SetProperty(data->props, "a", "thread_done");
|
||||
SDL_UnlockProperties(data->props);
|
||||
return 0;
|
||||
}
|
||||
static int properties_testLocking(void *arg)
|
||||
{
|
||||
struct properties_thread_data data;
|
||||
SDL_Thread *thread;
|
||||
void *value;
|
||||
|
||||
SDLTest_AssertPass("Testing property locking");
|
||||
data.done = SDL_FALSE;
|
||||
data.props = SDL_CreateProperties();
|
||||
SDLTest_AssertPass("Setting property to 'init'");
|
||||
SDL_SetProperty(data.props, "a", "init");
|
||||
thread = SDL_CreateThread(properties_thread, "properties_thread", &data);
|
||||
if (thread) {
|
||||
SDLTest_AssertPass("Waiting for property to change to 'thread_loop'");
|
||||
for ( ; ; )
|
||||
{
|
||||
SDL_Delay(10);
|
||||
SDL_LockProperties(data.props);
|
||||
value = SDL_GetProperty(data.props, "a", NULL);
|
||||
SDL_UnlockProperties(data.props);
|
||||
|
||||
if (!value || SDL_strcmp((const char *)value, "thread_loop") == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "thread_loop") == 0,
|
||||
"After thread loop, property is %s, expected 'thread_loop'", value ? (const char *)value : "NULL");
|
||||
|
||||
SDLTest_AssertPass("Setting property to 'main'");
|
||||
SDL_LockProperties(data.props);
|
||||
SDL_SetProperty(data.props, "a", "main");
|
||||
SDL_Delay(100);
|
||||
value = SDL_GetProperty(data.props, "a", NULL);
|
||||
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "main") == 0,
|
||||
"After 100ms sleep, property is %s, expected 'main'", value ? (const char *)value : "NULL");
|
||||
SDL_UnlockProperties(data.props);
|
||||
|
||||
data.done = SDL_TRUE;
|
||||
SDL_WaitThread(thread, NULL);
|
||||
|
||||
value = SDL_GetProperty(data.props, "a", NULL);
|
||||
SDLTest_AssertCheck(value && SDL_strcmp((const char *)value, "thread_done") == 0,
|
||||
"After thread complete, property is %s, expected 'thread_done'", value ? (const char *)value : "NULL");
|
||||
}
|
||||
SDL_DestroyProperties(data.props);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* Properties test cases */
|
||||
static const SDLTest_TestCaseReference propertiesTest1 = {
|
||||
(SDLTest_TestCaseFp)properties_testBasic, "properties_testBasic", "Test basic property functionality", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference propertiesTest2 = {
|
||||
(SDLTest_TestCaseFp)properties_testCleanup, "properties_testCleanup", "Test property cleanup functionality", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference propertiesTest3 = {
|
||||
(SDLTest_TestCaseFp)properties_testLocking, "properties_testLocking", "Test property locking functionality", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of Properties test cases */
|
||||
static const SDLTest_TestCaseReference *propertiesTests[] = {
|
||||
&propertiesTest1, &propertiesTest2, &propertiesTest3, NULL
|
||||
};
|
||||
|
||||
/* Properties test suite (global) */
|
||||
SDLTest_TestSuiteReference propertiesTestSuite = {
|
||||
"Properties",
|
||||
NULL,
|
||||
propertiesTests,
|
||||
NULL
|
||||
};
|
@ -11,7 +11,7 @@
|
||||
/* Helper functions */
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_GetRectAndLineIntersection results
|
||||
* Private helper to check SDL_GetRectAndLineIntersection results
|
||||
*/
|
||||
static void validateIntersectRectAndLineResults(
|
||||
SDL_bool intersection, SDL_bool expectedIntersection,
|
||||
@ -38,7 +38,7 @@ static void validateIntersectRectAndLineResults(
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectAndLineIntersection() clipping cases
|
||||
* Tests SDL_GetRectAndLineIntersection() clipping cases
|
||||
*
|
||||
* \sa SDL_GetRectAndLineIntersection
|
||||
*/
|
||||
@ -107,7 +107,7 @@ static int rect_testIntersectRectAndLine(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectAndLineIntersection() non-clipping case line inside
|
||||
* Tests SDL_GetRectAndLineIntersection() non-clipping case line inside
|
||||
*
|
||||
* \sa SDL_GetRectAndLineIntersection
|
||||
*/
|
||||
@ -172,7 +172,7 @@ static int rect_testIntersectRectAndLineInside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectAndLineIntersection() non-clipping cases outside
|
||||
* Tests SDL_GetRectAndLineIntersection() non-clipping cases outside
|
||||
*
|
||||
* \sa SDL_GetRectAndLineIntersection
|
||||
*/
|
||||
@ -225,7 +225,7 @@ static int rect_testIntersectRectAndLineOutside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectAndLineIntersection() with empty rectangle
|
||||
* Tests SDL_GetRectAndLineIntersection() with empty rectangle
|
||||
*
|
||||
* \sa SDL_GetRectAndLineIntersection
|
||||
*/
|
||||
@ -258,7 +258,7 @@ static int rect_testIntersectRectAndLineEmpty(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_GetRectAndLineIntersection() with invalid parameters
|
||||
* Negative tests against SDL_GetRectAndLineIntersection() with invalid parameters
|
||||
*
|
||||
* \sa SDL_GetRectAndLineIntersection
|
||||
*/
|
||||
@ -291,7 +291,7 @@ static int rect_testIntersectRectAndLineParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_HasRectIntersection results
|
||||
* Private helper to check SDL_HasRectIntersection results
|
||||
*/
|
||||
static void validateHasIntersectionResults(
|
||||
SDL_bool intersection, SDL_bool expectedIntersection,
|
||||
@ -314,7 +314,7 @@ static void validateHasIntersectionResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_GetRectIntersection results
|
||||
* Private helper to check SDL_GetRectIntersection results
|
||||
*/
|
||||
static void validateIntersectRectResults(
|
||||
SDL_bool intersection, SDL_bool expectedIntersection,
|
||||
@ -333,7 +333,7 @@ static void validateIntersectRectResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_GetRectUnion results
|
||||
* Private helper to check SDL_GetRectUnion results
|
||||
*/
|
||||
static void validateUnionRectResults(
|
||||
SDL_Rect *rectA, SDL_Rect *rectB, SDL_Rect *refRectA, SDL_Rect *refRectB,
|
||||
@ -356,7 +356,7 @@ static void validateUnionRectResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_RectEmpty results
|
||||
* Private helper to check SDL_RectEmpty results
|
||||
*/
|
||||
static void validateRectEmptyResults(
|
||||
SDL_bool empty, SDL_bool expectedEmpty,
|
||||
@ -374,7 +374,7 @@ static void validateRectEmptyResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_RectsEqual results
|
||||
* Private helper to check SDL_RectsEqual results
|
||||
*/
|
||||
static void validateRectEqualsResults(
|
||||
SDL_bool equals, SDL_bool expectedEquals,
|
||||
@ -397,7 +397,7 @@ static void validateRectEqualsResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Private helper to check SDL_RectsEqualFloat results
|
||||
* Private helper to check SDL_RectsEqualFloat results
|
||||
*/
|
||||
static void validateFRectEqualsResults(
|
||||
SDL_bool equals, SDL_bool expectedEquals,
|
||||
@ -423,7 +423,7 @@ static void validateFRectEqualsResults(
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectIntersection() with B fully inside A
|
||||
* Tests SDL_GetRectIntersection() with B fully inside A
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -450,7 +450,7 @@ static int rect_testIntersectRectInside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectIntersection() with B fully outside A
|
||||
* Tests SDL_GetRectIntersection() with B fully outside A
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -477,7 +477,7 @@ static int rect_testIntersectRectOutside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectIntersection() with B partially intersecting A
|
||||
* Tests SDL_GetRectIntersection() with B partially intersecting A
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -565,7 +565,7 @@ static int rect_testIntersectRectPartial(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectIntersection() with 1x1 pixel sized rectangles
|
||||
* Tests SDL_GetRectIntersection() with 1x1 pixel sized rectangles
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -611,7 +611,7 @@ static int rect_testIntersectRectPoint(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectIntersection() with empty rectangles
|
||||
* Tests SDL_GetRectIntersection() with empty rectangles
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -682,7 +682,7 @@ static int rect_testIntersectRectEmpty(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_GetRectIntersection() with invalid parameters
|
||||
* Negative tests against SDL_GetRectIntersection() with invalid parameters
|
||||
*
|
||||
* \sa SDL_GetRectIntersection
|
||||
*/
|
||||
@ -711,7 +711,7 @@ static int rect_testIntersectRectParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasRectIntersection() with B fully inside A
|
||||
* Tests SDL_HasRectIntersection() with B fully inside A
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -737,7 +737,7 @@ static int rect_testHasIntersectionInside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasRectIntersection() with B fully outside A
|
||||
* Tests SDL_HasRectIntersection() with B fully outside A
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -763,7 +763,7 @@ static int rect_testHasIntersectionOutside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasRectIntersection() with B partially intersecting A
|
||||
* Tests SDL_HasRectIntersection() with B partially intersecting A
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -829,7 +829,7 @@ static int rect_testHasIntersectionPartial(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasRectIntersection() with 1x1 pixel sized rectangles
|
||||
* Tests SDL_HasRectIntersection() with 1x1 pixel sized rectangles
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -874,7 +874,7 @@ static int rect_testHasIntersectionPoint(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_HasRectIntersection() with empty rectangles
|
||||
* Tests SDL_HasRectIntersection() with empty rectangles
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -931,7 +931,7 @@ static int rect_testHasIntersectionEmpty(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_HasRectIntersection() with invalid parameters
|
||||
* Negative tests against SDL_HasRectIntersection() with invalid parameters
|
||||
*
|
||||
* \sa SDL_HasRectIntersection
|
||||
*/
|
||||
@ -953,7 +953,7 @@ static int rect_testHasIntersectionParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test SDL_GetRectEnclosingPoints() without clipping
|
||||
* Test SDL_GetRectEnclosingPoints() without clipping
|
||||
*
|
||||
* \sa SDL_GetRectEnclosingPoints
|
||||
*/
|
||||
@ -1030,7 +1030,7 @@ static int rect_testEnclosePoints(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test SDL_GetRectEnclosingPoints() with repeated input points
|
||||
* Test SDL_GetRectEnclosingPoints() with repeated input points
|
||||
*
|
||||
* \sa SDL_GetRectEnclosingPoints
|
||||
*/
|
||||
@ -1113,7 +1113,7 @@ static int rect_testEnclosePointsRepeatedInput(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test SDL_GetRectEnclosingPoints() with clipping
|
||||
* Test SDL_GetRectEnclosingPoints() with clipping
|
||||
*
|
||||
* \sa SDL_GetRectEnclosingPoints
|
||||
*/
|
||||
@ -1219,7 +1219,7 @@ static int rect_testEnclosePointsWithClipping(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_GetRectEnclosingPoints() with invalid parameters
|
||||
* Negative tests against SDL_GetRectEnclosingPoints() with invalid parameters
|
||||
*
|
||||
* \sa SDL_GetRectEnclosingPoints
|
||||
*/
|
||||
@ -1246,7 +1246,7 @@ static int rect_testEnclosePointsParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectUnion() where rect B is outside rect A
|
||||
* Tests SDL_GetRectUnion() where rect B is outside rect A
|
||||
*
|
||||
* \sa SDL_GetRectUnion
|
||||
*/
|
||||
@ -1324,7 +1324,7 @@ static int rect_testUnionRectOutside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectUnion() where rect A or rect B are empty
|
||||
* Tests SDL_GetRectUnion() where rect A or rect B are empty
|
||||
*
|
||||
* \sa SDL_GetRectUnion
|
||||
*/
|
||||
@ -1388,7 +1388,7 @@ static int rect_testUnionRectEmpty(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_GetRectUnion() where rect B is inside rect A
|
||||
* Tests SDL_GetRectUnion() where rect B is inside rect A
|
||||
*
|
||||
* \sa SDL_GetRectUnion
|
||||
*/
|
||||
@ -1459,7 +1459,7 @@ static int rect_testUnionRectInside(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_GetRectUnion() with invalid parameters
|
||||
* Negative tests against SDL_GetRectUnion() with invalid parameters
|
||||
*
|
||||
* \sa SDL_GetRectUnion
|
||||
*/
|
||||
@ -1486,7 +1486,7 @@ static int rect_testUnionRectParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_RectEmpty() with various inputs
|
||||
* Tests SDL_RectEmpty() with various inputs
|
||||
*
|
||||
* \sa SDL_RectEmpty
|
||||
*/
|
||||
@ -1528,7 +1528,7 @@ static int rect_testRectEmpty(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_RectEmpty() with invalid parameters
|
||||
* Negative tests against SDL_RectEmpty() with invalid parameters
|
||||
*
|
||||
* \sa SDL_RectEmpty
|
||||
*/
|
||||
@ -1544,7 +1544,7 @@ static int rect_testRectEmptyParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_RectsEqual() with various inputs
|
||||
* Tests SDL_RectsEqual() with various inputs
|
||||
*
|
||||
* \sa SDL_RectsEqual
|
||||
*/
|
||||
@ -1573,7 +1573,7 @@ static int rect_testRectEquals(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_RectsEqual() with invalid parameters
|
||||
* Negative tests against SDL_RectsEqual() with invalid parameters
|
||||
*
|
||||
* \sa SDL_RectsEqual
|
||||
*/
|
||||
@ -1605,7 +1605,7 @@ static int rect_testRectEqualsParam(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests SDL_RectsEqualFloat() with various inputs
|
||||
* Tests SDL_RectsEqualFloat() with various inputs
|
||||
*
|
||||
* \sa SDL_RectsEqualFloat
|
||||
*/
|
||||
@ -1634,7 +1634,7 @@ static int rect_testFRectEquals(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Negative tests against SDL_RectsEqualFloat() with invalid parameters
|
||||
* Negative tests against SDL_RectsEqualFloat() with invalid parameters
|
||||
*
|
||||
* \sa SDL_RectsEqualFloat
|
||||
*/
|
||||
@ -1804,7 +1804,7 @@ static const SDLTest_TestCaseReference rectTest31 = {
|
||||
};
|
||||
|
||||
/**
|
||||
* \brief Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
|
||||
* Sequence of Rect test cases; functions that handle simple rectangles including overlaps and merges.
|
||||
*/
|
||||
static const SDLTest_TestCaseReference *rectTests[] = {
|
||||
&rectTest1, &rectTest2, &rectTest3, &rectTest4, &rectTest5, &rectTest6, &rectTest7, &rectTest8, &rectTest9, &rectTest10, &rectTest11, &rectTest12, &rectTest13, &rectTest14,
|
||||
|
@ -49,6 +49,7 @@ static int isSupported(int code);
|
||||
static void InitCreateRenderer(void *arg)
|
||||
{
|
||||
int width = 320, height = 240;
|
||||
int renderer_flags = SDL_RENDERER_ACCELERATED;
|
||||
renderer = NULL;
|
||||
window = SDL_CreateWindow("render_testCreateRenderer", width, height, 0);
|
||||
SDLTest_AssertPass("SDL_CreateWindow()");
|
||||
@ -57,9 +58,13 @@ static void InitCreateRenderer(void *arg)
|
||||
return;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_ACCELERATED);
|
||||
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "dummy") == 0) {
|
||||
renderer_flags = 0;
|
||||
}
|
||||
|
||||
renderer = SDL_CreateRenderer(window, NULL, renderer_flags);
|
||||
SDLTest_AssertPass("SDL_CreateRenderer()");
|
||||
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result");
|
||||
SDLTest_AssertCheck(renderer != NULL, "Check SDL_CreateRenderer result: %s", renderer != NULL ? "success" : SDL_GetError());
|
||||
if (renderer == NULL) {
|
||||
SDL_DestroyWindow(window);
|
||||
return;
|
||||
@ -71,13 +76,13 @@ static void InitCreateRenderer(void *arg)
|
||||
*/
|
||||
static 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");
|
||||
@ -85,7 +90,7 @@ static void CleanupDestroyRenderer(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests call to SDL_GetNumRenderDrivers
|
||||
* Tests call to SDL_GetNumRenderDrivers
|
||||
*
|
||||
* \sa SDL_GetNumRenderDrivers
|
||||
*/
|
||||
@ -98,7 +103,7 @@ static int render_testGetNumRenderDrivers(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests the SDL primitives for rendering.
|
||||
* Tests the SDL primitives for rendering.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawColor
|
||||
* \sa SDL_RenderFillRect
|
||||
@ -185,7 +190,7 @@ static int render_testPrimitives(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests the SDL primitives with alpha for rendering.
|
||||
* Tests the SDL primitives with alpha for rendering.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawColor
|
||||
* \sa SDL_SetRenderDrawBlendMode
|
||||
@ -328,7 +333,7 @@ static int render_testPrimitivesBlend(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some blitting routines.
|
||||
* Tests some blitting routines.
|
||||
*
|
||||
* \sa SDL_RenderTexture
|
||||
* \sa SDL_DestroyTexture
|
||||
@ -395,7 +400,7 @@ static int render_testBlit(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Blits doing color tests.
|
||||
* Blits doing color tests.
|
||||
*
|
||||
* \sa SDL_SetTextureColorMod
|
||||
* \sa SDL_RenderTexture
|
||||
@ -469,7 +474,7 @@ static int render_testBlitColor(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests blitting with alpha.
|
||||
* Tests blitting with alpha.
|
||||
*
|
||||
* \sa SDL_SetTextureAlphaMod
|
||||
* \sa SDL_RenderTexture
|
||||
@ -546,7 +551,7 @@ static int render_testBlitAlpha(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests a blend mode.
|
||||
* Tests a blend mode.
|
||||
*
|
||||
* \sa SDL_SetTextureBlendMode
|
||||
* \sa SDL_RenderTexture
|
||||
@ -597,7 +602,7 @@ testBlitBlendMode(SDL_Texture *tface, int mode)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines.
|
||||
* Tests some more blitting routines.
|
||||
*
|
||||
* \sa SDL_SetTextureColorMod
|
||||
* \sa SDL_SetTextureAlphaMod
|
||||
@ -754,7 +759,7 @@ static int render_testBlitBlend(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test viewport
|
||||
* Test viewport
|
||||
*/
|
||||
static int render_testViewport(void *arg)
|
||||
{
|
||||
@ -811,7 +816,7 @@ static int render_testViewport(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test logical size
|
||||
* Test logical size
|
||||
*/
|
||||
static int render_testLogicalSize(void *arg)
|
||||
{
|
||||
@ -921,7 +926,7 @@ static int render_testLogicalSize(void *arg)
|
||||
/* Helper functions */
|
||||
|
||||
/**
|
||||
* \brief Checks to see if functionality is supported. Helper function.
|
||||
* Checks to see if functionality is supported. Helper function.
|
||||
*/
|
||||
static int
|
||||
isSupported(int code)
|
||||
@ -930,7 +935,7 @@ isSupported(int code)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test to see if we can vary the draw color. Helper function.
|
||||
* Test to see if we can vary the draw color. Helper function.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawColor
|
||||
* \sa SDL_GetRenderDrawColor
|
||||
@ -971,7 +976,7 @@ hasDrawColor(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test to see if we can vary the blend mode. Helper function.
|
||||
* Test to see if we can vary the blend mode. Helper function.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawBlendMode
|
||||
* \sa SDL_GetRenderDrawBlendMode
|
||||
@ -1038,7 +1043,7 @@ hasBlendModes(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Loads the test image 'Face' as texture. Helper function.
|
||||
* Loads the test image 'Face' as texture. Helper function.
|
||||
*
|
||||
* \sa SDL_CreateTextureFromSurface
|
||||
*/
|
||||
@ -1049,12 +1054,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());
|
||||
}
|
||||
|
||||
@ -1064,7 +1069,7 @@ loadTestFace(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test to see if can set texture color mode. Helper function.
|
||||
* Test to see if can set texture color mode. Helper function.
|
||||
*
|
||||
* \sa SDL_SetTextureColorMod
|
||||
* \sa SDL_GetTextureColorMod
|
||||
@ -1080,7 +1085,7 @@ hasTexColor(void)
|
||||
|
||||
/* Get test face. */
|
||||
tface = loadTestFace();
|
||||
if (tface == NULL) {
|
||||
if (!tface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1107,7 +1112,7 @@ hasTexColor(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Test to see if we can vary the alpha of the texture. Helper function.
|
||||
* Test to see if we can vary the alpha of the texture. Helper function.
|
||||
*
|
||||
* \sa SDL_SetTextureAlphaMod
|
||||
* \sa SDL_GetTextureAlphaMod
|
||||
@ -1123,7 +1128,7 @@ hasTexAlpha(void)
|
||||
|
||||
/* Get test face. */
|
||||
tface = loadTestFace();
|
||||
if (tface == NULL) {
|
||||
if (!tface) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1150,7 +1155,7 @@ hasTexAlpha(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Compares screen pixels with image pixels. Helper function.
|
||||
* Compares screen pixels with image pixels. Helper function.
|
||||
*
|
||||
* \param referenceSurface Image to compare against.
|
||||
* \param allowable_error allowed difference from the reference image
|
||||
@ -1195,7 +1200,7 @@ compare(SDL_Surface *referenceSurface, int allowable_error)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Clears the screen. Helper function.
|
||||
* Clears the screen. Helper function.
|
||||
*
|
||||
* \sa SDL_SetRenderDrawColor
|
||||
* \sa SDL_RenderClear
|
||||
|
@ -90,7 +90,7 @@ static void RWopsTearDown(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Makes sure parameters work properly. Local helper function.
|
||||
* Makes sure parameters work properly. Local helper function.
|
||||
*
|
||||
* \sa SDL_RWseek
|
||||
* \sa SDL_RWread
|
||||
@ -110,11 +110,11 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
|
||||
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
|
||||
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
|
||||
|
||||
/* Test write. */
|
||||
/* Test write */
|
||||
s = SDL_RWwrite(rw, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1);
|
||||
SDLTest_AssertPass("Call to SDL_RWwrite succeeded");
|
||||
if (write) {
|
||||
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing one byte with SDL_RWwrite, expected 1, got %i", (int)s);
|
||||
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing with SDL_RWwrite, expected %i, got %i", (int)sizeof(RWopsHelloWorldTestString) - 1, (int)s);
|
||||
} else {
|
||||
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int)s);
|
||||
}
|
||||
@ -129,6 +129,37 @@ static void testGenericRWopsValidations(SDL_RWops *rw, SDL_bool write)
|
||||
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
|
||||
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
|
||||
|
||||
/* Test read */
|
||||
s = SDL_RWread(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
|
||||
SDLTest_AssertPass("Call to SDL_RWread succeeded");
|
||||
SDLTest_AssertCheck(
|
||||
s == (sizeof(RWopsHelloWorldTestString) - 1),
|
||||
"Verify result from SDL_RWread, expected %i, got %i",
|
||||
(int)(sizeof(RWopsHelloWorldTestString) - 1),
|
||||
(int)s);
|
||||
SDLTest_AssertCheck(
|
||||
SDL_memcmp(buf, RWopsHelloWorldTestString, sizeof(RWopsHelloWorldTestString) - 1) == 0,
|
||||
"Verify read bytes match expected string, expected '%s', got '%s'", RWopsHelloWorldTestString, buf);
|
||||
|
||||
/* Test seek back to start */
|
||||
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
|
||||
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
|
||||
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
|
||||
|
||||
/* Test printf */
|
||||
s = SDL_RWprintf(rw, "%s", RWopsHelloWorldTestString);
|
||||
SDLTest_AssertPass("Call to SDL_RWprintf succeeded");
|
||||
if (write) {
|
||||
SDLTest_AssertCheck(s == sizeof(RWopsHelloWorldTestString) - 1, "Verify result of writing with SDL_RWprintf, expected %i, got %i", (int)sizeof(RWopsHelloWorldTestString) - 1, (int)s);
|
||||
} else {
|
||||
SDLTest_AssertCheck(s == 0, "Verify result of writing with SDL_RWwrite, expected: 0, got %i", (int)s);
|
||||
}
|
||||
|
||||
/* Test seek back to start */
|
||||
i = SDL_RWseek(rw, 0, SDL_RW_SEEK_SET);
|
||||
SDLTest_AssertPass("Call to SDL_RWseek succeeded");
|
||||
SDLTest_AssertCheck(i == (Sint64)0, "Verify seek to 0 with SDL_RWseek (SDL_RW_SEEK_SET), expected 0, got %" SDL_PRIs64, i);
|
||||
|
||||
/* Test read */
|
||||
s = SDL_RWread(rw, buf, sizeof(RWopsHelloWorldTestString) - 1);
|
||||
SDLTest_AssertPass("Call to SDL_RWread succeeded");
|
||||
@ -214,7 +245,7 @@ static int rwops_testParamNegative(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests opening from memory.
|
||||
* Tests opening from memory.
|
||||
*
|
||||
* \sa SDL_RWFromMem
|
||||
* \sa SDL_RWClose
|
||||
@ -253,7 +284,7 @@ static int rwops_testMem(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests opening from memory.
|
||||
* Tests opening from memory.
|
||||
*
|
||||
* \sa SDL_RWFromConstMem
|
||||
* \sa SDL_RWClose
|
||||
@ -288,7 +319,7 @@ static int rwops_testConstMem(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests reading from file.
|
||||
* Tests reading from file.
|
||||
*
|
||||
* \sa SDL_RWFromFile
|
||||
* \sa SDL_RWClose
|
||||
@ -335,7 +366,7 @@ static int rwops_testFileRead(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests writing from file.
|
||||
* Tests writing from file.
|
||||
*
|
||||
* \sa SDL_RWFromFile
|
||||
* \sa SDL_RWClose
|
||||
@ -382,7 +413,7 @@ static int rwops_testFileWrite(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests alloc and free RW context.
|
||||
* Tests alloc and free RW context.
|
||||
*
|
||||
* \sa SDL_CreateRW
|
||||
* \sa SDL_DestroyRW
|
||||
@ -410,7 +441,7 @@ static int rwops_testAllocFree(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Compare memory and file reads
|
||||
* Compare memory and file reads
|
||||
*
|
||||
* \sa SDL_RWFromMem
|
||||
* \sa SDL_RWFromFile
|
||||
@ -473,7 +504,7 @@ static int rwops_testCompareRWFromMemWithRWFromFile(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests writing and reading from file using endian aware functions.
|
||||
* Tests writing and reading from file using endian aware functions.
|
||||
*
|
||||
* \sa SDL_RWFromFile
|
||||
* \sa SDL_RWClose
|
||||
|
@ -12,7 +12,7 @@
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_GenerateRunSeed()
|
||||
* Calls to SDLTest_GenerateRunSeed()
|
||||
*/
|
||||
static int sdltest_generateRunSeed(void *arg)
|
||||
{
|
||||
@ -42,7 +42,7 @@ static int sdltest_generateRunSeed(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_GetFuzzerInvocationCount()
|
||||
* Calls to SDLTest_GetFuzzerInvocationCount()
|
||||
*/
|
||||
static int sdltest_getFuzzerInvocationCount(void *arg)
|
||||
{
|
||||
@ -64,7 +64,7 @@ static int sdltest_getFuzzerInvocationCount(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random number generators
|
||||
* Calls to random number generators
|
||||
*/
|
||||
static int sdltest_randomNumber(void *arg)
|
||||
{
|
||||
@ -131,7 +131,7 @@ static int sdltest_randomNumber(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Uint8
|
||||
* Calls to random boundary number generators for Uint8
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberUint8(void *arg)
|
||||
{
|
||||
@ -240,7 +240,7 @@ static int sdltest_randomBoundaryNumberUint8(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Uint16
|
||||
* Calls to random boundary number generators for Uint16
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberUint16(void *arg)
|
||||
{
|
||||
@ -349,7 +349,7 @@ static int sdltest_randomBoundaryNumberUint16(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Uint32
|
||||
* Calls to random boundary number generators for Uint32
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberUint32(void *arg)
|
||||
{
|
||||
@ -458,7 +458,7 @@ static int sdltest_randomBoundaryNumberUint32(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Uint64
|
||||
* Calls to random boundary number generators for Uint64
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberUint64(void *arg)
|
||||
{
|
||||
@ -567,7 +567,7 @@ static int sdltest_randomBoundaryNumberUint64(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Sint8
|
||||
* Calls to random boundary number generators for Sint8
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberSint8(void *arg)
|
||||
{
|
||||
@ -676,7 +676,7 @@ static int sdltest_randomBoundaryNumberSint8(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Sint16
|
||||
* Calls to random boundary number generators for Sint16
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberSint16(void *arg)
|
||||
{
|
||||
@ -785,7 +785,7 @@ static int sdltest_randomBoundaryNumberSint16(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Sint32
|
||||
* Calls to random boundary number generators for Sint32
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberSint32(void *arg)
|
||||
{
|
||||
@ -901,7 +901,7 @@ static int sdltest_randomBoundaryNumberSint32(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to random boundary number generators for Sint64
|
||||
* Calls to random boundary number generators for Sint64
|
||||
*/
|
||||
static int sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
{
|
||||
@ -1010,7 +1010,7 @@ static int sdltest_randomBoundaryNumberSint64(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_RandomIntegerInRange
|
||||
* Calls to SDLTest_RandomIntegerInRange
|
||||
*/
|
||||
static int sdltest_randomIntegerInRange(void *arg)
|
||||
{
|
||||
@ -1084,7 +1084,7 @@ static int sdltest_randomIntegerInRange(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_RandomAsciiString
|
||||
* Calls to SDLTest_RandomAsciiString
|
||||
*/
|
||||
static int sdltest_randomAsciiString(void *arg)
|
||||
{
|
||||
@ -1116,7 +1116,7 @@ static int sdltest_randomAsciiString(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_RandomAsciiStringWithMaximumLength
|
||||
* Calls to SDLTest_RandomAsciiStringWithMaximumLength
|
||||
*/
|
||||
static int sdltest_randomAsciiStringWithMaximumLength(void *arg)
|
||||
{
|
||||
@ -1168,7 +1168,7 @@ static int sdltest_randomAsciiStringWithMaximumLength(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Calls to SDLTest_RandomAsciiStringOfSize
|
||||
* Calls to SDLTest_RandomAsciiStringOfSize
|
||||
*/
|
||||
static int sdltest_randomAsciiStringOfSize(void *arg)
|
||||
{
|
||||
|
@ -8,7 +8,7 @@
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_strnlen
|
||||
* Call to SDL_strnlen
|
||||
*/
|
||||
#undef SDL_strnlen
|
||||
static int stdlib_strnlen(void *arg)
|
||||
@ -36,7 +36,7 @@ static int stdlib_strnlen(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_strlcpy
|
||||
* Call to SDL_strlcpy
|
||||
*/
|
||||
#undef SDL_strlcpy
|
||||
static int stdlib_strlcpy(void *arg)
|
||||
@ -60,6 +60,68 @@ static int stdlib_strlcpy(void *arg)
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call to SDL_strstr
|
||||
*/
|
||||
static int stdlib_strstr(void *arg)
|
||||
{
|
||||
char *result;
|
||||
const char *text = "abcdef";
|
||||
const char *expected;
|
||||
|
||||
result = SDL_strstr(text, "");
|
||||
expected = text;
|
||||
SDLTest_AssertPass("Call to SDL_strstr(text, \"\")");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strstr(text, "abc");
|
||||
expected = text;
|
||||
SDLTest_AssertPass("Call to SDL_strstr(text, \"abc\")");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strstr(text, "bcd");
|
||||
expected = text+1;
|
||||
SDLTest_AssertPass("Call to SDL_strstr(text, \"bcd\")");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strstr(text, "xyz");
|
||||
expected = NULL;
|
||||
SDLTest_AssertPass("Call to SDL_strstr(text, \"xyz\")");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
||||
|
||||
result = SDL_strnstr(text, "", SDL_strlen(text));
|
||||
expected = text;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"\", SDL_strlen(text))");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strnstr(text, "abc", SDL_strlen(text));
|
||||
expected = text;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"abc\", SDL_strlen(text))");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strnstr(text, "bcd", SDL_strlen(text));
|
||||
expected = text+1;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"bcd\", SDL_strlen(text))");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: %s, got: %s", expected, result);
|
||||
|
||||
result = SDL_strnstr(text, "bcd", 3);
|
||||
expected = NULL;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"bcd\", 3)");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
||||
|
||||
result = SDL_strnstr(text, "xyz", 3);
|
||||
expected = NULL;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"xyz\", 3)");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
||||
|
||||
result = SDL_strnstr(text, "xyz", SDL_strlen(text)*100000);
|
||||
expected = NULL;
|
||||
SDLTest_AssertPass("Call to SDL_strnstr(text, \"xyz\", SDL_strlen(text)*100000)");
|
||||
SDLTest_AssertCheck(result == expected, "Check result, expected: (null), got: %s", result);
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
#if defined(HAVE_WFORMAT) || defined(HAVE_WFORMAT_EXTRA_ARGS)
|
||||
#pragma GCC diagnostic push
|
||||
#ifdef HAVE_WFORMAT
|
||||
@ -71,7 +133,7 @@ static int stdlib_strlcpy(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_snprintf
|
||||
* Call to SDL_snprintf
|
||||
*/
|
||||
#undef SDL_snprintf
|
||||
static int stdlib_snprintf(void *arg)
|
||||
@ -258,11 +320,18 @@ static int stdlib_snprintf(void *arg)
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
|
||||
SDLTest_AssertCheck(result == SDL_strlen(expected), "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";
|
||||
SDLTest_AssertPass("Call to SDL_snprintf(text, sizeof(text), \"%%p\", 0x1ba07bddf60)");
|
||||
SDLTest_AssertCheck(SDL_strcmp(text, expected) == 0, "Check text, expected: '%s', got: '%s'", expected, text);
|
||||
SDLTest_AssertCheck(result == SDL_strlen(expected), "Check result value, expected: %d, got: %d", (int)SDL_strlen(expected), result);
|
||||
}
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_swprintf
|
||||
* Call to SDL_swprintf
|
||||
*/
|
||||
#undef SDL_swprintf
|
||||
static int stdlib_swprintf(void *arg)
|
||||
@ -429,7 +498,7 @@ static int stdlib_swprintf(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_getenv and SDL_setenv
|
||||
* Call to SDL_getenv and SDL_setenv
|
||||
*/
|
||||
static int stdlib_getsetenv(void *arg)
|
||||
{
|
||||
@ -453,10 +522,10 @@ static 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);
|
||||
@ -572,7 +641,7 @@ static int stdlib_getsetenv(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_sscanf
|
||||
* Call to SDL_sscanf
|
||||
*/
|
||||
#undef SDL_sscanf
|
||||
static int stdlib_sscanf(void *arg)
|
||||
@ -585,7 +654,7 @@ static 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;
|
||||
@ -649,6 +718,82 @@ static 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;
|
||||
}
|
||||
|
||||
@ -665,7 +810,7 @@ static int stdlib_sscanf(void *arg)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_aligned_alloc
|
||||
* Call to SDL_aligned_alloc
|
||||
*/
|
||||
static int stdlib_aligned_alloc(void *arg)
|
||||
{
|
||||
@ -854,22 +999,26 @@ static const SDLTest_TestCaseReference stdlibTest2 = {
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest3 = {
|
||||
stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED
|
||||
stdlib_strstr, "stdlib_strstr", "Call to SDL_strstr", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest4 = {
|
||||
stdlib_swprintf, "stdlib_swprintf", "Call to SDL_swprintf", TEST_ENABLED
|
||||
stdlib_snprintf, "stdlib_snprintf", "Call to SDL_snprintf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest5 = {
|
||||
stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED
|
||||
stdlib_swprintf, "stdlib_swprintf", "Call to SDL_swprintf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest6 = {
|
||||
stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED
|
||||
stdlib_getsetenv, "stdlib_getsetenv", "Call to SDL_getenv and SDL_setenv", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest7 = {
|
||||
stdlib_sscanf, "stdlib_sscanf", "Call to SDL_sscanf", TEST_ENABLED
|
||||
};
|
||||
|
||||
static const SDLTest_TestCaseReference stdlibTest8 = {
|
||||
stdlib_aligned_alloc, "stdlib_aligned_alloc", "Call to SDL_aligned_alloc", TEST_ENABLED
|
||||
};
|
||||
|
||||
@ -886,6 +1035,7 @@ static const SDLTest_TestCaseReference *stdlibTests[] = {
|
||||
&stdlibTest5,
|
||||
&stdlibTest6,
|
||||
&stdlibTest7,
|
||||
&stdlibTest8,
|
||||
&stdlibTestOverflow,
|
||||
NULL
|
||||
};
|
||||
|
239
test/testautomation_subsystems.c
Normal file
@ -0,0 +1,239 @@
|
||||
/**
|
||||
* Events test suite
|
||||
*/
|
||||
#include "testautomation_suites.h"
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/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 */
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
};
|
@ -20,15 +20,17 @@ extern SDLTest_TestSuiteReference keyboardTestSuite;
|
||||
extern SDLTest_TestSuiteReference mainTestSuite;
|
||||
extern SDLTest_TestSuiteReference mathTestSuite;
|
||||
extern SDLTest_TestSuiteReference mouseTestSuite;
|
||||
extern SDLTest_TestSuiteReference penTestSuite;
|
||||
extern SDLTest_TestSuiteReference pixelsTestSuite;
|
||||
extern SDLTest_TestSuiteReference platformTestSuite;
|
||||
extern SDLTest_TestSuiteReference propertiesTestSuite;
|
||||
extern SDLTest_TestSuiteReference rectTestSuite;
|
||||
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;
|
||||
extern SDLTest_TestSuiteReference videoTestSuite;
|
||||
|
||||
|
@ -209,7 +209,7 @@ static void AssertFileExist(const char *filename)
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Tests sprite saving and loading
|
||||
* Tests sprite saving and loading
|
||||
*/
|
||||
static int surface_testSaveLoadBitmap(void *arg)
|
||||
{
|
||||
@ -327,7 +327,10 @@ static int surface_testCompleteSurfaceConversion(void *arg)
|
||||
SDL_PIXELFORMAT_RGBA8888,
|
||||
SDL_PIXELFORMAT_ABGR8888,
|
||||
SDL_PIXELFORMAT_BGRA8888,
|
||||
SDL_PIXELFORMAT_XRGB2101010,
|
||||
SDL_PIXELFORMAT_XBGR2101010,
|
||||
SDL_PIXELFORMAT_ARGB2101010,
|
||||
SDL_PIXELFORMAT_ABGR2101010,
|
||||
};
|
||||
SDL_Surface *face = NULL, *cvt1, *cvt2, *final;
|
||||
SDL_PixelFormat *fmt1, *fmt2;
|
||||
@ -386,7 +389,7 @@ static int surface_testCompleteSurfaceConversion(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests sprite loading. A failure case.
|
||||
* Tests sprite loading. A failure case.
|
||||
*/
|
||||
static int surface_testLoadFailure(void *arg)
|
||||
{
|
||||
@ -397,7 +400,7 @@ static int surface_testLoadFailure(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some blitting routines.
|
||||
* Tests some blitting routines.
|
||||
*/
|
||||
static int surface_testBlit(void *arg)
|
||||
{
|
||||
@ -419,7 +422,7 @@ static int surface_testBlit(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some blitting routines with color mod
|
||||
* Tests some blitting routines with color mod
|
||||
*/
|
||||
static int surface_testBlitColorMod(void *arg)
|
||||
{
|
||||
@ -441,7 +444,7 @@ static int surface_testBlitColorMod(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some blitting routines with alpha mod
|
||||
* Tests some blitting routines with alpha mod
|
||||
*/
|
||||
static int surface_testBlitAlphaMod(void *arg)
|
||||
{
|
||||
@ -463,7 +466,7 @@ static int surface_testBlitAlphaMod(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines.
|
||||
* Tests some more blitting routines.
|
||||
*/
|
||||
static int surface_testBlitBlendNone(void *arg)
|
||||
{
|
||||
@ -485,7 +488,7 @@ static int surface_testBlitBlendNone(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines.
|
||||
* Tests some more blitting routines.
|
||||
*/
|
||||
static int surface_testBlitBlendBlend(void *arg)
|
||||
{
|
||||
@ -507,7 +510,7 @@ static int surface_testBlitBlendBlend(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines.
|
||||
* Tests some more blitting routines.
|
||||
*/
|
||||
static int surface_testBlitBlendAdd(void *arg)
|
||||
{
|
||||
@ -529,7 +532,7 @@ static int surface_testBlitBlendAdd(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines.
|
||||
* Tests some more blitting routines.
|
||||
*/
|
||||
static int surface_testBlitBlendMod(void *arg)
|
||||
{
|
||||
@ -551,7 +554,7 @@ static int surface_testBlitBlendMod(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Tests some more blitting routines with loop
|
||||
* Tests some more blitting routines with loop
|
||||
*/
|
||||
static int surface_testBlitBlendLoop(void *arg)
|
||||
{
|
||||
@ -629,12 +632,12 @@ static int surface_testOverflow(void *arg)
|
||||
|
||||
/* Less than 1 byte per pixel: the pitch can legitimately be less than
|
||||
* the width, but it must be enough to hold the appropriate number of
|
||||
* bits per pixel. SDL_PIXELFORMAT_INDEX4LSB* needs 1 byte per 2 pixels. */
|
||||
* bits per pixel. SDL_PIXELFORMAT_INDEX4* needs 1 byte per 2 pixels. */
|
||||
surface = SDL_CreateSurfaceFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 6, 1, 3, SDL_PIXELFORMAT_INDEX4MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "6px * 4 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
@ -643,7 +646,7 @@ static int surface_testOverflow(void *arg)
|
||||
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_CreateSurfaceFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 7, 1, 3, SDL_PIXELFORMAT_INDEX4MSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
@ -652,17 +655,45 @@ static int surface_testOverflow(void *arg)
|
||||
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 7, 1, 4, SDL_PIXELFORMAT_INDEX4MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "7px * 4 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX2* needs 1 byte per 4 pixels. */
|
||||
surface = SDL_CreateSurfaceFrom(buf, 12, 1, 3, SDL_PIXELFORMAT_INDEX2LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 12, 1, 3, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "12px * 2 bits per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 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_CreateSurfaceFrom(buf, 13, 1, 3, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
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_CreateSurfaceFrom(buf, 13, 1, 4, SDL_PIXELFORMAT_INDEX2LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 13, 1, 4, SDL_PIXELFORMAT_INDEX2MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "13px * 2 bits per px fits in 4 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
||||
/* SDL_PIXELFORMAT_INDEX1* needs 1 byte per 8 pixels. */
|
||||
surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 16, 1, 2, SDL_PIXELFORMAT_INDEX1MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "16px * 1 bit per px fits in 2 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
@ -671,7 +702,7 @@ static int surface_testOverflow(void *arg)
|
||||
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_CreateSurfaceFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 17, 1, 2, SDL_PIXELFORMAT_INDEX1MSB);
|
||||
SDLTest_AssertCheck(surface == NULL, "Should detect pitch < width * bpp");
|
||||
SDLTest_AssertCheck(SDL_strcmp(SDL_GetError(), expectedError) == 0,
|
||||
"Expected \"%s\", got \"%s\"", expectedError, SDL_GetError());
|
||||
@ -680,7 +711,7 @@ static int surface_testOverflow(void *arg)
|
||||
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1LSB);
|
||||
surface = SDL_CreateSurfaceFrom(buf, 17, 1, 3, SDL_PIXELFORMAT_INDEX1MSB);
|
||||
SDLTest_AssertCheck(surface != NULL, "17px * 1 bit per px fits in 3 bytes: %s",
|
||||
surface != NULL ? "(success)" : SDL_GetError());
|
||||
SDL_DestroySurface(surface);
|
||||
|
@ -1,60 +0,0 @@
|
||||
/**
|
||||
* SysWM test suite
|
||||
*/
|
||||
|
||||
/* Avoid inclusion of e.g. X11 headers when these are not installed */
|
||||
#include <build_config/SDL_build_config.h>
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
#include <SDL3/SDL_syswm.h>
|
||||
#include <SDL3/SDL_test.h>
|
||||
#include "testautomation_suites.h"
|
||||
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_GetWindowWMInfo
|
||||
*/
|
||||
static int syswm_getWindowWMInfo(void *arg)
|
||||
{
|
||||
int result;
|
||||
SDL_Window *window;
|
||||
SDL_SysWMinfo info;
|
||||
|
||||
window = SDL_CreateWindow("", 0, 0, SDL_WINDOW_HIDDEN);
|
||||
SDLTest_AssertPass("Call to SDL_CreateWindow()");
|
||||
SDLTest_AssertCheck(window != NULL, "Check that value returned from SDL_CreateWindow is not NULL");
|
||||
if (window == NULL) {
|
||||
return TEST_ABORTED;
|
||||
}
|
||||
|
||||
/* Make call */
|
||||
result = SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION);
|
||||
SDLTest_AssertPass("Call to SDL_GetWindowWMInfo()");
|
||||
SDLTest_Log((result == 0) ? "Got window information" : "Couldn't get window information");
|
||||
|
||||
SDL_DestroyWindow(window);
|
||||
SDLTest_AssertPass("Call to SDL_DestroyWindow()");
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
|
||||
/* ================= Test References ================== */
|
||||
|
||||
/* SysWM test cases */
|
||||
static const SDLTest_TestCaseReference syswmTest1 = {
|
||||
(SDLTest_TestCaseFp)syswm_getWindowWMInfo, "syswm_getWindowWMInfo", "Call to SDL_GetWindowWMInfo", TEST_ENABLED
|
||||
};
|
||||
|
||||
/* Sequence of SysWM test cases */
|
||||
static const SDLTest_TestCaseReference *syswmTests[] = {
|
||||
&syswmTest1, NULL
|
||||
};
|
||||
|
||||
/* SysWM test suite (global) */
|
||||
SDLTest_TestSuiteReference syswmTestSuite = {
|
||||
"SysWM",
|
||||
NULL,
|
||||
syswmTests,
|
||||
NULL
|
||||
};
|
@ -30,7 +30,7 @@ static void timerSetUp(void *arg)
|
||||
/* Test case functions */
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_GetPerformanceCounter
|
||||
* Call to SDL_GetPerformanceCounter
|
||||
*/
|
||||
static int timer_getPerformanceCounter(void *arg)
|
||||
{
|
||||
@ -44,7 +44,7 @@ static int timer_getPerformanceCounter(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_GetPerformanceFrequency
|
||||
* Call to SDL_GetPerformanceFrequency
|
||||
*/
|
||||
static int timer_getPerformanceFrequency(void *arg)
|
||||
{
|
||||
@ -58,7 +58,7 @@ static int timer_getPerformanceFrequency(void *arg)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_Delay and SDL_GetTicks
|
||||
* Call to SDL_Delay and SDL_GetTicks
|
||||
*/
|
||||
static int timer_delayAndGetTicks(void *arg)
|
||||
{
|
||||
@ -92,7 +92,10 @@ static int timer_delayAndGetTicks(void *arg)
|
||||
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);
|
||||
#if 0
|
||||
/* Disabled because this might fail on non-interactive systems. Moved to testtimer. */
|
||||
SDLTest_AssertCheck(difference < (testDelay + marginOfError), "Check difference, expected: <%d, got: %" SDL_PRIu64, testDelay + marginOfError, difference);
|
||||
#endif
|
||||
|
||||
return TEST_COMPLETED;
|
||||
}
|
||||
@ -113,7 +116,7 @@ static Uint32 SDLCALL timerTestCallback(Uint32 interval, void *param)
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Call to SDL_AddTimer and SDL_RemoveTimer
|
||||
* Call to SDL_AddTimer and SDL_RemoveTimer
|
||||
*/
|
||||
static int timer_addRemoveTimer(void *arg)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,6 +86,7 @@ static SDL_JoystickID mapping_controller = 0;
|
||||
static int binding_element = SDL_GAMEPAD_ELEMENT_INVALID;
|
||||
static int last_binding_element = SDL_GAMEPAD_ELEMENT_INVALID;
|
||||
static SDL_bool binding_flow = SDL_FALSE;
|
||||
static int binding_flow_direction = 0;
|
||||
static Uint64 binding_advance_time = 0;
|
||||
static SDL_FRect title_area;
|
||||
static SDL_bool title_highlighted;
|
||||
@ -102,10 +103,10 @@ static SDL_GamepadButton virtual_button_active = SDL_GAMEPAD_BUTTON_INVALID;
|
||||
|
||||
static int s_arrBindingOrder[] = {
|
||||
/* Standard sequence */
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||
SDL_GAMEPAD_BUTTON_EAST,
|
||||
SDL_GAMEPAD_BUTTON_WEST,
|
||||
SDL_GAMEPAD_BUTTON_NORTH,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_UP,
|
||||
@ -331,12 +332,13 @@ static void SetCurrentBindingElement(int element, SDL_bool flow)
|
||||
}
|
||||
|
||||
if (element == SDL_GAMEPAD_ELEMENT_INVALID) {
|
||||
binding_flow_direction = 0;
|
||||
last_binding_element = SDL_GAMEPAD_ELEMENT_INVALID;
|
||||
} else {
|
||||
last_binding_element = binding_element;
|
||||
}
|
||||
binding_element = element;
|
||||
binding_flow = flow || (element == SDL_GAMEPAD_BUTTON_A);
|
||||
binding_flow = flow || (element == SDL_GAMEPAD_BUTTON_SOUTH);
|
||||
binding_advance_time = 0;
|
||||
|
||||
for (i = 0; i < controller->num_axes; ++i) {
|
||||
@ -356,6 +358,7 @@ static void SetNextBindingElement(void)
|
||||
|
||||
for (i = 0; i < SDL_arraysize(s_arrBindingOrder); ++i) {
|
||||
if (binding_element == s_arrBindingOrder[i]) {
|
||||
binding_flow_direction = 1;
|
||||
SetCurrentBindingElement(s_arrBindingOrder[i + 1], SDL_TRUE);
|
||||
return;
|
||||
}
|
||||
@ -373,6 +376,7 @@ static void SetPrevBindingElement(void)
|
||||
|
||||
for (i = 1; i < SDL_arraysize(s_arrBindingOrder); ++i) {
|
||||
if (binding_element == s_arrBindingOrder[i]) {
|
||||
binding_flow_direction = -1;
|
||||
SetCurrentBindingElement(s_arrBindingOrder[i - 1], SDL_TRUE);
|
||||
return;
|
||||
}
|
||||
@ -456,8 +460,8 @@ static void CommitBindingElement(const char *binding, SDL_bool force)
|
||||
}
|
||||
}
|
||||
if (native_axis) {
|
||||
AxisInfo current_axis_info;
|
||||
AxisInfo proposed_axis_info;
|
||||
AxisInfo current_axis_info = { 0, 0 };
|
||||
AxisInfo proposed_axis_info = { 0, 0 };
|
||||
SDL_bool current_axis = ParseAxisInfo(current, ¤t_axis_info);
|
||||
SDL_bool proposed_axis = ParseAxisInfo(binding, &proposed_axis_info);
|
||||
|
||||
@ -498,32 +502,50 @@ static void CommitBindingElement(const char *binding, SDL_bool force)
|
||||
if (!ignore_binding && binding_flow && !force) {
|
||||
int existing = GetElementForBinding(mapping, binding);
|
||||
if (existing != SDL_GAMEPAD_ELEMENT_INVALID) {
|
||||
if (existing == SDL_GAMEPAD_BUTTON_A) {
|
||||
if (binding_element == SDL_GAMEPAD_BUTTON_A) {
|
||||
/* Just move on to the next one */
|
||||
SDL_GamepadButton action_forward = SDL_GAMEPAD_BUTTON_SOUTH;
|
||||
SDL_GamepadButton action_backward = SDL_GAMEPAD_BUTTON_EAST;
|
||||
SDL_GamepadButton action_delete = SDL_GAMEPAD_BUTTON_WEST;
|
||||
if (binding_element == action_forward) {
|
||||
/* Bind it! */
|
||||
} else if (binding_element == action_backward) {
|
||||
if (existing == action_forward) {
|
||||
SDL_bool bound_backward = MappingHasElement(controller->mapping, action_backward);
|
||||
if (bound_backward) {
|
||||
/* Just move on to the next one */
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetNextBindingElement();
|
||||
} else {
|
||||
/* You can't skip the backward action, go back and start over */
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetPrevBindingElement();
|
||||
}
|
||||
} else if (existing == action_backward && binding_flow_direction == -1) {
|
||||
/* Keep going backwards */
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetNextBindingElement();
|
||||
SetPrevBindingElement();
|
||||
} else {
|
||||
/* Clear the current binding and move to the next one */
|
||||
binding = NULL;
|
||||
direction = 1;
|
||||
force = SDL_TRUE;
|
||||
}
|
||||
} else if (existing == SDL_GAMEPAD_BUTTON_B) {
|
||||
if (binding_element != SDL_GAMEPAD_BUTTON_A &&
|
||||
last_binding_element != SDL_GAMEPAD_BUTTON_A) {
|
||||
/* Clear the current binding and move to the previous one */
|
||||
binding = NULL;
|
||||
direction = -1;
|
||||
force = SDL_TRUE;
|
||||
/* Bind it! */
|
||||
}
|
||||
} else if (existing == action_forward) {
|
||||
/* Just move on to the next one */
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetNextBindingElement();
|
||||
} else if (existing == action_backward) {
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetPrevBindingElement();
|
||||
} else if (existing == binding_element) {
|
||||
/* We're rebinding the same thing, just move to the next one */
|
||||
ignore_binding = SDL_TRUE;
|
||||
SetNextBindingElement();
|
||||
} else if (binding_element != SDL_GAMEPAD_BUTTON_A &&
|
||||
binding_element != SDL_GAMEPAD_BUTTON_B) {
|
||||
ignore_binding = SDL_TRUE;
|
||||
} else if (existing == action_delete) {
|
||||
/* Clear the current binding and move to the next one */
|
||||
binding = NULL;
|
||||
direction = 1;
|
||||
force = SDL_TRUE;
|
||||
} else if (binding_element != action_forward &&
|
||||
binding_element != action_backward) {
|
||||
/* Actually, we'll just clear the existing binding */
|
||||
/*ignore_binding = SDL_TRUE;*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -572,7 +594,7 @@ static void SetDisplayMode(ControllerDisplayMode mode)
|
||||
if (MappingHasBindings(backup_mapping)) {
|
||||
SetCurrentBindingElement(SDL_GAMEPAD_ELEMENT_INVALID, SDL_FALSE);
|
||||
} else {
|
||||
SetCurrentBindingElement(SDL_GAMEPAD_BUTTON_A, SDL_TRUE);
|
||||
SetCurrentBindingElement(SDL_GAMEPAD_BUTTON_SOUTH, SDL_TRUE);
|
||||
}
|
||||
} else {
|
||||
if (backup_mapping) {
|
||||
@ -701,30 +723,31 @@ static const char *GetBindingInstruction(void)
|
||||
switch (binding_element) {
|
||||
case SDL_GAMEPAD_ELEMENT_INVALID:
|
||||
return "Select an element to bind from the list on the left";
|
||||
case SDL_GAMEPAD_BUTTON_A:
|
||||
if (GetGamepadImageFaceStyle(image) == GAMEPAD_IMAGE_FACE_SONY) {
|
||||
return "Press the Cross (X) button";
|
||||
} else {
|
||||
case SDL_GAMEPAD_BUTTON_SOUTH:
|
||||
case SDL_GAMEPAD_BUTTON_EAST:
|
||||
case SDL_GAMEPAD_BUTTON_WEST:
|
||||
case SDL_GAMEPAD_BUTTON_NORTH:
|
||||
switch (SDL_GetGamepadButtonLabelForType(GetGamepadImageType(image), (SDL_GamepadButton)binding_element)) {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_A:
|
||||
return "Press the A button";
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_B:
|
||||
if (GetGamepadImageFaceStyle(image) == GAMEPAD_IMAGE_FACE_SONY) {
|
||||
return "Press the Circle button";
|
||||
} else {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_B:
|
||||
return "Press the B button";
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_X:
|
||||
if (GetGamepadImageFaceStyle(image) == GAMEPAD_IMAGE_FACE_SONY) {
|
||||
return "Press the Square button";
|
||||
} else {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_X:
|
||||
return "Press the X button";
|
||||
}
|
||||
case SDL_GAMEPAD_BUTTON_Y:
|
||||
if (GetGamepadImageFaceStyle(image) == GAMEPAD_IMAGE_FACE_SONY) {
|
||||
return "Press the Triangle button";
|
||||
} else {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_Y:
|
||||
return "Press the Y button";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_CROSS:
|
||||
return "Press the Cross (X) button";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_CIRCLE:
|
||||
return "Press the Circle button";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_SQUARE:
|
||||
return "Press the Square button";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE:
|
||||
return "Press the Triangle button";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
break;
|
||||
case SDL_GAMEPAD_BUTTON_BACK:
|
||||
return "Press the left center button (Back/View/Share)";
|
||||
case SDL_GAMEPAD_BUTTON_GUIDE:
|
||||
@ -829,7 +852,7 @@ static void AddController(SDL_JoystickID id, SDL_bool verbose)
|
||||
}
|
||||
|
||||
new_controllers = (Controller *)SDL_realloc(controllers, (num_controllers + 1) * sizeof(*controllers));
|
||||
if (new_controllers == NULL) {
|
||||
if (!new_controllers) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -846,9 +869,12 @@ static void AddController(SDL_JoystickID id, SDL_bool verbose)
|
||||
joystick = new_controller->joystick;
|
||||
if (joystick) {
|
||||
if (verbose && !SDL_IsGamepad(id)) {
|
||||
const char *name = SDL_GetJoystickName(new_controller->joystick);
|
||||
const char *path = SDL_GetJoystickPath(new_controller->joystick);
|
||||
const char *name = SDL_GetJoystickName(joystick);
|
||||
const char *path = SDL_GetJoystickPath(joystick);
|
||||
char guid[33];
|
||||
SDL_Log("Opened joystick %s%s%s\n", name, path ? ", " : "", path ? path : "");
|
||||
SDL_GetJoystickGUIDString(SDL_GetJoystickGUID(joystick), guid, sizeof(guid));
|
||||
SDL_Log("No gamepad mapping for %s\n", guid);
|
||||
}
|
||||
} else {
|
||||
SDL_Log("Couldn't open joystick: %s", SDL_GetError());
|
||||
@ -941,8 +967,6 @@ static void HandleGamepadAdded(SDL_JoystickID id, SDL_bool verbose)
|
||||
int i;
|
||||
|
||||
i = FindController(id);
|
||||
|
||||
SDL_assert(i >= 0);
|
||||
if (i < 0) {
|
||||
return;
|
||||
}
|
||||
@ -969,6 +993,10 @@ static void HandleGamepadAdded(SDL_JoystickID id, SDL_bool verbose)
|
||||
if (SDL_GamepadHasRumbleTriggers(gamepad)) {
|
||||
SDL_Log("Trigger rumble supported");
|
||||
}
|
||||
|
||||
if (SDL_GetGamepadPlayerIndex(gamepad) >= 0) {
|
||||
SDL_Log("Player index: %d\n", SDL_GetGamepadPlayerIndex(gamepad));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_arraysize(sensors); ++i) {
|
||||
@ -981,6 +1009,14 @@ static void HandleGamepadAdded(SDL_JoystickID id, SDL_bool verbose)
|
||||
SDL_SetGamepadSensorEnabled(gamepad, sensor, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
char *mapping = SDL_GetGamepadMapping(gamepad);
|
||||
if (mapping) {
|
||||
SDL_Log("Mapping: %s\n", mapping);
|
||||
SDL_free(mapping);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
SDL_Log("Couldn't open gamepad: %s", SDL_GetError());
|
||||
}
|
||||
@ -1084,7 +1120,7 @@ static void OpenVirtualGamepad(void)
|
||||
SDL_Log("Couldn't attach virtual device: %s\n", SDL_GetError());
|
||||
} else {
|
||||
virtual_joystick = SDL_OpenJoystick(virtual_id);
|
||||
if (virtual_joystick == NULL) {
|
||||
if (!virtual_joystick) {
|
||||
SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError());
|
||||
}
|
||||
}
|
||||
@ -1254,6 +1290,13 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
||||
SDL_SetRenderDrawColor(renderer, r, g, b, a);
|
||||
}
|
||||
|
||||
if (controller->joystick) {
|
||||
SDL_snprintf(text, sizeof(text), "(%" SDL_PRIu32 ")", SDL_GetJoystickInstanceID(controller->joystick));
|
||||
x = (float)SCREEN_WIDTH - (FONT_CHARACTER_SIZE * SDL_strlen(text)) - 8.0f;
|
||||
y = 8.0f;
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
}
|
||||
|
||||
if (controller_name && *controller_name) {
|
||||
x = title_area.x + title_area.w / 2 - (FONT_CHARACTER_SIZE * SDL_strlen(controller_name)) / 2;
|
||||
y = title_area.y + title_area.h / 2 - FONT_CHARACTER_SIZE / 2;
|
||||
@ -1273,6 +1316,14 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
||||
SDLTest_DrawString(renderer, x, y, type);
|
||||
|
||||
if (display_mode == CONTROLLER_MODE_TESTING) {
|
||||
Uint64 steam_handle = SDL_GetGamepadSteamHandle(controller->gamepad);
|
||||
if (steam_handle) {
|
||||
SDL_snprintf(text, SDL_arraysize(text), "Steam: 0x%.16" SDL_PRIx64 "", steam_handle);
|
||||
y = (float)SCREEN_HEIGHT - 2 * (8.0f + FONT_LINE_HEIGHT);
|
||||
x = (float)SCREEN_WIDTH - 8.0f - (FONT_CHARACTER_SIZE * SDL_strlen(text));
|
||||
SDLTest_DrawString(renderer, x, y, text);
|
||||
}
|
||||
|
||||
SDL_snprintf(text, SDL_arraysize(text), "VID: 0x%.4x PID: 0x%.4x",
|
||||
SDL_GetJoystickVendor(controller->joystick),
|
||||
SDL_GetJoystickProduct(controller->joystick));
|
||||
@ -1290,6 +1341,30 @@ static void DrawGamepadInfo(SDL_Renderer *renderer)
|
||||
}
|
||||
}
|
||||
|
||||
static const char *GetButtonLabel(SDL_GamepadType type, SDL_GamepadButton button)
|
||||
{
|
||||
switch (SDL_GetGamepadButtonLabelForType(type, button)) {
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_A:
|
||||
return "A";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_B:
|
||||
return "B";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_X:
|
||||
return "X";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_Y:
|
||||
return "Y";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_CROSS:
|
||||
return "Cross (X)";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_CIRCLE:
|
||||
return "Circle";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_SQUARE:
|
||||
return "Square";
|
||||
case SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE:
|
||||
return "Triangle";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawBindingTips(SDL_Renderer *renderer)
|
||||
{
|
||||
const char *text;
|
||||
@ -1309,7 +1384,12 @@ static void DrawBindingTips(SDL_Renderer *renderer)
|
||||
} else {
|
||||
Uint8 r, g, b, a;
|
||||
SDL_FRect rect;
|
||||
SDL_bool bound_A, bound_B;
|
||||
SDL_GamepadButton action_forward = SDL_GAMEPAD_BUTTON_SOUTH;
|
||||
SDL_bool bound_forward = MappingHasElement(controller->mapping, action_forward);
|
||||
SDL_GamepadButton action_backward = SDL_GAMEPAD_BUTTON_EAST;
|
||||
SDL_bool bound_backward = MappingHasElement(controller->mapping, action_backward);
|
||||
SDL_GamepadButton action_delete = SDL_GAMEPAD_BUTTON_WEST;
|
||||
SDL_bool bound_delete = MappingHasElement(controller->mapping, action_delete);
|
||||
|
||||
y -= (FONT_CHARACTER_SIZE + BUTTON_MARGIN) / 2;
|
||||
|
||||
@ -1328,15 +1408,22 @@ static void DrawBindingTips(SDL_Renderer *renderer)
|
||||
|
||||
if (binding_element == SDL_GAMEPAD_ELEMENT_NAME) {
|
||||
text = "(press RETURN to complete)";
|
||||
} else if (binding_element == SDL_GAMEPAD_ELEMENT_TYPE) {
|
||||
} else if (binding_element == SDL_GAMEPAD_ELEMENT_TYPE ||
|
||||
binding_element == action_forward ||
|
||||
binding_element == action_backward) {
|
||||
text = "(press ESC to cancel)";
|
||||
} else {
|
||||
bound_A = MappingHasElement(controller->mapping, SDL_GAMEPAD_BUTTON_A);
|
||||
bound_B = MappingHasElement(controller->mapping, SDL_GAMEPAD_BUTTON_B);
|
||||
if (binding_flow && bound_A && bound_B) {
|
||||
text = "(press A to skip, B to go back, and ESC to cancel)";
|
||||
static char dynamic_text[128];
|
||||
SDL_GamepadType type = GetGamepadImageType(image);
|
||||
if (binding_flow && bound_forward && bound_backward) {
|
||||
if (binding_element != action_delete && bound_delete) {
|
||||
SDL_snprintf(dynamic_text, sizeof(dynamic_text), "(press %s to skip, %s to go back, %s to delete, and ESC to cancel)", GetButtonLabel(type, action_forward), GetButtonLabel(type, action_backward), GetButtonLabel(type, action_delete));
|
||||
} else {
|
||||
SDL_snprintf(dynamic_text, sizeof(dynamic_text), "(press %s to skip, %s to go back, SPACE to delete, and ESC to cancel)", GetButtonLabel(type, action_forward), GetButtonLabel(type, action_backward));
|
||||
}
|
||||
text = dynamic_text;
|
||||
} else {
|
||||
text = "(press SPACE to clear binding and ESC to cancel)";
|
||||
text = "(press SPACE to delete and ESC to cancel)";
|
||||
}
|
||||
}
|
||||
SDLTest_DrawString(renderer, (float)x - (FONT_CHARACTER_SIZE * SDL_strlen(text)) / 2, (float)y, text);
|
||||
@ -1521,6 +1608,10 @@ static void loop(void *arg)
|
||||
HandleGamepadRemapped(event.gdevice.which);
|
||||
break;
|
||||
|
||||
case SDL_EVENT_GAMEPAD_STEAM_HANDLE_UPDATED:
|
||||
RefreshControllerName();
|
||||
break;
|
||||
|
||||
#ifdef VERBOSE_TOUCHPAD
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION:
|
||||
@ -1801,6 +1892,7 @@ static void loop(void *arg)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
SDL_bool show_mappings = SDL_FALSE;
|
||||
int i;
|
||||
float content_scale;
|
||||
int screen_width, screen_height;
|
||||
@ -1810,7 +1902,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1832,16 +1924,7 @@ int main(int argc, char *argv[])
|
||||
consumed = SDLTest_CommonArg(state, i);
|
||||
if (!consumed) {
|
||||
if (SDL_strcmp(argv[i], "--mappings") == 0) {
|
||||
int map_i;
|
||||
SDL_Log("Supported mappings:\n");
|
||||
for (map_i = 0; map_i < SDL_GetNumGamepadMappings(); ++map_i) {
|
||||
char *mapping = SDL_GetGamepadMappingForIndex(map_i);
|
||||
if (mapping) {
|
||||
SDL_Log("\t%s\n", mapping);
|
||||
SDL_free(mapping);
|
||||
}
|
||||
}
|
||||
SDL_Log("\n");
|
||||
show_mappings = SDL_TRUE;
|
||||
consumed = 1;
|
||||
} else if (SDL_strcmp(argv[i], "--virtual") == 0) {
|
||||
OpenVirtualGamepad();
|
||||
@ -1874,6 +1957,18 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_AddGamepadMappingsFromFile("gamecontrollerdb.txt");
|
||||
|
||||
if (show_mappings) {
|
||||
int count = 0;
|
||||
char **mappings = SDL_GetGamepadMappings(&count);
|
||||
int map_i;
|
||||
SDL_Log("Supported mappings:\n");
|
||||
for (map_i = 0; map_i < count; ++map_i) {
|
||||
SDL_Log("\t%s\n", mappings[map_i]);
|
||||
}
|
||||
SDL_Log("\n");
|
||||
SDL_free(mappings);
|
||||
}
|
||||
|
||||
/* Create a window to display gamepad state */
|
||||
content_scale = SDL_GetDisplayContentScale(SDL_GetPrimaryDisplay());
|
||||
if (content_scale == 0.0f) {
|
||||
@ -1882,13 +1977,13 @@ int main(int argc, char *argv[])
|
||||
screen_width = (int)SDL_ceilf(SCREEN_WIDTH * content_scale);
|
||||
screen_height = (int)SDL_ceilf(SCREEN_HEIGHT * content_scale);
|
||||
window = SDL_CreateWindow("SDL Controller Test", 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, NULL, 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;
|
||||
@ -1915,7 +2010,7 @@ int main(int argc, char *argv[])
|
||||
type_area.y = (float)TITLE_HEIGHT / 2 - type_area.h / 2;
|
||||
|
||||
image = CreateGamepadImage(screen);
|
||||
if (image == NULL) {
|
||||
if (!image) {
|
||||
SDL_DestroyRenderer(screen);
|
||||
SDL_DestroyWindow(window);
|
||||
return 2;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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,6 +65,50 @@ static const char *arrow[] = {
|
||||
"0,0"
|
||||
};
|
||||
|
||||
static const char *cross[] = {
|
||||
/* width height num_colors chars_per_pixel */
|
||||
" 32 32 3 1",
|
||||
/* colors */
|
||||
"o c #000000",
|
||||
". c #ffffff",
|
||||
" c None",
|
||||
/* pixels */
|
||||
/* pixels */
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oooooooooooooooooooooooo ",
|
||||
" oooooooooooooooooooooooo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" oo ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
"0,0"
|
||||
};
|
||||
|
||||
static SDL_Cursor *
|
||||
init_color_cursor(const char *file)
|
||||
{
|
||||
@ -72,7 +116,12 @@ init_color_cursor(const char *file)
|
||||
SDL_Surface *surface = SDL_LoadBMP(file);
|
||||
if (surface) {
|
||||
if (surface->format->palette) {
|
||||
SDL_SetSurfaceColorKey(surface, 1, *(Uint8 *)surface->pixels);
|
||||
const Uint8 bpp = surface->format->BitsPerPixel;
|
||||
const Uint8 mask = (1 << bpp) - 1;
|
||||
if (SDL_PIXELORDER(surface->format->format) == SDL_BITMAPORDER_4321)
|
||||
SDL_SetSurfaceColorKey(surface, 1, (*(Uint8 *)surface->pixels) & mask);
|
||||
else
|
||||
SDL_SetSurfaceColorKey(surface, 1, ((*(Uint8 *)surface->pixels) >> (8 - bpp)) & mask);
|
||||
} else {
|
||||
switch (surface->format->BitsPerPixel) {
|
||||
case 15:
|
||||
@ -122,6 +171,9 @@ init_system_cursor(const char *image[])
|
||||
case '.':
|
||||
mask[i] |= 0x01;
|
||||
break;
|
||||
case 'o':
|
||||
data[i] |= 0x01;
|
||||
break;
|
||||
case ' ':
|
||||
break;
|
||||
}
|
||||
@ -133,8 +185,8 @@ init_system_cursor(const char *image[])
|
||||
|
||||
static SDLTest_CommonState *state;
|
||||
static int done;
|
||||
static SDL_Cursor *cursors[1 + SDL_NUM_SYSTEM_CURSORS];
|
||||
static SDL_SystemCursor cursor_types[1 + SDL_NUM_SYSTEM_CURSORS];
|
||||
static SDL_Cursor *cursors[3 + SDL_NUM_SYSTEM_CURSORS];
|
||||
static SDL_SystemCursor cursor_types[3 + SDL_NUM_SYSTEM_CURSORS];
|
||||
static int num_cursors;
|
||||
static int current_cursor;
|
||||
static SDL_bool show_cursor;
|
||||
@ -210,6 +262,30 @@ static void loop(void)
|
||||
case SDL_SYSTEM_CURSOR_HAND:
|
||||
SDL_Log("Hand");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOPLEFT:
|
||||
SDL_Log("Window resize top-left");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOP:
|
||||
SDL_Log("Window resize top");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_TOPRIGHT:
|
||||
SDL_Log("Window resize top-right");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_RIGHT:
|
||||
SDL_Log("Window resize right");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMRIGHT:
|
||||
SDL_Log("Window resize bottom-right");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOM:
|
||||
SDL_Log("Window resize bottom");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_BOTTOMLEFT:
|
||||
SDL_Log("Window resize bottom-left");
|
||||
break;
|
||||
case SDL_SYSTEM_CURSOR_WINDOW_LEFT:
|
||||
SDL_Log("Window resize left");
|
||||
break;
|
||||
default:
|
||||
SDL_Log("UNKNOWN CURSOR TYPE, FIX THIS PROGRAM.");
|
||||
break;
|
||||
@ -228,7 +304,29 @@ static void loop(void)
|
||||
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
SDL_Renderer *renderer = state->renderers[i];
|
||||
SDL_RenderClear(renderer);
|
||||
SDL_FRect rect;
|
||||
int x, y, row;
|
||||
int window_w = 0, window_h = 0;
|
||||
|
||||
SDL_GetWindowSize(state->windows[i], &window_w, &window_h);
|
||||
rect.w = 128.0f;
|
||||
rect.h = 128.0f;
|
||||
for (y = 0, row = 0; y < window_h; y += (int)rect.h, ++row) {
|
||||
SDL_bool black = ((row % 2) == 0) ? SDL_TRUE : SDL_FALSE;
|
||||
for (x = 0; x < window_w; x += (int)rect.w) {
|
||||
rect.x = (float)x;
|
||||
rect.y = (float)y;
|
||||
|
||||
if (black) {
|
||||
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF);
|
||||
} else {
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
|
||||
}
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
|
||||
black = !black;
|
||||
}
|
||||
}
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
#ifdef __EMSCRIPTEN__
|
||||
@ -242,13 +340,14 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
const char *color_cursor = NULL;
|
||||
SDL_Cursor *cursor;
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
for (i = 1; i < argc;) {
|
||||
@ -270,23 +369,10 @@ int main(int argc, char *argv[])
|
||||
quit(2);
|
||||
}
|
||||
|
||||
for (i = 0; i < state->num_windows; ++i) {
|
||||
SDL_Renderer *renderer = state->renderers[i];
|
||||
SDL_SetRenderDrawColor(renderer, 0xA0, 0xA0, 0xA0, 0xFF);
|
||||
SDL_RenderClear(renderer);
|
||||
}
|
||||
|
||||
num_cursors = 0;
|
||||
|
||||
if (color_cursor) {
|
||||
SDL_Cursor *cursor = init_color_cursor(color_cursor);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
num_cursors++;
|
||||
}
|
||||
} else {
|
||||
SDL_Cursor *cursor = init_system_cursor(arrow);
|
||||
cursor = init_color_cursor(color_cursor);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
@ -294,8 +380,22 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
cursor = init_system_cursor(arrow);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
num_cursors++;
|
||||
}
|
||||
|
||||
cursor = init_system_cursor(cross);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = (SDL_SystemCursor)-1;
|
||||
num_cursors++;
|
||||
}
|
||||
|
||||
for (i = 0; i < SDL_NUM_SYSTEM_CURSORS; ++i) {
|
||||
SDL_Cursor *cursor = SDL_CreateSystemCursor((SDL_SystemCursor)i);
|
||||
cursor = SDL_CreateSystemCursor((SDL_SystemCursor)i);
|
||||
if (cursor) {
|
||||
cursors[num_cursors] = cursor;
|
||||
cursor_types[num_cursors] = i;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@
|
||||
static void
|
||||
print_mode(const char *prefix, const SDL_DisplayMode *mode)
|
||||
{
|
||||
if (mode == NULL) {
|
||||
if (!mode) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -229,7 +229,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;) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -57,6 +57,7 @@ static void DrawChessBoard(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
SDL_RenderPresent(renderer);
|
||||
}
|
||||
|
||||
static void loop(void)
|
||||
@ -106,7 +107,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -126,13 +127,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Create window and renderer for given surface */
|
||||
window = SDL_CreateWindow("Chess Board", 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;
|
||||
}
|
||||
@ -151,6 +152,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
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 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -56,9 +56,6 @@ int main(int argc, char *argv[])
|
||||
goto quit;
|
||||
}
|
||||
|
||||
|
||||
SDL_SetEventEnabled(SDL_EVENT_DROP_FILE, SDL_TRUE);
|
||||
|
||||
/* Main render loop */
|
||||
done = 0;
|
||||
while (!done) {
|
||||
@ -71,16 +68,13 @@ int main(int argc, char *argv[])
|
||||
SDL_Log("Drop complete on window %u at (%f, %f)", (unsigned int)event.drop.windowID, event.drop.x, event.drop.y);
|
||||
} else if ((event.type == SDL_EVENT_DROP_FILE) || (event.type == SDL_EVENT_DROP_TEXT)) {
|
||||
const char *typestr = (event.type == SDL_EVENT_DROP_FILE) ? "File" : "Text";
|
||||
char *dropped_filedir = event.drop.file;
|
||||
SDL_Log("%s dropped on window %u: %s at (%f, %f)", typestr, (unsigned int)event.drop.windowID, dropped_filedir, event.drop.x, event.drop.y);
|
||||
/* Normally you'd have to do this, but this is freed in SDLTest_CommonEvent() */
|
||||
/*SDL_free(dropped_filedir);*/
|
||||
SDL_Log("%s dropped on window %u: %s at (%f, %f)", typestr, (unsigned int)event.drop.windowID, event.drop.data, event.drop.x, event.drop.y);
|
||||
} else if (event.type == SDL_EVENT_DROP_POSITION) {
|
||||
is_hover = SDL_TRUE;
|
||||
x = event.drop.x;
|
||||
y = event.drop.y;
|
||||
windowID = event.drop.windowID;
|
||||
SDL_Log("Drop position on window %u at (%f, %f) file = %s", (unsigned int)event.drop.windowID, event.drop.x, event.drop.y, event.drop.file);
|
||||
SDL_Log("Drop position on window %u at (%f, %f) data = %s", (unsigned int)event.drop.windowID, event.drop.x, event.drop.y, event.drop.data);
|
||||
}
|
||||
|
||||
SDLTest_CommonEvent(state, &event, &done);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -52,7 +52,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -81,7 +81,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);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 2020-2022 Collabora Ltd.
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
@ -1940,7 +1940,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
if (state == NULL) {
|
||||
if (!state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|