Commit graph

11215 commits

Author SHA1 Message Date
Sam Lantinga
5365d120f5 Track android device panel width & height as well as window surface & height.
Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails.

Add Android_DeviceWidth/Android_DeviceHeight globals to native code.
Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight
Use device width/height for all display mode settings.
2018-06-07 17:07:03 -07:00
Sam Lantinga
b524fbfa1a Added support for the PS3 controller driver in PlayStation Now 2018-06-07 10:54:54 -07:00
Sam Lantinga
5c2e9ad377 Added Android hardware feature support to the default manifest 2018-06-06 09:42:12 -07:00
Sam Lantinga
cc3eb28d4d Added improved mouse pointer capture under API 26. (Thanks Rachel!) 2018-06-05 14:08:39 -07:00
Sam Lantinga
c05c926eca Added SDL_IsChromebook() to determine if we're running on a Chromebook. 2018-06-05 12:46:13 -07:00
Sam Lantinga
971e77801b Add Android support for relative mouse mode to SDL. 2018-06-05 12:46:11 -07:00
Sam Lantinga
3fce290676 Fix creating a minimized window in SDL to not cause focus to be stolen (because ShowWindow( hwnd, SW_MINIMIZE ) would be called after creation, thus changing focus to the prior window based on some per-app list in windows, rather than the window being created with WS_MINIMIZED to start with).
This means we have to consider SDL_WINDOW_MINIMIZED a window creation flag, but on non-windows platforms we just remove it and let the normal FinishWindowCreation re-apply and do the minimize as I have no idea what is right on them or if anything should change.

CR: Phil
2018-06-05 12:46:09 -07:00
Sam Lantinga
a63126c72b Fixed bug 4184 - jack audio driver fails in presence of midi ports
Martin Širokov

Launching an SDL application with SDL_AUDIODRIVER=jack, and then calling SDL_OpenAudioDevice() with whatever parameters fails with an error like this one:

SDL_OpenAudioDevice: Couldn't connect JACK ports: SDL:sdl_jack_output_0 => system:midi_playback_1

This happens because JACK_OpenDevice in src/audio/jack/SDL_jackaudio.c blindly tries to connect to all input ports without checking whether they are for audio or midi.

The fix is to check port types and ignore all non audio ports. Also I removed devports field from struct SDL_PrivateAudioData, because it's never really used and removing unused ports from it would be PITA.
2018-06-01 19:43:53 -07:00
Sam Lantinga
7aab344396 Added support for Android relative mouse mode on API 24 and above 2018-05-29 11:18:01 -07:00
Sam Lantinga
1d6c7e96f0 Added a new GUID for DS3 controller connected over bluetooth, for both Sony and Shanwan (thanks William!) 2018-05-29 08:03:44 -07:00
Ryan C. Gordon
bdea7c958e metal: contrary to documentation, we need to set the drawableSize explicitly.
Fixes Bugzilla #4149.
2018-05-27 20:30:03 -04:00
Sam Lantinga
71f7ab88d3 Fixed bug 4169 - Crash due to audio session observer race condition
Jona

The following explains why this bug was happening:
This crash was caused because the audio session was being set as active [session setActive:YES error:&err] when the audio device was actually being CLOSED. Certain cases the audio session being set to active would fail and the method would return right away. Because of the way the error was handled we never removed the SDLInterruptionListener thus leaking it. Later when an interruption was received the THIS_ object would contain a pointer to an already released device causing the crash.

The fix:
When only one device remained open and it was being closed we needed to set the audio session as NOT active and completely ignore the returned error to successfully release the SDLInterruptionListener. I think the user assumed that the open_playback_devices and open_capture_devices would equal 0 when all of them where closed but the truth is that at the end of the closing process that the open devices count is decremented.
2018-05-24 07:30:24 -07:00
Sam Lantinga
a860abd036 Added support for the NVIDIA SHIELD handheld gaming device 2018-05-23 17:15:37 -07:00
Sam Lantinga
fd550c4788 Better fix for axis sorting with some Android controllers 2018-05-23 17:15:35 -07:00
Sam Lantinga
59d9b642c4 Actually left trigger is motion axis 17 and right trigger is motion axis 18, which will map in that order to SDL axes. 2018-05-23 17:15:33 -07:00
Sam Lantinga
1a11875150 Added additional supported Android controllers 2018-05-23 16:00:21 -07:00
Sam Lantinga
31619e7cd8 Fixed default mapping for Android controller triggers (they were reversed) 2018-05-23 16:00:19 -07:00
Ryan C. Gordon
3e6756a409 audio: Needed to fix two more instances for Visual Studio. 2018-05-21 12:05:17 -04:00
Ryan C. Gordon
09c7ceab2e thread: fixed compiler warnings on non-Linux systems that use pthread.
(static function rtkit_setpriority was unused, moved it in with rest of
__LINUX__ section.)
2018-05-21 12:00:21 -04:00
Ryan C. Gordon
8486bf2127 audio: Patched to compile on Visual Studio.
(It gets upset at the -2147483648, thinking this should be an unsigned value
because 2147483648 is too large for an int32, so the negative sign upsets the
compiler.)
2018-05-21 11:54:09 -04:00
Ryan C. Gordon
72aa5ee14c audio: Added ARM NEON versions of audio converters.
These are _much_ faster than the scalar equivalents on the Raspberry Pi that
I tested on. Often 3x to 4x as fast!

--HG--
extra : rebase_source : a9f90ef5bfdd309d6a3c8e9220ee235d7413cb5d
extra : histedit_source : 61c5ad731eed96f7bb46da40261ed8b14d474624
2018-05-16 02:03:06 -04:00
Ryan C. Gordon
8f939498c0 audio: SSE2 float-to-int converters should clamp input.
The scalar versions already do this.

--HG--
extra : rebase_source : c42a9f21fe39cbc86bcf00a3a2aab6045e93653c
extra : histedit_source : 010f977ddd95317719656840aab11bfbe4c3ba48
2018-05-15 02:29:35 -04:00
Ryan C. Gordon
4fdc866cb9 audio: Fix range on float-to-int data clamping.
I can't tell if there was a good reason for this or it was just me getting
numbers wrong due to exhaustion.

--HG--
extra : rebase_source : 89c4fdec316ae565b004f36050084ba54ad0f8e9
extra : histedit_source : 4951e6c9e873249b9f0baaffd3c9b4b2506308c4
2018-05-15 01:40:05 -04:00
Ryan C. Gordon
799afaf11c audio: float to int converters should clamp inclusively.
If we have to test if a sample is > 1.0f anyhow, we might as well use this
to avoid the unnecessary multiplication when it's == 1.0f, too. (etc).

--HG--
extra : rebase_source : efee952e0b5cd3f96c68b80158bcee6f9c66b241
extra : histedit_source : d60200ad2713377a0f8a322e5a0ce59a003fe575
2018-05-15 01:35:53 -04:00
Ryan C. Gordon
3ca98abf96 testresample: correctly output .wav files that have floating point audio.
--HG--
extra : rebase_source : 12727c9fbaead1d9e954b34dbdae5babef3f4dce
extra : histedit_source : bdee71b1310f6a427e0e03ad7c06856ad3c6299f
2018-05-15 00:04:02 -04:00
Ryan C. Gordon
d4581bb6a7 audio: converting int32 to/from float shouldn't use doubles.
The concern is that a massive int sample, like 0x7FFFFFFF, won't fit in a
float32, which doesn't have enough bits to hold a whole number this large,
just to divide it to get a value between 0 and 1.
Previously we would convert to double, to get more bits, do the division, and
cast back to a float, but this is expensive.

Casting to double is more accurate, but it's 2x to 3x slower. Shifting out
the least significant byte of an int32, so it'll definitely fit in a float,
and dividing by 0x7FFFFF is still accurate to about 5 decimal places, and the
difference doesn't appear to be perceptable.

--HG--
extra : rebase_source : 5be8fca9a33034555682eb22945744cc34cabf71
extra : histedit_source : 2b3c771dcb080326e24fdac1c8f19e5b44ef21b3
2018-05-15 01:04:11 -04:00
Ryan C. Gordon
b7560b9599 cpuinfo: Added SDL_HasAVX512F().
This checks for the "foundation" AVX-512 instructions (that all AVX-512
compatible CPUs support).

--HG--
extra : rebase_source : 2857dd04072e2f897e18665d0a4fe2837c06ed9b
extra : histedit_source : 67d0b925bceb2ed2a8f37b5783f2b755e796031f
2018-05-21 11:35:42 -04:00
Ryan C. Gordon
507f22ca69 cpuinfo: Make CPU flags easier to read and add to.
--HG--
extra : rebase_source : 4d81b3af23cee1138820a0c3f9883ec45ac711ce
extra : histedit_source : d5432ab16b6e3202735f19ecae3b959d8f3beb3f
2018-05-14 00:03:39 -04:00
Ryan C. Gordon
fbfce09170 cpuinfo: Added some internal SIMD-aligned allocation functions.
Fixes Bugzilla #4150 (sort of).

--HG--
extra : rebase_source : af4df4fe459ce28889fb225717c418e6c1ef9ae4
extra : histedit_source : aafd7e609c08ea908255e205d23e3efdc88837a1
2018-05-21 11:34:57 -04:00
Sam Lantinga
bebfd14c33 Merged latest changes from Steam Link app 2018-05-18 13:09:30 -07:00
Ryan C. Gordon
ae037005ee dynapi: don't let system loader resolve the initializer to the wrong version.
Fixes problems launching Firewatch on Linux (which statically links SDL but
also dynamically loads a system-wide copy from a plugin shared library) with
a newer SDL build.
2018-05-17 12:50:46 -04:00
Ozkan Sezer
ae0e4230a9 remove testvulkan.vcproj (was a VS2008 left-over.) 2018-05-11 09:37:00 +03:00
Ozkan Sezer
6f33890b09 make sure SDL_vsnprintf() nul terminates if it is using _vsnprintf
The change makes sure that SDL_vsnprintf() nul terminates if it is
using _vsnprintf() for the job.

I made this patch for Watcom, whose _vsnprintf() doesn't guarantee
nul termination.  The preprocessor check can be extended to windows
in general too, if required.

Closes bug #3769.
2018-05-10 09:02:39 +03:00
Ozkan Sezer
7a1c60fed4 SDL_stdinc.h: move the alloca() includes before begin_code.h 2018-05-10 08:28:00 +03:00
Ozkan Sezer
b34726884e do the direct3d tap dance for overscan hint only if SDL_VIDEO_RENDER_D3D == 1 2018-05-10 08:25:23 +03:00
Sam Lantinga
3f5220d8e8 Reverted change for bug 4152 - restrict the win10 mouse bug workaround to win10 v1709 only
Daniel Gibson

Sorry, but it seems like Microsoft didn't fix the issue properly.

I just updated my Win10 machine, it now is Version 1803, Build 17134.1

I tested with SDL2 2.0.7 (my workaround was released with 2.0.8) and still got
lots of events that directly undid the prior "real" events - just like before.
(See simple testcase in attachement)
By default it sets SDL_HINT_MOUSE_RELATIVE_MODE_WARP - which triggered (and on my machine still triggers) the buggy behavior. You can start it with -raw, then it'll not set that hint and the events will be as expected.
The easiest way to see the difference is looking at the window title, which shows accumulated X and Y values: If you just move your mouse to the right, in -raw mode the number just increases. In non-raw mode (using mouse warping) it stays around 0.

I also had a WinAPI-only testcase: https://gist.github.com/DanielGibson/b5b033c67b9137f0280af9fc53352c68
It just calls SetCursorPos(320,240); on each WM_MOUSEMOVE event, and it also
logs all those events to a mouseevents.log textfile.
This log indeed looks a bit different since the latest Win10 update: It seems like all those events with x=320 y=240 do arrive - but only after I stopped moving the mouse - even though the cursor seems to be moved back every frame (or so).
So moving the mouse to the right gives X coordinates like
330, 325, 333, 340, 330, ...
and then when stopping movement I get lots of events with X coordinate 320
2018-05-07 20:10:12 -07:00
Sam Lantinga
40f5b81553 Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window
Olli-Samuli Lehmus

If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
2018-05-07 19:52:25 -07:00
Sam Lantinga
31a9517639 Fixed bug 4159 - Windows headers are included after packing alignment change
lectem

The SDL_syswm.h header includes the windows.h header after including begin_code.h which changes the structure packing alignment.

It seems this is not safe as suggested by the following warning :
warning C4121: 'JOBOBJECT_IO_RATE_CONTROL_INFORMATION_NATIVE_V2': alignment of a member was sensitive to packing
2018-05-07 19:26:02 -07:00
Sam Lantinga
1a687f83fb Fixed bug 4154 - Fix three empty variable tests in configure
Zack Middleton

Running top-level SDL configure on macOS 10.11 resulted in the errors below because automake removed the brackets about the tests.

./configure: line 15756: : command not found
./configure: line 15759: -Iinclude -I/Users/zack/SDL/include -idirafter /Users/zack/SDL/src/video/khronos : No such file or directory
./configure: line 15763: : command not found
2018-05-05 10:31:03 -07:00
Sam Lantinga
39c7887375 Fixed bug 4152 - Windows 10 v1803 update seems to have fixed the jumping mouse bug (see bug #3931.) 2018-05-05 10:27:53 -07:00
Sam Lantinga
93215c489a Improved error messages when Vulkan isn't configured (thanks Daniel Gibson!) 2018-04-23 22:29:14 -07:00
Sam Lantinga
415ed707e7 Fixed build 2018-04-23 22:17:56 -07:00
Sam Lantinga
50baccfbfb Added SDL_THREAD_PRIORITY_TIME_CRITICAL 2018-04-23 22:07:56 -07:00
Sam Lantinga
a6f6cae8eb Fixed bug 4144 - CMake complains about trailing spaces in sdl2.pc
Azamat H. Hackimov

When you try use SDL2 2.0.8 in CMake project in Linux, it complains about trailing spaces in sdl2.pc:

CMake Error at CMakeLists.txt:147 (add_executable):
  Target "TestSimpleMain" links to item "-L/usr/lib64 -lSDL2 " which has
  leading or trailing whitespace.  This is now an error according to policy
  CMP0004.
2018-04-23 21:55:59 -07:00
Sam Lantinga
289db15943 TryLockMutex: Fix error handling for TryLockMutex
Christian Herzig

pthread_mutex_trylock() and by the way, pthread_mutex_lock() do not set errno.
Pthread-methods directly return error code as int. See related man-pages for
details.
2018-04-23 21:50:03 -07:00
Sam Lantinga
82f42026e7 Handle NULL return from SDL_DBus_GetContext() 2018-04-23 20:24:12 -07:00
Sam Lantinga
fbfcea8362 Handle NULL return from SDL_DBus_GetContext() 2018-04-23 19:20:12 -07:00
Sam Lantinga
9a335154f2 Added SDL_LinuxSetThreadPriority() to directly set the priority of a Linux thread (tid)
This function tries using RealtimeKit connecting over DBUS as needed.
2018-04-23 19:18:52 -07:00
Sam Lantinga
467b928af2 Added support for adjusting thread priorities using Linux RealtimeKit
Michael Sartain

This is a quick pass at adding Linux RealtimeKit thread priority support to SDL.

It allows me to bump the thread priority to high without root privileges or setting any caps, etc.

rtkit readme here:
    http://git.0pointer.net/rtkit.git/tree/README
2018-04-23 17:10:36 -07:00
Ryan C. Gordon
426d67ec76 coreaudio: Use the standard SDL audio thread instead of spinning a new one.
Fixes corner cases, like the audio callback not firing if the device is
disconnected, etc.
2018-04-16 02:11:09 -04:00