Commit Graph

2404 Commits

Author SHA1 Message Date
Sam Lantinga
7df0f4fdac Fixed bug 4277 - warnings patch
Sylvain

Patch a few warnings when using:
-Wmissing-prototypes -Wdocumentation -Wdocumentation-unknown-command

They are automatically enabled with -Wall
2018-09-27 14:56:29 -07:00
Ozkan Sezer
d9fb77a3c1 SDL_atomic.c, SDL_spinlock.c: use lock prefix with xchg in Watcom asm. 2018-09-27 11:55:02 +03:00
Ozkan Sezer
bb5516ac8e SDL_vsnprintf() updates for zero-padding:
- remove force-enabling of pad_zeroes for %u for compatibility
 (was added in https://hg.libsdl.org/SDL/rev/701f4a25df89)
- ignore pad_zeroes for %s and %S
- ignore pad_zeroes for %d, %i and %u if a precision is given
2018-09-27 09:37:36 +03:00
Ryan C. Gordon
7689162ca0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
2018-09-26 20:10:32 -04:00
Ozkan Sezer
6eeb8593ba SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning 2018-09-27 01:10:50 +03:00
Ozkan Sezer
5342ae2bba SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset() 2018-09-27 01:00:50 +03:00
Ozkan Sezer
d2131ac165 SDL_vsnprintf: implement precision for the integral value printers. 2018-09-27 00:32:15 +03:00
Sam Lantinga
55b24b93b4 Fixed bug 4265 - SDL window falls to the bottom of the screen when dragged down and stuck there
Alexei

On WM_WINDOWPOSCHANGED event, WIN_UpdateClipCursor() is called. SDL_WINDOW_INPUT_FOCUS is set even when the mouse pointer is not inside the SDL window and therefore ClipCursor(&rect) is called. When dragging the window and rect.bottom=800 (i.e. the bottom edge of the screen) the SDL window is clipped to the bottom of the screen and it is not possible to move it back to the center of the screen.
2018-09-26 11:17:43 -07:00
Ozkan Sezer
ffc19ee255 SDL_string.c: added comments to three SDL_FormatInfo members. 2018-09-26 20:47:34 +03:00
Sam Lantinga
bc6c199790 Updated version to 2.0.9 2018-09-26 10:08:14 -07:00
Ozkan Sezer
8743e9759e SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0. 2018-09-26 17:11:40 +03:00
Ozkan Sezer
69ab8541a9 SDL_vsnprintf: string printer now honors the precision. (bug #4263.) 2018-09-26 10:40:02 +03:00
Ozkan Sezer
d0e9a36460 SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.) 2018-09-26 10:38:40 +03:00
Sam Lantinga
e236e8435a Fixed bug 4268 - Android_JNI_OpenAudioDevice function has error
alittle

where iscapture == 1

1.param set error

(*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureOpen, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames)

param:audioBuffer16Bit need change to captureBuffer16Bit

2.logic error

if (is16Bit) {
        // ALITTLE Modify the source code
        if (iscapture) {
            audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)captureBuffer);
        } else {
            audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
            audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
        }
        // if (!iscapture) {
        //     audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
        // }
        // audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
    } else {
        // ALITTLE Modify the source code
        if (iscapture) {
            audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer);
        } else {
            audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy);
            audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer);
        }
        // if (!iscapture) {
        //     audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy);
        // }
        // audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer);
    }
2018-09-25 20:08:51 -07:00
Sam Lantinga
60afec79bf Removed redundant SDL_GetColorKey() call. (thanks Sylvain!) 2018-09-25 19:53:16 -07:00
Ethan Lee
7f9854b9b2 WinRT: Wait until audio device activation is complete and PrepDevice during OpenAudio 2018-09-25 01:45:12 -04:00
Sam Lantinga
aa9683bb6f Added 8bitdo SF 30 PRO controller support for Linux / DInput mode (thanks Frank Hartung) 2018-09-25 19:41:33 -07:00
Sam Lantinga
fb0e68ae0f Fixed building with newer Android NDK 2018-09-25 08:23:57 -07:00
Ozkan Sezer
870c44bfed safer this way, just in case.. 2018-09-25 09:20:56 +03:00
Sam Lantinga
ef34704875 Fixed bug 4264 - SDL_CreateTextureFromSurface generates error message but returns ok
Anthony @ POW Games

SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
2018-09-24 16:41:55 -07:00
Sam Lantinga
cd90e2ca58 Fixed bug 4267 - linkage failure with --enable-hidapi because of missing libudev symbols
Ozkan Sezer

hidapi dynamic udev initial patch
2018-09-24 16:33:14 -07:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
d07fe7ad95 Removed button logging message 2018-09-21 09:41:21 -07:00
Sam Lantinga
e8b0859f17 Added missing call to WindowsDeleteString() 2018-09-20 15:55:52 -07:00
Sam Lantinga
600126c90e Added experimental support for Windows.Gaming.Input 2018-09-19 10:03:40 -07:00
Sam Lantinga
f6a537cbfa Store the API device refcount on the device itself, so if the device is disconnected and we have multiple application references to it, we only free it once. 2018-09-17 11:35:24 -07:00
Sam Lantinga
59a2d12cc3 Fixed creating an Android game controller mapping for HIDAPI devices on initialization 2018-09-17 11:35:22 -07:00
Ozkan Sezer
305e5968aa do not export hidapi symbols from SDL dlls (bug #4259). 2018-09-15 14:28:10 +03:00
Sam Lantinga
6b3e893105 Added hints SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS to allow tuning double-click sensitivity.
Also increased the default double-click radius to 32 pixels to be more forgiving for touch interfaces
2018-09-14 19:26:26 -07:00
Sam Lantinga
e8a0e35e24 Use atomic reference counting for the HID device object 2018-09-14 18:31:01 -07:00
Sam Lantinga
6a7b0c27af Fixed crash launching under Steam on Mac OS X 2018-09-14 12:41:29 -07:00
Sam Lantinga
0b3a350c90 Fixed Chinese IME support (thanks ???!) 2018-09-10 23:01:33 -07:00
Sam Lantinga
af823cc1d9 Fixed building on tvOS 2018-09-10 23:00:09 -07:00
Ozkan Sezer
33381d3d10 hidapi/SDL_hidapijoystick.c: fix build in C90 mode:
src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_InitializeDiscovery':
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: 'true' undeclared (first use in this function)
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: (Each undeclared identifier is reported only once
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: for each function it appears in.)
src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_UpdateDiscovery':
src/joystick/hidapi/SDL_hidapijoystick.c:339: error: 'true' undeclared (first use in this function)
src/joystick/hidapi/SDL_hidapijoystick.c:341: error: ISO C90 forbids mixed declarations and code
2018-09-07 11:03:24 +03:00
Anthony Pesch
c591429542 alsa: avoid hardware parameters with an excessive number of periods.
The previous code attempted to use set_buffer_size / set_period_size
discretely, favoring the parameters which generated a buffer size that was
exactly 2x the requested buffer size. This solution ultimately prioritizes
only the buffer size, which comes at a large performance cost on some machines
where this results in an excessive number of periods. In my case, for a 4096
sample buffer, this configured the device to use 37 periods with a period size
of 221 samples and a buffer size of 8192 samples. With 37 periods, the SDL
Audio thread was consuming 25% of the CPU.

This code has been refactored to use set_period_size and set_buffer_size
together. set_period_size is called first to attempt to set the period to
exactly match the requested buffer size, and set_buffer_size is called second
to further refine the parameters to attempt to use only 2 periods. The
fundamental change here is that the period size / count won't go to extreme
values if the buffer size can't be exactly matched, the buffer size should
instead just increase to the next closest multiple of the target period size
that is supported. After changing this, for a 4096 sample buffer, the device
is configured to use 3 periods with a period size of 4096 samples and a buffer
size of 12288 samples. With only 3 periods, the SDL Audio thread doesn't even
show up when profiling.

Fixes Bugzilla #4156.
2018-05-04 21:21:32 -04:00
Ryan C. Gordon
59574fe2f0 x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).
"Applications (such as SDL's testgesture) do "event.tfinger.x * window_width"
to find window coord. Currently the X11 XInput2 backend expects application
to do "event.tfinger.x * (window_width-1)" instead.

X11 XInput2 touch events are normalized so x is 1.0 at "width - 1" but other
SDL backends appear to have x be 1.0 at "width". Same issue for touch event
y with regards to height."

Fixes Bugzilla #4183.
2018-06-24 13:57:22 -04:00
Tomeu Vizoso
fe6828272a egl: Don't change context when deleting current.
If we change the current context behind the app's back, those tracking
the current context to minimize context changes are going to get
confused.

This brings the EGL backend in line with the GLX one.

Fixes Bugzilla #4199.
2018-06-14 06:12:12 +00:00
Ryan C. Gordon
5308a245a4 Fixed some possible malloc(0) calls reported by static analysis. 2018-06-24 12:16:58 -04:00
Sam Lantinga
88dfa46644 Use a blank cursor instead of PointerIcon.TYPE_NULL since that shows the default cursor on Samsung DeX 2018-06-18 13:14:04 -07:00
Sam Lantinga
a515853569 Added support for external mouse in Samsung DeX mode
relative mode doesn't work, but absolute coordinates are functional
2018-06-18 13:14:02 -07:00
Sam Lantinga
74ec7cabdb Fixed race condition where Android touch events could get scaled by a render target's viewport 2018-06-18 13:13:56 -07:00
Sam Lantinga
9924a8e392 Fixed bug 4094 - No SDL_TEXTEDITING after pressing Alt key on Raspberry Pi Linux
This was reproducible by running an SDL app on the console from an ssh login. In this case the terminal wasn't owned by the user running the app, so we were using the default keymap, which didn't have state transitions defined for ctrl and alt, so once we entered that state keypresses would no longer transition out of that state, nor would they generate text.

As a workaround, we'll just reset to the default shift state if that happens, which means we'll get text for keys pressed while ctrl is held down, but I don't think that's a big problem.

Note that in this case we also can't mute the keyboard, so the keypresses go to the console, which probably isn't what you want...
2018-06-14 00:51:45 -07:00
Ozkan Sezer
08de74ec49 use the 'aborts' pragma of Watcom for SDL_NORETURN functions
SDL_ExitProcess(), SDL_AbortAssertion() and SDLTest_BailOut().

(Commit 303c1e0fb0cf for bug #4100 removed SDL_NORETURN from
SDL_ExitProcess() and SDL_AbortAssertion() in order to avoid
warnings from windows builds, but that's temporary I guess..)
2018-06-13 14:45:02 +03:00
Sam Lantinga
4a4bac95eb Deal with fullscreen limitations under windowed Android environments (Chromebook, DeX, etc.) (Thanks Rachel!) 2018-06-12 13:22:58 -07:00
Sam Lantinga
864b8f89fa Merged in community contributed controller mappings from https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt 2018-06-12 01:04:26 -07:00
Sam Lantinga
1205978244 Added common controllers used with Steam Big Picture
These are entirely untested
Several USB ids refer to multiple packaged products. In those cases I tried to use the most common name, or a general name (e.g. PS3 Controller), or a completely generic name (e.g. USB gamepad) if it wasn't clear what type of controller it was.
Patches welcome!
2018-06-12 00:18:10 -07:00
Sam Lantinga
fe196db774 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
db86e7a633 Added support for the PS3 controller driver in PlayStation Now 2018-06-07 10:54:54 -07:00
Sam Lantinga
113801b790 Added SDL_IsChromebook() to determine if we're running on a Chromebook. 2018-06-05 12:46:13 -07:00
Sam Lantinga
2dedbc7262 Add Android support for relative mouse mode to SDL. 2018-06-05 12:46:11 -07:00
Sam Lantinga
9d6ac3deff 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
1d25135b71 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
ff6aebc4a1 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
3d3870982c metal: contrary to documentation, we need to set the drawableSize explicitly.
Fixes Bugzilla #4149.
2018-05-27 20:30:03 -04:00
Sam Lantinga
8325df25aa 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
b3173d9d3b Added support for the NVIDIA SHIELD handheld gaming device 2018-05-23 17:15:37 -07:00
Sam Lantinga
361043a5f6 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
4d9a346927 Added additional supported Android controllers 2018-05-23 16:00:21 -07:00
Sam Lantinga
c07656dbcb Fixed default mapping for Android controller triggers (they were reversed) 2018-05-23 16:00:19 -07:00
Ryan C. Gordon
101544d6f0 audio: Needed to fix two more instances for Visual Studio. 2018-05-21 12:05:17 -04:00
Ryan C. Gordon
0ad4b0b697 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
49881861b1 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
b7e88aaae0 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!
2018-05-16 02:03:06 -04:00
Ryan C. Gordon
cb0e614fb1 audio: SSE2 float-to-int converters should clamp input.
The scalar versions already do this.
2018-05-15 02:29:35 -04:00
Ryan C. Gordon
a07e5815a5 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.
2018-05-15 01:40:05 -04:00
Ryan C. Gordon
7832cb652e 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).
2018-05-15 01:35:53 -04:00
Ryan C. Gordon
e2ec1eb12e 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.
2018-05-15 01:04:11 -04:00
Ryan C. Gordon
4df859c586 cpuinfo: Added SDL_HasAVX512F().
This checks for the "foundation" AVX-512 instructions (that all AVX-512
compatible CPUs support).
2018-05-21 11:35:42 -04:00
Ryan C. Gordon
4718791f11 cpuinfo: Make CPU flags easier to read and add to. 2018-05-14 00:03:39 -04:00
Ryan C. Gordon
8543ad7df1 cpuinfo: Added some internal SIMD-aligned allocation functions.
Fixes Bugzilla #4150 (sort of).
2018-05-21 11:34:57 -04:00
Sam Lantinga
999af8099b Merged latest changes from Steam Link app 2018-05-18 13:09:30 -07:00
Ryan C. Gordon
e2619f1dcf 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
652d59fb3b 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
fe032ff4c9 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
a4d0571e4a 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
eb14b635cd 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
606c5a585c 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
386790efbf Improved error messages when Vulkan isn't configured (thanks Daniel Gibson!) 2018-04-23 22:29:14 -07:00
Sam Lantinga
8f780e76e1 Fixed build 2018-04-23 22:17:56 -07:00
Sam Lantinga
f521b22eb5 Added SDL_THREAD_PRIORITY_TIME_CRITICAL 2018-04-23 22:07:56 -07:00
Sam Lantinga
a1b8fa6071 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
a9ae1b508d Handle NULL return from SDL_DBus_GetContext() 2018-04-23 20:24:12 -07:00
Sam Lantinga
b5d231eede Handle NULL return from SDL_DBus_GetContext() 2018-04-23 19:20:12 -07:00
Sam Lantinga
432312561f 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
816a6e68e5 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
dc8b55e50b 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
Ryan C. Gordon
2df59062dc wayland: zxdg_shell_v6 needs a configure event before using a surface at all.
Fixes Bugzilla #4109.
Fixes Bugzilla #4119.
2018-04-15 17:42:09 -04:00
Sam Lantinga
b7228bc51f Added support for the GameSir G3w 2018-04-11 18:28:03 -07:00
Sam Lantinga
6a0ef0cdbc SDL:
On Windows, have SDL_ShowWindow() not activate the window if the window has the WS_EX_NOACTIVATE window flag.
2018-04-09 10:37:31 -07:00
Sam Lantinga
4d78a99544 Fixed bug where an SDL window that was activated while hidden could never be shown.
Test code:
{
	SDL_Window *win = SDL_CreateWindow( "Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, SDL_WINDOW_HIDDEN );
	SDL_SysWMinfo info;
	SDL_VERSION( &info.version );
	SDL_GetWindowWMInfo( win, &info );
	SetActiveWindow( info.info.win.window );
	{
		DWORD then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
		SDL_ShowWindow( win );

		then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
	}
	SDL_DestroyWindow( win );
}
2018-03-26 12:38:29 -07:00
Sam Lantinga
e14278ef6f Fixed bug 3804 - Message box on Windows truncates button ID
Simon Hug

I just wanted to fix a simple compiler warning in SDL_ShowMessageBox on Windows (which Sam fixed recently) and ended up finding some issues.

Attached patch fixes these issues:

- Because Windows only reports the lower 16 bits of the control identifier that was pushed, the button IDs used by SDL (C type int, most likely 32 bits) can get cut off.

- The documentation states (somewhat ambiguously) that the button ID will be -1 if the dialog was closed, but the current code sets 0. For SDL 2.1, I think this should be a return code of SDL_ShowMessageBox itself. That will free up the button ID and it seems a more appropriate place for signaling this event.

- Ampersands in controls will create mnemonics on Windows (underlined letters that, if combined with the Alt key, will push the button). I was thinking of adding a hint or flag to let the users enable it, but that might have unexpected results.

- When the size of the text gets calculated, it doesn't use the same parameters as the static control. This can cut off text or wrap it weirdly.

- On Windows, the Tab key is used to switch between control groups and sometimes between buttons in dialogs. This didn't seem to work correctly.

Attached patch also adds:

- Icons. Just the system ones that can be loaded with the ordinals IDI_ERROR, IDI_WARNING and IDI_INFORMATION.

- A button limit of 2^16 - 101.

- Some more specific error messages, but they never reach the user because how SDL_ShowMessageBox handles them if an implementation returns with an error.
2018-03-24 10:26:40 -07:00
Sam Lantinga
b41b9d34c7 Fixed return value 2018-03-19 14:52:53 -07:00
Sam Lantinga
8e062f6925 Generalized the handling of instantaneous guide button presses so there's a minimum of 100 ms between guide button press and release.
This happens with at least the following controllers: All Apple MFI controllers, ASUS Gamepad, XiaoMi Bluetooth Controller
2018-03-19 14:42:51 -07:00
Sam Lantinga
d529b001bc Added mapping for the ASUS Gamepad removing the guide button, which doesn't generate events even though it's reported in the Android APIs. 2018-03-19 13:16:11 -07:00
Sam Lantinga
f536fbea71 Reimplemented Android cursor API support using reflection so it builds with older SDKs 2018-03-16 11:08:53 -07:00
Sam Lantinga
e20d4173bf Added Android custom cursor implementation
This is commented out in SDLActivity.java, with the note #CURSORIMPLEENTATION because it requires API 24, which is higher than the minimum required SDK
2018-03-15 18:22:48 -07:00
Sam Lantinga
d401a77eff Fixed bug 4102 - define _WIN32_WINNT_WIN7 if not already defined
Ozkan Sezer

The following patch defines _WIN32_WINNT_WIN7 if it is not already
defined in core/windows/SDL_windows.c,  similar to what is already
there for _WIN32_WINNT_VISTA.
2018-03-10 21:22:42 -08:00
Sam Lantinga
cc7b2fc512 Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notch) don't generate events
Eric Wasylishen

This bug was reintroduced by https://hg.libsdl.org/SDL/rev/fcf24b38a28a

The steps to reproduce are the same: run the "testrelative" SDL demo with "--info all",
connect a USB mouse with a scroll wheel, and roll the scroll wheel one "notch". You'll get log output like:

testdraw2[1644:67222] INFO: SDL EVENT: Mouse: wheel scrolled 0 in x and 0 in y (reversed: 1) in window 1

As far as I can tell macOS doesn't have an API for getting the number of "wheel notches"; I get a deltaY of 0.100006 for one "notch", and it's heavily accelerated (if you roll the wheel quickly you'll get large deltas). So NSEvent's deltaY is only meant to be used for scrolling a scroll view, with the given distance in points, not something like selecting an item in a game.

Here's a temporary patch that at restores the foor/ceil in Cocoa_HandleMouseWheel.
Not ideal, but at least it restores the ability to scroll one notch of a mousewheel.
2018-03-10 21:13:50 -08:00
Sam Lantinga
129431b4f4 Delay delivery of the pause button release on MFI controllers so it doesn't happen in the same frame as the button press 2018-03-08 16:32:22 -08:00
Sam Lantinga
92847022f5 Added a mapping for the latest firmware for the Xbox One S controller on Android 2018-03-07 18:10:01 -08:00
Sam Lantinga
a2c1d83c02 Include a USB VID/PID for Apple MFI controllers
This is just placeholder VID/PID, but allows code that works with VID/PID to identify the MFI controllers easily.
2018-03-07 18:09:58 -08:00
Sam Lantinga
a8ac588549 Added SDL_GameControllerMappingForDeviceIndex() to get the mapping for a controller before it's opened 2018-03-07 13:30:40 -08:00
Sam Lantinga
9e651b6915 Try to dynamically create a default Android game controller mapping based on the buttons and axes on the controller.
Include the controller USB VID/PID in the GUID where possible, as we do on other platforms.
2018-03-06 14:51:50 -08:00
Sam Lantinga
2419d26724 Progress fixing bug 4100 - errors and warnings after changeset 11917
Ozkan Sezer 2018-03-02 20:02:37 UTC
http://hg.libsdl.org/SDL/rev/d702b0c54e52 resulted in an error and
two warnings when compiled with mingw.

1.  Error from SDL_windowstaskdialog.h:
In file included from src/video/windows/SDL_windowsmessagebox.c:29:0:
src/video/windows/SDL_windowstaskdialog.h:23:54: error: expected ')' before 'HWND'

This is fixed by removing unnecessary annotations:

2.  Warning from SDL_assert.c:
src/SDL_assert.c: In function 'SDL_ExitProcess':
src/SDL_assert.c:138:1: warning: 'noreturn' function does return

Indeed ExitProcess() is prototyped with DECLSPEC_NORETURN, but
TerminateProcess() is not.  This can be rectified by adding an
exit() call in there. Do NOTE, however, that requires building
with a libc:

3.  Warning from SDL_windowsmessagebox.c:
src/video/windows/SDL_windowsmessagebox.c: In function 'WIN_ShowMessageBox':
src/video/windows/SDL_windowsmessagebox.c:513:9: warning: 'nCancelButton' may be used uninitialized in this function

My lazy solution was manually initializing nCancelButton to 0.
2018-03-02 22:53:25 -08:00
Sam Lantinga
ac2d1f6773 Fixed setting the layer drawable size
Without this change the drawable had a size of 0 and the metal renderer asserted because the projection matrix wasn't set.
2018-03-02 12:08:18 -08:00
Ryan C. Gordon
cef1c1c2ee windows: Restore patches for Task Dialogs and TerminateProcess().
2.0.8 has shipped, these can live in revision control now!
2018-03-02 14:10:25 -05:00
Sam Lantinga
003c0dce9c Use the real controller name for game controllers on iOS and Apple TV 2018-03-02 10:56:21 -08:00
Ryan C. Gordon
3537c3e7a9 Back out Task Dialog and TerminateProcess patches for 2.0.8.
These can return to revision control once we ship.
2018-02-28 10:39:41 -05:00
Ryan C. Gordon
6a1cfccef8 windows: dos2unix'd messagebox code, and (hopefully) fixed on MingW. 2018-02-28 02:14:15 -05:00
Ryan C. Gordon
a749035f10 windows: Message boxes use Task Dialogs if possible (thanks, Jack!).
This lets the message box have an icon. Unless the app has opted-in to using
the v6 common controls, though, this will fall back to the usual SDL message
boxes.
2018-02-28 01:54:22 -05:00
Ryan C. Gordon
8536130aa2 assert: Use TerminateProcess() on Windows, vs ExitProcess (thanks, Jack!).
"What I have done is use TerminateProcess rather than ExitProcess.
ExitProcess will cause Microsoft's leak detection to continue, TerminateProcess
won't. It is also technically wrong to use ExitProcess in the case of aborting
the application.

Jack Powell
Twitter @jack9267"
2018-02-28 01:23:49 -05:00
Mark Callow
be6ca785e3 Support official Vulkan SDK for macOS.
This tries to load vulkan.framework or libvulkan.1.dylib before MoltenVK.framework
or libMoltenVK.dylib. In the previous version, layers would not work for applications
run-time loading the default library.
2018-02-25 23:02:09 -08:00
Sam Lantinga
f9f45d0bf5 Fixed bug 4097 - Segmentation fault by SDL_CreateThreadWithStackSize
Dongsun Kim

Normal case
1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread.
2. [thread 1] If successful, it calls SDL_SemWait.
3. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost.
4. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free.

Crash case (Segmentation fault)
1. [thread 1] SDL_CreateThreadWithStackSize calls SDL_SYS_CreateThread.
2. [thread 1] If successful, it calls SDL_SemWait.
--> Error return due to SIGNAL(SYSTEM or Real Time) at sem_wait(pthread).
3. [thread 1] SDL_CreateThreadWithStackSize calls SDL_DestroySemaphore, SDL_free.
4. [thread 2] SDL_RunThread calls SDL_SYS_SetupThread, SDL_ThreadID, SDL_SemPost.
--> Segmentation fault at strlen or sem_post.
2018-02-25 19:51:34 -08:00
Ozkan Sezer
3ea093cc85 SDL_test_fuzzer.c: fix strict aliasing warnings by using a union. 2018-02-25 10:15:00 +03:00
Sam Lantinga
849d042fa4 Fixed bug 4091 - Undefined references to Android audio functions when SDL_AUDIO_DISABLED is on
Manuel Sabogal

If SDL is compiled with the Audio subsystem disabled there are some undefined references to the functions ANDROIDAUDIO_ResumeDevices and ANDROIDAUDIO_PauseDevices in the file src/video/android/SDL_androidevents.c.
2018-02-24 08:58:22 -08:00
Sam Lantinga
99a0c0f0e2 Fixed MinGW-w64 build 2018-02-24 08:23:44 -08:00
Brandon Schaefer
0626486e2e Backout the vulkan change in d449dea10fc8 breaks Mir builds 2018-02-23 19:12:04 -05:00
Brandon Schaefer
e17c3219d3 mir: Disable Mir by default as Mir supports Wayland clients
Also remove enabling VK support for Mir
2018-02-23 11:24:26 -05:00
Ryan C. Gordon
8891f5919f Backed out changeset 6c8521d53507
Apparently this still triggers a compiler warning, have to dig further.
2018-02-21 22:53:52 -05:00
Ryan C. Gordon
fd8f12d2a1 android: apparently they fixed this header at some point. 2018-02-21 22:35:17 -05:00
Ryan C. Gordon
ac309df7b4 vulkan: Possibly fix a compiler warning (-Wstrict-prototypes). 2018-02-21 22:27:09 -05:00
Ryan C. Gordon
c7e4366530 wasapi: let Windows do the resampling for us if possible. 2018-02-21 21:34:06 -05:00
Ryan C. Gordon
7e1fa0ce53 wasapi: fixed typo in an assert message. 2018-02-21 21:34:35 -05:00
Ryan C. Gordon
ed64d54dfd windows: added WIN_IsWindows7OrGreater(). 2018-02-21 21:36:10 -05:00
Ethan Lee
6e3d0a133c Use new XInput mapping for Win10+ (Bugzilla #3960) 2018-02-21 12:42:30 -05:00
Mark Callow
69958441be Fix high-dpi support on macOS and simplify it and iOS variant.
The detault drawableSize for a CAMetalLayer is its bounds x its scale.
So it is sufficient to set the *layer's* scale to the desired value.
2018-02-21 09:58:21 -08:00
Sam Lantinga
a0687a9ccb Fixed bug 4034 - Don't include _DllMainCRTStartup() if SDL_STATIC_LIB is defined. 2018-02-21 09:40:47 -08:00
Sam Lantinga
58f9be1257 Actually, this is needed for building with Visual Studio with both /MT and /MD.
With the previous change, I get:
1>     Creating library C:\projects\SDL\VisualC\Win32\Debug\SDL2.lib and object C:\projects\SDL\VisualC\Win32\Debug\SDL2.exp
1>LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
2018-02-18 09:09:56 -08:00
Sam Lantinga
3c9d33361c Fixed bug 4034 - Do we really need _DllMainCRTStartup() in every Windows build?
Andreas Falkenhahn

In src/SDL.c there is this code:

_DllMainCRTStartup(HANDLE hModule,

...

The comment says that this is needed on Watcom C for some reason but why is it included then when building with Visual C as well? Shouldn't it be only included when compiling on Watcom C then?

I'm asking because this code caused me a lot of headaches because I'm building a DLL that contains SDL and I link using /MT and the _DllMainCRTStartup() symbol obviously led to lots of trouble but it wasn't clear to me where the problem was because all I got from the linker was:

LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup

So I had to got through each and every object to see what the culprit was. See here for the full story:
https://stackoverflow.com/questions/25067151/lnk2019-unresolved-external-symbol-main-referenced-in-function-tmaincrtstar/48177067#48177067

So if it isn't necessary on Visual C, please just leave that symbol out on Visual C so that it no longer leads to any trouble. Thanks.
2018-02-18 08:57:01 -08:00
Ryan C. Gordon
75a58303a0 pthread: fix error code checks (thanks, Andreas!).
Most pthread functions return 0 on success and non-zero on error, but those
errors might be positive or negative, so checking for return values in the
Unix style, where errors are less than zero, is a bug.

Fixes Bugzilla #4039.
2018-02-17 23:57:57 -05:00
Ryan C. Gordon
2ea4419a57 yuv: patched to compile. 2018-02-17 20:18:48 -05:00
Ryan C. Gordon
7c0c2c22a8 yuv: fixed variable declaration shadowing warnings.
Fixes Bugzilla #4062.
2018-02-17 20:10:13 -05:00
Ryan C. Gordon
97494f5374 pulseaudio: Just read/dump captured data in FlushCapture.
Apparently pa_stream_flush() doesn't work as expected:

https://lists.freedesktop.org/archives/pulseaudio-discuss/2012-April/013328.html

Fixes Bugzilla #4087.
2018-02-17 18:30:21 -05:00
Ryan C. Gordon
6867f6189f video: put a spinlock around a global linked list.
This should only contend if you're allocating or freeing surfaces from
multiple threads at once, and then just for a short time.

Fixes Bugzilla #4084.
2018-02-16 14:56:28 -05:00
Sam Lantinga
8ddebfa06e Fixed bug 4085 - X11: Allow configuring _NET_WM_BYPASS_COMPOSITOR through SDL hints
Callum McGing

This patch allows the user to disable the behaviour that blocks the compositor through a new hint: SDL_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR. This allows tools or other windowed applications to behave properly under KWin.
2018-02-16 10:23:10 -08:00
Ozkan Sezer
926d803f83 bug #3739: handle %lu, %li and %ld in SDL_SetError. 2017-10-29 14:15:00 +03:00
Sam Lantinga
5abd7d16d7 Don't attempt WM_NCCALCSIZE adjustment when in fullscreen window transition 2018-02-13 22:58:20 -08:00
sezero
ba0ecc6712 fix building SDL_audiotypecvt.c with gcc < 4.0 2018-02-12 10:47:00 +03:00
sezero
40b27fd51b revert the recent typecast assignment changes (see bug #4079)
also change the void* typedefs for the two vulkan function
pointers added in vulkan_internal.h  into generic function
pointer typedefs.
2018-02-12 17:00:00 +03:00
Sam Lantinga
f6366c09e2 Fixed bug 3920 - IBus not work with SDL 2.0.7
cjacker

After updating from 2.0.5 to 2.0.7, Ibus not work anymore(fcitx still works).

Compare with 2.0.5, there are two issues in SDL_ibus.c.

1, SetupConnection always return SDL_FALSE in 2.0.7.

2, 'SetCapabilities' method should be called on 'ibus_conn'.

Patch attached.
2018-02-13 08:15:39 -08:00
Sam Lantinga
3b4c2fdf5d Fixed bug 3947 - replace strlcpy with memcpy in SDL_strdup() 2018-02-13 08:13:29 -08:00
Sam Lantinga
714085d327 Fixed bug 3950 - Don't always call dbus_shutdown in SDL_DBus
Alexander Larsson

dbus_shutdown() is a debug feature which closes all global resources in the dbus library. Calling this should be done by the app, not a library, because if there are multiple users of dbus in the process then SDL could shut it down even though another part is using it.

For example, i had an issue with this in mGBA, which uses both Qt and SDL, both using libdbus. I had a session bus, but no system bus (this was in a flatpak sandbox), and when SDL_DBus_Init() failed to init the system bus it called dbus_shudown() and continued on. This caused issues for Qt when running due to its session bus connections having disappeared beneath it.
2018-02-13 08:07:52 -08:00
sezero
8a1ae708d4 kill C99'ism in SDL_waylandvulkan.c 2018-02-12 10:00:00 +03:00
Sam Lantinga
6e01fbb763 On Android show the system UI when an SDL window is windowed, hide the system UI when it's fullscreen, like we do on iOS.
We're increasing the Android SDK minimum version to API 19, this doesn't increase the minimum target API, which is API 14.
2018-02-11 18:23:37 -08:00
Sam Lantinga
873141acb1 ISO C correct fix for casting void* to function pointer 2018-02-11 15:29:36 -08:00
Ryan C. Gordon
882215e138 vulkan: Fix assignment of vkGetInstanceProcAddr on Windows.
"*(void**)pfn = LoadAddress()" would cast the NULL pointer in pfn to a
void**, and then dereference it, which wasn't what we wanted. Replaced with
a clearer cast operation.
2018-02-11 18:16:01 -05:00
Sam Lantinga
1143857d76 Fixed bug 4073 - Unquoted Unicode argument parsing broken on Windows due to incorrect usage of SDL_isspace() 2018-02-10 12:43:11 -08:00
Sam Lantinga
d5f293a777 Fixed compile warning 2018-02-09 16:31:57 -08:00
Sam Lantinga
7c36002739 Fixed compiler warning on Android 2018-02-09 16:01:11 -08:00
Sam Lantinga
7b50aee932 Fixed min/max window size handling for borderless resizable windows 2018-02-08 18:07:14 -08:00
sezero
4c2a444e3a add SDL_log10 and SDL_log10f to include and dynapi 2018-02-08 17:07:47 +03:00
Sam Lantinga
940933d892 Fixed bug 4054 - Raspberry Pi refresh rate detection
Viacheslav Slavinsky

SDL_rpivideo driver has 60 frames per second hardcoded in it, this is a problem for games that need to keep pace using VSYNC. I believe that I have found a solution to this. It is based on code in tvservice.c in rpi userland:

a1b89e91f3/host_applications/linux/apps/tvservice/tvservice.c (L433)
2018-02-07 15:05:30 -08:00
Ethan Lee
11c348b4d7 SDL_log10 2018-01-17 11:53:09 -05:00
Guillermo A. Amaral
bd0def06ee Set rpath instead of changing environment for RPi
Credit goes to Adrian Perez de Castro for the improvement.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
2018-02-07 14:12:26 -08:00
Sam Lantinga
965c11f38a Fixed bug 4060 - Alternative DualShock 4 v2 controller GUID
ayer.3d

I have a DualShock 4 v2 controller with a GUID that's not in the database. There is an existing GUID that is almost identical, with the only difference that I can tell being the reported version string (mine being 8001, database is 8100).

Existing GUID: 050000004c050000cc09000000810000
     New GUID: 050000004c050000cc09000001800000

When connected via USB, the GUID matches an existing entry: 030000004c050000cc09000011810000
2018-02-07 14:07:54 -08:00
Ryan C. Gordon
cd53220749 wayland: Add support for xdg-shell protocol (unstable v6).
This is meant to be the desktop-enhanced version of wl_shell. Right now we
just match what the existing wl_shell code does, but there are other areas of
functionality available to us now, that we can fill in later.

This uses the "unstable" API, since this is what ships in Ubuntu 17.10 (as
part of Wayland 1.10), but Wayland 1.12 promotes this to stable with extremely
minor changes. We will add support for the stable version when it makes sense
to do so.
2018-02-07 13:13:55 -05:00
Sam Lantinga
73c26c204c Send Apple TV remote input as key events unless it's opened as a joystick, to match Android behavior. 2018-02-06 16:43:31 -08:00
Sam Lantinga
f59b9c8b13 Replaced SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS with SDL_HINT_TV_REMOTE_AS_JOYSTICK which controls whether remotes on iOS and Android are interpreted as joysticks (the default) or as return/escape/arrow keys. 2018-02-06 15:03:38 -08:00
Sam Lantinga
6ed184ec69 Added SDL_IsAndroidTV() 2018-02-06 15:03:35 -08:00
Sam Lantinga
2b441ec6c4 SDL Changes to support clean reads
CR: saml
2018-02-05 11:40:39 -08:00
Sam Lantinga
35322ed847 Fixed building on tvOS 2018-02-01 15:46:51 -08:00
Sam Lantinga
85c34e9a39 Added SDL_HINT_IOS_HIDE_HOME_INDICATOR to determine how the home indicator on the iPhone X is handled.
This variable can be set to the following values:
   "0"       - The indicator bar is not hidden (default for windowed applications)
   "1"       - The indicator bar is hidden and is shown when the screen is touched (useful for movie playback applications)
   "2"       - The indicator bar is dim and the first swipe makes it visible and the second swipe performs the "home" action (default for fullscreen applications)
2018-02-01 15:21:01 -08:00
Sam Lantinga
330b19c968 Fixed building on platforms without __sighandler_t 2018-01-30 18:12:25 -08:00
Sam Lantinga
90e72bf4e2 Fixed ISO C99 compatibility
SDL now builds with gcc 7.2 with the following command line options:
-Wall -pedantic-errors -Wno-deprecated-declarations -Wno-overlength-strings --std=c99
2018-01-30 18:08:34 -08:00
Sam Lantinga
e1d85985b2 Fixed misleading indentation 2018-01-30 16:53:24 -08:00
Sam Lantinga
2d7420f238 Fixed bug 3985 - SDL_CreateWindow() has stopped changing screen mode when SDL_WINDOW_FULLSCREEN is used
Anthony

This worked in 2.0.5 as normal, but stopped working in 2.0.7. The monitor's resolution doesn't change, a window is created in full screen mode at the virtual desktop resolution instead.
2018-01-25 11:12:20 -08:00
Ryan C. Gordon
e99daaf8b5 android: Fixed compiler warning about nested '/*' comments. 2018-01-22 09:45:16 -05:00
Ryan C. Gordon
488824017a wasapi: Fixed some compiler warnings. 2018-01-22 09:36:40 -05:00
Sam Lantinga
9338a619f8 Added a hint SDL_HINT_APPLE_TV_REMOTE_SWIPES_AS_ARROW_KEYS to prevent turning Apple TV remote swipes into arrow key events 2018-01-17 17:24:15 -08:00
Dawid Gan
61261e59bc EGL: Request sRGB framebuffer in correct place.
The EGL_GL_COLORSPACE_KHR is an attribute for eglCreate*Surface.

As written in EGL_KHR_gl_colorspace documentation:

    Accepted as an attribute name by eglCreateWindowSurface,
    eglCreatePbufferSurface and eglCreatePixmapSurface

        EGL_GL_COLORSPACE_KHR                   0x309D
    (...)
2018-01-16 21:29:32 +01:00
Guillermo A. Amaral
35554caf16 Make rpi video cross-compiler friendly.
* Stops using fixed path to find GLES/EGL libs.
* Tries pkg-config to locate bcm_host.

Signed-off-by: Guillermo A. Amaral <g@maral.me>
2018-01-17 13:17:10 -08:00
Sam Lantinga
509db8afbd Fixed formatting, added actual count to SDL error message 2018-01-17 13:12:39 -08:00
John Bartholomew
f9bdce61e1 Vulkan: Allow SDL_Vulkan_GetInstanceExtensions to be called with a larger array than necessary. 2018-01-14 13:34:50 +00:00
Marius Gripsgard
7cd39b7d15 Mir: Handle close window events 2018-01-13 01:58:11 +01:00
Sam Lantinga
0cba684794 Fixed bug 4043 - SDL_windowswindow.c incorrect icon height
Needed to allocate space for the mask in the ICONIMAGE structure
2018-01-15 10:29:53 -08:00
Sam Lantinga
a0c4eb2aa3 Restored borderless window behavior where DOTA created a borderless window the size of the desktop and expected it to behave like a fullscreen desktop window.
A future SDL release will change the borderless window to act more like a normal window that happens to have no chrome, to support windows that draw their own chrome. In the meantime, those applications should set the "SDL_BORDERLESS_WINDOWED_STYLE" hint.
2018-01-10 18:00:51 -08:00
Alex Szpakowski
3bfada2e02 Android: resolve symlinks in SDL_AndroidGetInternalStoragePath (thanks Henrique Gemignani and cigumo!)
Fixes issues on modern Android versions when the path is used in code that explicitly doesn't follow symlinks (such as PHYSFS_mkdir).
2018-01-10 19:56:51 -04:00
Sam Lantinga
72d4507918 Added availability check to fix compiler warning for symbol only available on tvOS 11.0 and newer 2018-01-10 10:42:40 -08:00
Alex Szpakowski
7d5437bb31 metal: set max texture size based on device capability. 2018-01-07 22:00:37 -04:00
Alex Szpakowski
a8c0532c08 metal: Fix pipeline states to use the pixel format of the current render target, instead of a hard-coded format. 2018-01-07 16:57:32 -04:00
Alex Szpakowski
740a90af37 metal: Add support for YUV/NV12 texture formats. 2018-01-06 18:54:12 -04:00
Alex Szpakowski
9a8683b275 metal: use a private instead of managed buffer for the renderer's non-changing constant data.
Recommended by Xcode's Metal frame capture analysis.
2018-01-04 22:16:42 -04:00
Alex Szpakowski
990ebba55a metal: Implement fast hardware clearing when possible, by deferring the start of a render pass until a clear or draw operation happens. 2018-01-04 19:29:33 -04:00
Sam Lantinga
66baf7363e Fixed spacing in copyright headers 2018-01-03 11:31:42 -08:00
Sam Lantinga
7c60bec493 Fixed bug 4018 - Implement SDL_GetWindowBordersSize() under Windows/Win32/WinAPI
Ismael Ferreras Morezuelas (Swyter)

As a new year gift I have implemented the Windows version of SDL_GetWindowBordersSize(). I needed it for auto-selecting a cozy window size for the game I'm currently working on and noticed that it only worked under X11, so I thought it could be a good excuse to contribute back more stuff. The Mercurial patch is attached as a .diff file. Let me know what you think.

Happy 2018 to all the SDL2 devs and users!

--

PS: Keep in mind that Windows 10 includes the 8px invisible grip borders as part of the frame. There's a way of detecting if Aero/DWM is being used and ask only for the visible rect, but I believe that GetWindowRect() is doing that for a reason and working as intended, so I haven't changed it. (See [2])


References:
[1]: http://www.firststeps.ru/mfc/winapi/r.php?72
[2]: https://stackoverflow.com/a/34143777/674685
[3]: https://stackoverflow.com/a/431548/674685
[4]: https://wiki.libsdl.org/SDL_GetWindowBordersSize
2018-01-03 10:58:58 -08:00
Sam Lantinga
8111a632be Fixed bug 4013 - Wayland: fix videoquit on multimonitor system
Vladimir

On multimonitor system Wayland_VideoQuit invalid deiniting.

Tested in Centos7 + Weston
2018-01-03 10:49:26 -08:00
Sam Lantinga
1fa4bcca6a Fixed bug 4012 - Wayland: invalid direction on mouse wheel
Vladimir

Invalid direction on mouse wheel

Patch tested in Centos 7 + Weston
2018-01-03 10:43:01 -08:00
Sam Lantinga
6bc3873729 Fixed bug 4011 - Wayland: fix free cursor
Vladimir

Sometimes SDL application crashes on cursor free.

Patch tested under Centos 7 + weston
2018-01-03 10:07:27 -08:00
Sam Lantinga
e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Alex Szpakowski
888198ee31 metal: Misc. improvements.
- Use a single buffer for various non-changing constants accessed by the GPU, instead of multiple buffers.
- Do the half-pixel offset for points and lines using a transform matrix so we don't need a malloc when rendering.
- Don't add a half-pixel offset for other primitives and textures. This matches D3D and GL render behaviour.
- Remove the half-texel texture coordinate offset since it's not needed now that there's no more half-pixel position offset when rendering a texture.
- Don't try to set texture usage on iOS 8 since it doesn't exist there.
2018-01-03 00:43:01 -04:00
Alex Szpakowski
f9cd765020 metal and moltenvk: fix highdpi. 2018-01-02 21:44:28 -04:00
Sam Lantinga
b3b5c47366 Fixed direction of y adjustment for new orthographic projection in the metal renderer 2018-01-02 14:32:15 -08:00
Sam Lantinga
fa86807ceb Fixed metal renderer pixel centers when drawing 2018-01-02 14:11:10 -08:00
Alex Szpakowski
07f08b47ff metal: Fix a typo preventing iOS compilation... 2018-01-01 23:06:08 -04:00
Alex Szpakowski
1cc6603378 metal: Clean up manual reference counting. Fixes some memory leaks. 2018-01-01 23:03:50 -04:00
Ryan C. Gordon
7c667a6f7a windows: Remove references to GetVersionExA (thanks, Andrew Pilley!).
"GetVersionExA is deprecated in windows 8.1 and above's SDK, causing a warning
when building against the win10 SDK. Attached patch cleans up the usage for a
warning-free build.

GetVersionExA was being used to test to see if SDL was running on win9x or
winnt. A quick chat with Ryan on twitter suggested that SDL doesn't
officially support win9x anymore, so the call to this can be outright removed.

As an aside, replacing the call to GetVersionExA with VerifyVersionInfoA (the
recommended path) would have been pointless, as VerifyVersionInfoA only
supports VER_PLATFORM_WIN32_NT and doesn't officially support any other value
for dwPlatformId currently. (And it's probable that win9x SDKs didn't have
VerifyVersionInfo* in them anyway.)"

Fixes Bugzilla #4019.
2018-01-01 19:16:51 -05:00
Alex Szpakowski
a452a08458 iOS: fix build 2018-01-01 19:40:29 -04:00
Alex Szpakowski
639ea9fdbc metal: Use sampler state objects instead of shader-declared samplers for linear vs nearest filtering.
This avoids a ton of shader duplication once multiple shaders that use samplers are added (e.g. the currently missing YUV shaders).
2018-01-01 19:37:16 -04:00
Alex Szpakowski
cf45cf70e5 metal: Add support for custom blend modes. 2018-01-01 18:06:27 -04:00
Alex Szpakowski
85470a2f95 metal: implement SDL_RenderCopyEx, and fix a memory leak in SDL_CreateTexture. 2017-12-31 21:06:16 -04:00
Alex Szpakowski
047d387b2e metal: Use the existing cocoa code for creating a Metal view on macOS. Fixes the renderer size when the window is resized. 2017-12-31 15:30:08 -04:00
Alex Szpakowski
48fea0cee4 macOS: Fix MoltenVK Metal view resizing, and allow the metal view to be used without vulkan. 2017-12-31 15:21:25 -04:00
Ryan C. Gordon
027d63bc01 winrt: workaround for pre-UWP builds.
There's probably a better way to do this for legacy platforms, though.
2017-12-31 03:36:54 -05:00
Ryan C. Gordon
140cc46004 windows: Use WaitForSingleObjectEx() always
This is available since Windows XP, so it's safe to use always, not just in
a WinRT ifdef.
2017-12-31 03:35:41 -05:00
Ryan C. Gordon
77bb49b7a7 wasapi: Patched to compile on non-UWP WinRT builds. 2017-12-31 03:34:16 -05:00
Alex Szpakowski
42b19c9749 metal: Respect the vsync flag on macOS 10.13+. 2017-12-30 22:39:55 -04:00
Alex Szpakowski
e24dc9053b metal: use a projection matrix instead of manually transforming vertices into clip space on the CPU. 2017-12-30 20:32:22 -04:00
Alex Szpakowski
49df65c25a metal: only 4 (instead of 5) vertices are needed to draw rectangles and textures, and only 3 (instead of 5) vertices are needed to cover the screen for the 'full-screen quad' when clearing. 2017-12-30 18:48:07 -04:00
Alex Szpakowski
64ec4c3334 macOS: Make sure the desktop's display mode is always in SDL's list of display modes. 2017-12-29 22:13:40 -04:00
Sam Lantinga
b7be5bce33 Fixed bug 4000 - SDL2 on raspberry: mouse displayed at 0,0 after SDL_ShowCursor
Laurent Merckx

I have a problem with the SDL_ShowCursor method on Raspberry.

Depending on the context, my application hides or show the mouse cursor with SDL_ShowCursor.
But when calling SDL_ShowCursor(true), the cursor is displayed at 0,0 (and not at last position).

After debugging sources by myself, it seems that the problem is in SDL_rpimouse.c - RPI_ShowCursor:

vc_dispmanx_rect_set( &dst_rect, 0, 0, curdata->w, curdata->h);
should be
vc_dispmanx_rect_set( &dst_rect, mouse->x, mouse->y, curdata->w, curdata->h);

For me, it solves the problem.
2017-12-19 11:17:37 -08:00
Sam Lantinga
70082db849 Fixed bug 4003 - HAVE_POLL undefined in SDL_poll.c, making it impossible to use.
tomwardio

HAVE_POLL is correctly defined in SDL_config.h when running configure. However, in the only place where it's used, it's undefined at the start of the file.
2017-12-19 11:14:06 -08:00
Sam Lantinga
b92e2f027a Fixed bug 4004 - iOS: don't hide keyboard on RETURN
Dominik Reichardt

As discussed in 2012 the iOS onscreen keyboard hides when you hit RETURN (see https://discourse.libsdl.org/t/on-screen-keyboard-change/19216).
IMO this is a bad idea to not be able to influence this behavior and just recently this was fixed for Android by adding the hint SDL_HINT_ANDROID_RETURN_HIDES_IME in changeset 11768	6ce3bb5e38a5.
2017-12-19 10:57:21 -08:00
Sam Lantinga
fee2469c65 Fixed bug 4005 - Android, SDL_IsGameController() crashes is index is out of range
Sylvain

On Android, if you give an invalid index to SDL_IsGameController(), it will crash in SDL_SYS_IsDPAD_DeviceIndex().
2017-12-19 10:48:29 -08:00
Sam Lantinga
e5cfa24182 Fixed default Android D-PAD mapping so the back button is treated as B 2017-12-16 10:40:47 -08:00
Sam Lantinga
255362a3ed Fixed handling of the Apple TV remote buttons
The menu button on the remote is the back button
2017-12-16 10:40:45 -08:00
Sam Lantinga
cc30e1eb3d Added support for the ASUS TV500BG Android gamepad 2017-12-16 10:40:43 -08:00
Ryan C. Gordon
ab4695f48f wasapi: switched to event-driven interface.
This reduces latency and improves battery life.
2017-12-13 14:35:55 -05:00
Ryan C. Gordon
988034fcc7 windows: Fixed a comment. 2017-12-12 22:25:39 -05:00
Sam Lantinga
18577a70dd Fixed bug 3992 - SDL_GetColorKey doesn't set error message
Luke A. Guest

SDL_GetColorKey does not set an error message on failure. The current source just returns -1.

The documentation https://wiki.libsdl.org/SDL_GetColorKey?highlight=%28%5CbCategoryAPI%5Cb%29%7C%28SDLFunctionTemplate%29 says to call SDL_GetError but that is useless in this case.
2017-12-12 16:37:23 -08:00
Sam Lantinga
87894224b6 Fixed bug 3981 - Inverted logic bug in SDL_renderer "overscan" feature
Eric wing

There is a tiny bug in the new overscan code for the SDL_renderer.

In SDL_renderer.c, line 1265, the if check for SDL_strcasecmp with "direct3d" needs to be inverted.

Instead of:
if(SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) {

It should be:
if(0 == SDL_strcasecmp("direct3d", SDL_GetCurrentVideoDriver())) {

This bug causes the "overscan" mode to pretty much be completely ignored in all cases and all things remain letterboxed (as before the feature).
2017-12-12 16:34:16 -08:00
Sam Lantinga
ca7297668a Fixed bug 3996 - Corrupted or over-released critical section on SDL_Quit (SDL_event_watchers_lock)
Andrew

This likely comes down to an additional 'unlock' being called before destroying it, without a matching 'lock'.
2017-12-12 16:10:20 -08:00
Sam Lantinga
e8bbbb37f1 Added support for Android video textures 2017-12-12 12:52:17 -08:00
Sam Lantinga
bed7fd8066 Merged latest changes from rel/streaming_client 2017-12-12 12:52:09 -08:00
Sam Lantinga
e0d0184f09 Fixed bug 3999 - Build failed when try to build with configure script for Android 2017-12-11 14:44:34 -08:00
Sam Lantinga
1b16618b13 Fixed Windows gcc build 2017-12-11 11:47:52 -08:00
Sam Lantinga
7ac46a7449 The newer compilers generate the property boilerplate automatically 2017-12-11 11:34:53 -08:00
Sam Lantinga
358e4d9c7e Fixed Mac OS X build 2017-12-11 11:02:51 -08:00
Sam Lantinga
ab06f570a8 Workaround for bug 3931 - spurious SDL_MOUSEMOTION events with SDL_HINT_MOUSE_RELATIVE_MODE_WARP 1 since Windows 10 Fall Creators update
Elis?e Maurer

The attached minimal program sets the SDL_HINT_MOUSE_RELATIVE_MODE_WARP to 1, enables relative mouse mode then logs all SDL_MOUSEMOTION xrel values as they happen.

When moving the mouse exclusively to the right:

 * On a Windows 10 installation before Fall Creators update (for instance, Version	10.0.15063 Build 15063), only positive values are reported, as expected
 * On a Windows 10 installation after Fall Creators update (for instance, Version 10.0.16299 Update 16299), a mix of positive and negative values are reported.

3 different people have reproduced this bug and have confirmed it started to happen after the Fall Creators update was installed. It happens with SDL 2.0.7 as well as latest default branch as of today.

It seems like some obscure (maybe unintended) Windows behavior change? Haven't been able to pin it down more yet.

(To force-upgrade a Windows installation to the Fall Creators update, you can use the update assistant at https://www.microsoft.com/en-us/software-download/windows10)

Eric Wasylishen

Broken GetCursorPos / SetCursorPos based games on Win 10 fall creators are not limited to SDL.. I just tested winquake.exe (original 1997 exe) and it now has "jumps" in the mouse input if you try to look around in a circle. It uses GetCursorPos/SetCursorPos by default. Switching WinQuake to use directinput (-dinput flag) seems to get rid of the jumps.

Daniel Gibson

A friend tested on Win10 1607 (which is before the Fall Creators Update) and the  the bug doesn't occur there, so the regression that SetCursorPos() doesn't reliably generate mouse events was indeed introduced with that update.
I even reproduced it in a minimal WinAPI-only application (https://gist.github.com/DanielGibson/b5b033c67b9137f0280af9fc53352c68), the weird thing is that if you don't do anything each "frame" (i.e. the mainloop only polls the events and does nothing else), there are a lot of mouse events with the coordinates you passed to SetCursorPos(), but when sleeping for 10ms in each iteration of the mainloop, those events basically don't happen anymore. Which is bad, because in games the each iteration of the mainloop usually takes 16ms..

I have a patch now that I find acceptable.
It checks for the windows version with RtlGetVersion() (https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx) and only if it's >= Win10 build 16299, enables the workaround.
All code is in video/windows/SDL_windowsevents.c
and the workaround is, that for each WM_MOUSEMOVE event, "if(isWin10FCUorNewer && mouseID != SDL_TOUCH_MOUSEID && mouse->relative_mode_warp)", an addition mouse move event is generated with the coordinates of the center of the screen
(SDL_SendMouseMotion(data->window, mouseID, 0, center_x, center_y);) - which is exactly what would happen if windows generated those reliably itself.
This will cause SDL_PrivateSendMouseMotion() to set mouse->last_x = center_x; and mouse->last_y = center_y; so the next mouse relative mouse event will be calculated correctly.

If Microsoft ever fixes this bug, the IsWin10FCUorNewer() function would have to
be adjusted to also check for a maximum version, so the workaround is then disabled again.
2017-12-10 09:17:33 -08:00
Sam Lantinga
baae74c857 Added SDL_WinRTGetDeviceFamily() to find out what type of device your application is running on (thanks Daniel Knobe!) 2017-12-10 09:10:02 -08:00
Sam Lantinga
c2cc9c166c Backed out using pixel texture coordinates, it had weird visual side effects 2017-12-09 19:48:38 -08:00
Sam Lantinga
8aad49238b Fixed normalized coordinates when the viewport is set 2017-12-09 19:41:08 -08:00
Sam Lantinga
441d309551 Added support for linear sampling and pixel coordinates in the metal renderer 2017-12-09 15:00:41 -08:00
Sam Lantinga
1c43705bab Fixed compiler warning 2017-12-09 13:05:56 -08:00
Sam Lantinga
f55c998891 Fixed pixel positioning and size for the Metal renderer 2017-12-09 12:58:41 -08:00
Ryan C. Gordon
7dac177cd1 metal: fixed render target support. 2017-12-09 03:28:23 -05:00
Ryan C. Gordon
85d12d8f21 metal: Added some comments and FIXMEs. 2017-12-09 03:27:52 -05:00
Ryan C. Gordon
686fc0937e metal: Cleaned up some reference count politics. 2017-12-08 18:26:26 -05:00
Sam Lantinga
cf3d450313 Added SDL_RenderGetMetalLayer() and SDL_RenderGetMetalCommandEncoder() 2017-12-08 14:30:10 -08:00
Sam Lantinga
c403c0fa9a Fixed Metal renderer memory leak 2017-12-08 13:20:20 -08:00
Ryan C. Gordon
81a33985e1 metal: Don't check if Metal is available if targeting modern macOS versions. 2017-12-08 14:03:36 -05:00
Sam Lantinga
b733dcc208 Minor cleanup 2017-12-08 12:02:23 -08:00
Sam Lantinga
5182c23c6b Fixed minor memory leak in the Metal renderer 2017-12-08 11:35:19 -08:00
Sam Lantinga
cac4e31261 Added check for failure of D3D_ActivateRenderer() 2017-12-08 11:34:32 -08:00
Sam Lantinga
127841f315 Fixed compiler warning 2017-12-08 11:33:27 -08:00
Sam Lantinga
1a1cd8c143 Fixed bug 1878 - Scaled texture draws with filtering produce wrapping artifacts.
Yuri K. Schlesner

When using texture filtering, there are filtering artifacts visible on the edges of scaled textures, where the texture filtering pulls in texels from the other side of the texture. Using clamping texture modes wouldn't completely fix this since source rectangles don't need to cover the whole texture. (See screenshot attached in next post.)

The opengl driver uses clamping on textures and so avoid this at least in the cases where the source rect is the whole texture. The direct3d driver does not and so has problems in every case. I'm not sure if it can actually completely be fixed, but at least enabling clamping for direct3d would be one step in the right direction.
2017-12-08 11:09:05 -08:00
Sam Lantinga
dc04f290a3 Defer getting the next drawable until we actually start rendering
This works better for games where there may be a bunch of simulation logic that needs to be run before the next rendering pass, and prevents blocking if the next drawable is busy.
2017-12-08 08:58:02 -08:00
Sam Lantinga
104decd16d Fixed runtime errors on iOS 2017-12-07 18:08:51 -08:00
Sam Lantinga
ba9c336e04 Fixed building for simulators or older iOS SDKs 2017-12-07 17:47:01 -08:00
Sam Lantinga
6deb1e7595 Fixed compiling Metal renderer on iOS 2017-12-07 17:12:03 -08:00
Sam Lantinga
1ae73a2be8 Added iOS and OSX versions of the Metal shaders 2017-12-07 16:08:47 -08:00
Sam Lantinga
b2859af6df Enable building the Metal renderer by default, and weak link the Metal framework so the SDL library is safe to use on older Macs
Also generate iOS versions of the Metal shaders
2017-12-07 16:08:09 -08:00
Ryan C. Gordon
2a2c8d42ca Initial shot at a renderer target for Apple's Metal API.
This isn't complete, but is enough to run testsprite2. It's currently
Mac-only; with a little work to figure out how to properly glue in a Metal
layer to a UIView, this will likely work on iOS, too.

This is only wired up to the configure script right now, and disabled by
default. CMake and Xcode still need their bits filled in as appropriate.
2016-04-21 03:16:44 -04:00
Sam Lantinga
cadf3e44ca The Metal view is a full SDL_uikitview to support multi-touch 2017-12-07 09:35:28 -08:00
Ryan C. Gordon
ef6e629d39 cocoa: Added two missing files from hg changeset da7ba330ec68.
Fixes Bugzilla #3975.
2017-12-06 16:37:55 -05:00
Ryan C. Gordon
351d6d4784 audio: Port WASAPI to WinRT, remove XAudio2 backend.
XAudio2 doesn't have capture support, so WASAPI was to replace it; the holdout
was WinRT, which still needed it as its primary audio target until the WASAPI
code code be made to work.

The support matrix now looks like:

WinXP: directsound by default, winmm as a fallback for buggy drivers.
Vista+: WASAPI (directsound and winmm as fallbacks for debugging).
WinRT: WASAPI
2017-12-06 12:24:32 -05:00
Sam Lantinga
47506fe1de Fixed bug 3974 - Fix SDL_WarpMouseInWindow on both KMSDRM and RaspberryPi drivers
Manuel Alfayate Corchete

This patch fixes SDL_WarpMouseInWindow() in both the KMSDRM and Raspberry Pi graphic backends.
2017-12-04 20:37:01 -08:00
Sam Lantinga
57ebc72714 Fixed bug 3975 - Add GLES2 support for macOS via ANGLE library
Andrey

Seems latest google angle library successfully built & tested under macOS'es.

https://github.com/google/angle

We need to use GLES2 to implement true cross-platform code.
2017-12-04 20:35:01 -08:00
Sam Lantinga
7914725bfc Removed spurious debug output 2017-12-04 20:26:09 -08:00
Olli Kallioinen
5a735da968 Fixed SDL_Log not working on windows if the output is being redirected. 2017-12-04 19:28:03 +02:00
Sam Lantinga
14452e9550 Fixed typos (thanks Martin!) 2017-12-04 20:21:52 -08:00
Sam Lantinga
67950e101e Fixed name of eglCreatePbufferSurface function 2017-12-03 20:27:08 -08:00
Sam Lantinga
e943d1ce5a Fixed bug 3945 - Add eglCreatePbufferSurface function
tomwardio

Proposed patch loads eglCreatePbufferSurface in same manner as other 1.1 functors. This allows custom video drivers to create pbuffer surfaces.
2017-12-03 20:25:55 -08:00
Sam Lantinga
25df5a5ac9 Non-resizable windows need to have their window rect set to the client rect 2017-11-28 18:31:18 -08:00
Sam Lantinga
88e3562ba0 Use the included Khronos headers on Android so we can create Core OpenGL contexts when building with older SDK 2017-11-27 15:07:07 -08:00
Sam Lantinga
8758b7bf15 Fixed bug 3980 - Fix for KMSDRM driver where cursor would not be shown on some gfx hardware because of unsupported cursor size
Manuel Alfayate Corchete

This fixes a problem with KMSDRM on some graphics hardware where only bigger cursor sizes are supported, such as current Intel gfx. (The kernel-side driver is what limits this: had to look for failing IOCTLs...)
That caused SDL_SetCursor() to fail silently, and we were left with a missing cursor without further explanation.
With this patch, different "standard" sizes are tried and a bigger one is used (with an intermediate and clean buffer only used to write the new cursor to the BO where it will live after) if we get, let's say, 16x16 which is pretty common but our hardware does not support that.
2017-11-24 12:03:28 -08:00
Sam Lantinga
5f38b5d705 Fixed bug 3979 - Failed to link with "multiple definition of `scalbln'" error on both MinGW and MinGW-w64 by CMake
Vitaly Novichkov

Once I ran build of my codecs collection on AppVeyor where my CMake script downloads latest SDL2 from HG repo, failed to link because of math functions conflict:

https://ci.appveyor.com/project/Wohlstand/audiocodecs/build/1.0.44
The revision is b9ff5f8b2303

There are both vanilla MinGW and MinGW-w64 are failed to build.


```
[100%] Linking C shared library libSDL2.dll
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingwex.a(scalbn.o):(.text+0x0): multiple definition of `scalbln'
CMakeFiles\SDL2.dir/objects.a(s_scalbn.c.obj):C:/projects/audiocodecs/build-MinGW-Release-Win32/external/SDL2/src/SDL2HG/src/libm/s_scalbn.c:30: first defined here
2017-11-24 03:01:07 -08:00
Sam Lantinga
f776997afc Fixed some compiler warnings 2017-11-21 21:58:27 -08:00
Sam Lantinga
ac4b491b20 Disabled spurious Visual Studio warnings in the uClibc math code 2017-11-21 21:51:33 -08:00
Sam Lantinga
1c0c90323c Fixed bug 3976 - SDL drivers may leak driverdata memory due to ignoring return value of SDL_AddDisplayMode
C Snover

SDL_AddDisplayMode returns an SDL_bool corresponding to whether or not the given display mode was added or not. It will return SDL_FALSE if a matching display mode already exists in the display's list of display modes, which causes ownership of the mode driverdata to remain with the caller. Some video drivers ignore the return value of SDL_AddDisplayMode, so leak the driverdata memory when SDL_AddDisplayMode returns SDL_FALSE.
2017-11-21 21:30:47 -08:00
Ethan Lee
688bc2858a Steam Virtual GamePad config for macOS 2017-11-20 13:59:43 -05:00
Sam Lantinga
3ac8adbae3 Fixed bug 3973 - Include of stdint is needed to build on linux, mingw and possibly android
Stuart Axon

https://discourse.libsdl.org/t/stdint-h-removed/23426

https://discourse.libsdl.org/t/debuild-fails-to-build-the-last-few-days/23429/4

Currently SDL2 is not building in Linux (x86 and ARM), Android and MingW because include stdint.h has been removed from yuv_rgb.h
2017-11-20 00:06:37 -08:00
Sam Lantinga
8fb3885c3c Fixed bug 3964 - YUV to RGB in video/SDL_yuv.c is broken for any output format of type ABGR8888 or BGR888
raist66676

Here is the bug in latest SDL 2.0.8 development repo. It is obvious and simple to fix by correcting typos on six lines of code.

In src/video/SDL_yuv.c on lines 217, 249, 280, 321, 353, and 384 the wrong conversion functions are called for SDL_PIXELFORMAT_ABGR8888 and SDL_PIXELFORMAT_BGR888. Instead of ABGR functions, BGRA functions are called. These are typos.
2017-11-17 11:03:02 -08:00
Sam Lantinga
cd89efb8b9 Fixed building yuv_rgb.h when stdint.h isn't available (thanks Ozkan!) 2017-11-17 10:55:58 -08:00
Sam Lantinga
a6a4e27ae8 Updated SDL's YUV support, many thanks to Adrien Descamps
New functions get and set the YUV colorspace conversion mode:
	SDL_SetYUVConversionMode()
	SDL_GetYUVConversionMode()
	SDL_GetYUVConversionModeForResolution()

SDL_ConvertPixels() converts between all supported RGB and YUV formats, with SSE acceleration for converting from planar YUV formats (YV12, NV12, etc) to common RGB/RGBA formats.

Added a new test program, testyuv, to verify correctness and speed of YUV conversion functionality.
2017-11-12 22:51:12 -08:00
Sam Lantinga
20364769e0 Fixed typo in comment 2017-11-11 17:21:47 -08:00
Alex Szpakowski
5501bcc834 macOS: Fix an OS-generated warning printed to stdout on launch in bundled apps. 2017-11-09 22:24:09 -04:00
Sam Lantinga
fcb77f9848 Back out the following commits which are causing Dota 2 Exclusive Fullscreen to fail on AMD-based Macs. The details of why this is being reverted are at: https://bugzilla.libsdl.org/show_bug.cgi?id=3949
Alex Szpakowski <slime73@gmail.com> 2017-07-12 21:28 -0300
macOS: Expose more display modes on retina screens. Fixes an issue found in BZFlag.
http://hg.libsdl.org/SDL/rev/cfb3ddf796c3

Alex Szpakowski <slime73@gmail.com> 2017-07-12 21:32 -0300
Fix a potential crash in macOS 10.7 and earlier.
http://hg.libsdl.org/SDL/rev/4941c8867075
2017-11-08 14:17:23 -08:00
Brandon Schaefer
9f4e4be8e0 Fixed bug 3943 - General SDL_HINT_VIDEO_DOUBLE_BUFFER hint support 2017-11-07 09:10:32 -08:00
Ryan C. Gordon
5cc46f3d30 mouse: remove assert for unimplemented platforms (thanks, tomwardio!).
Fixes Bugzilla #3946.
2017-11-06 15:29:24 -05:00
Sam Lantinga
c5429bd975 Fixed bug 3939 - Remove static vm_error and vm_event from SDL_x11modes.c
tomwardio

Remove static int vm_error and vm_event, use local variables instead.

This fixes unused variable errors when compiling with SDL_VIDEO_DRIVER_X11_XINERAMA undefined.

src/video/x11/SDL_x11modes.c:505:22: error: unused variable 'vm_error' [-Werror,-Wunused-variable]

src/video/x11/SDL_x11modes.c:505:12: error: unused variable 'vm_event' [-Werror,-Wunused-variable]
2017-11-04 22:06:40 -07:00
Sam Lantinga
50e422adfe Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
Sylvain

What about getting some return code instead of creating another native function.
2017-11-04 22:03:28 -07:00
Sam Lantinga
2c5724ef5d Updated version to 2.0.8 since SDL_image depends on it 2017-11-04 21:58:48 -07:00
Sam Lantinga
34a8cf767c Fixed compiler warnings after uClibc code update 2017-11-04 17:39:28 -07:00
Sam Lantinga
bcdf8b916b Added SDL_fmod() and SDL_fmodf() 2017-11-04 17:35:03 -07:00
Sam Lantinga
6cf065753c Updated math code from the uClibc 0.9.33 release 2017-11-04 15:53:19 -07:00
Sam Lantinga
34502143d9 Added float versions of SDL's math functions 2017-11-04 15:34:14 -07:00
Sam Lantinga
758156a765 Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
We're going to push the manifest environment variables from the Java side instead of continually querying for them from the native side.
2017-11-04 09:37:29 -07:00
Sam Lantinga
7334a2a1b5 Fixed bug 3940 - Add support for EGL_SURFACE_TYPE
tomwardio

Add support to be able to set EGL_SURFACE_TYPE bits when creating an EGL config. This is usefule when wanting to create pixel buffer surfaces in custom video drivers.
2017-11-04 09:07:33 -07:00
Conn O'Griofa
bf3e363d4b Raspberry Pi: fix ES 1/PVR support & autodetect Mesa driver
* The brcmGLESv2 vendor library also supports ES PVR/1 profiles
* Fallback to standard Mesa libraries if the VC4 driver is loaded
2017-11-04 09:04:19 -07:00
Conn O'Griofa
547448df6f SDL_video: try to bootstrap KMSDRM before RPI video driver
Allow better coexistence between RPI's vendor libraries and VC4 mesa driver.
2017-11-04 09:03:20 -07:00
Johannes Bader
1724313349 Emscripten: use cursor hotspot
the cursor's hotspot simply wasn't translated to it's CSS equivalent, yet
see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor?v=example#Syntax. no explicit hotspot if (0|0) for compatibility with Edge and IE, which indeed don't support custom hot spots
2017-11-04 11:16:49 +00:00
Sam Lantinga
c954b53830 Fixed bug 3935 - Not find joysticks if android run 24-48 days.
Alexander Orefkov

In src\joystick\android\SDL_sysjoystick.c in SDL_SYS_JoystickDetect when SDL_GetTicks return number grater 2147483648 (after 24.85 days uptime) SDL_TICKS_PASSED(SDL_GetTicks(), timeout) return FALSE and Android_JNI_PollInputDevices is never calling.
And in JoystickByDeviceId - when search for newly added joystic - after SDL_SYS_JoystickDetect item not reinitilized, and always stay NULL, cause return NULL instead of added joystick.
2017-11-02 08:48:14 -07:00
Sam Lantinga
1475e6984a Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
Sylvain

Some issue with this commit:
https://hg.libsdl.org/SDL/rev/97387a8b88d3

There is a memory allocation missing.
2017-11-01 19:19:21 -07:00
Sam Lantinga
9192c93e90 Fixed bug 3932 - Android, GetDisplayDPI release local reference
Sylvain

When writing JNI code, one has to make sure all local references are released otherwise the app end up crashing.
2017-11-01 17:30:02 -07:00
Sam Lantinga
a7d2d12c64 Fixed building on non-Android platforms 2017-11-01 10:07:04 -07:00
Sam Lantinga
a90be440e8 Added controller mapping for Android TV remotes
Also fixed the back button on the remote exiting the application
2017-11-01 10:06:58 -07:00
Sam Lantinga
4478707b0a Add SDL_GetDisplayDPI implementation on Android. (thanks Rachel!) 2017-10-31 13:49:59 -07:00
David Ludwig
0e032d5860 WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main.
This allows C# UWP applications to use SDL2's SDL_WinRTRunApp function.

Kudos to Ethan Lee (flibitijibibo@flibitijibibo.com) for the patch.  Thanks!
2017-10-24 13:21:11 -04:00
Brandon Schaefer
2ac567b715 Fixed bug 3902 - Add a specific KMSDRM hint for low latency video 2017-10-26 16:37:20 -07:00
Sam Lantinga
213b249094 Added missing keyinfotable.h 2017-10-26 10:42:14 -07:00
Sam Lantinga
8e37bed3b6 android: Fix softkeyboard issue in SDL on Android. 2017-10-26 10:41:38 -07:00
Ryan C. Gordon
9bbf92e3da cocoa: Don't change the NSWindow background color.
Changing the background color causes the titlebar to blend against it on
modern macOS releases, making all SDL windows look wrong by default. This was
set to make the window not flash white before a GL context is ready, but we
can accomplish this in our window's view's drawRect implementation, too.
2017-10-25 18:02:11 -04:00
Sam Lantinga
8fd0c22adc Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
2017-10-24 00:17:07 -07:00
Sven Hesse
b89cac6761 Don't X error in SDL_CreateWindow with unsupported GL attributes 2017-10-22 20:24:58 +02:00
Sam Lantinga
10376eb926 Fixed bug 3901 - Fix vsync-ed pageflips on the KMSDRM video driver
Manuel

I noticed that, at least on Intel GPU hardware, passing SDL_RENDERER_PRESENTVSYNC would result on a static console instead of the program graphics.
That was due to the fact that calling drmModePageFlip() only works if we have previously set up CRTC to one of the GBM buffers with a drmModeSetCrtc() call, so now it's done and things work as expected.

The KMSDRM_GLES_SetupCrtc() call is done only one time, only when needed (when egl_swapinterval is not 0: when it's 0, there's no need for it because we flip by calling drmModePageFlip() anyway).
The place where KMSDRM_GLES_SetupCrtc() call is done may look strange, but it's right: it needs EGL completely ready because it needs to call eglSwapBuffers() internally to work (see more comments about it in the code).
2017-10-21 04:20:57 -07:00
Sam Lantinga
e830ef3458 Fixed typo converting 4 channel audio to 2 channel 2017-10-20 16:53:42 -07:00
Sam Lantinga
9a291c1e59 Added a note about adjusting channel weights when converting to fewer channels 2017-10-20 14:51:22 -07:00
Ryan C. Gordon
729329068b audio: Added SDL_AudioStreamFlush(). 2017-10-19 18:05:42 -04:00
Ryan C. Gordon
e98920f5f3 Check correct variable for malloc() results. 2017-10-18 23:49:46 -04:00
Sam Lantinga
afefcbfeba Fixed bug 3876 - Resampling of certain sounds adds heavy distortion
Simon Hug

Patch that adds [-1, 1] clamping to the scalar audio type conversions.

This may come from the SDL_Convert_F32_to_X_Scalar functions. They don't clamp the float value to [-1, 1] and when they cast it to the target integer it may be too large or too small for the type and get truncated, causing horrible noise.

The attached patch throws clamping in, but I don't know if that's the preferred way to fix this. For x86 (without SSE) the compiler (I tested MSVC) seems to throw a horrible amount of x87 code in it. It's a bit better with SSE, but probably still quite the performance hit. And SSE2 uses a branchless approach with maxss and minss.
2017-10-18 19:30:47 -07:00
Sam Lantinga
653ab5d9c4 Added a staging buffer to the audio stream so that we can accumulate small amounts of data if needed when resampling 2017-10-18 19:26:36 -07:00
Sam Lantinga
80f8464d97 Added audio stream conversion functions:
SDL_NewAudioStream
    SDL_AudioStreamPut
    SDL_AudioStreamGet
    SDL_AudioStreamAvailable
    SDL_AudioStreamClear
    SDL_FreeAudioStream
2017-10-18 15:54:05 -07:00
Sam Lantinga
9fd0d6191c Fixed bug 3821 - Allow SDL_CreateWindow and SDL_CreateRenderer with OpenGL ES 3.0 (GLES3) for Angle (Windows)
Carlos

Angle supports GLES3 but when using these functions (SDL_CreateWindow and SDL_CreateRenderer), defaults again to GLES2.0.

A current workaround (hack) to retrieve a GLES3.0 context with Angle is:

1) set

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

after InitSDL AND after calling SDL_CreateWindow  (before SDL_CreateRenderer)

2) Comment lines 2032-2044 in SDL_render_gles2.c, funtion GLES2_CreateRenderer

    window_flags = SDL_GetWindowFlags(window);
    if (!(window_flags & SDL_WINDOW_OPENGL) ||
        profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) {

        changed_window = SDL_TRUE;
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);

        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
            goto error;
        }
    }

This retrives a GLES3 context as confirmed using glGetString(GL_VERSION). This should be fixed by modifying a few if's.
2017-10-18 08:52:04 -07:00
Sam Lantinga
556a854438 Fixed compiler warning on iOS 2017-10-16 15:22:40 -07:00
Sam Lantinga
e4ef1885d9 Fixed bug 3890 - Incomplete fix for CVE-2017-2888
Felix Geyer

http://hg.libsdl.org/SDL/rev/a31ee4d64ff6 tries to fix CVE-2017-2888.
Unfortunately compilers may optimize the second condition "(size / surface->pitch) != surface->h" away.
See https://bugzilla.redhat.com/show_bug.cgi?id=1500623#c2
I've verified that this is also the case on Debian unstable (gcc 7.2).
2017-10-16 14:57:42 -07:00
Sam Lantinga
8e98bdaa6f Fixed bug 3883 - SDL_assert / SDL_PromptAssertion in TTY mode does not accept options ("abriA")
shoerbaffen

fgets can read a newline and SDL_strcmp will never return zero.
2017-10-15 21:21:19 -07:00
Sam Lantinga
a223560a7f Fixed bug 3880 - X Error upon quit since rev. 11607
Ozkan Sezer

Since changeset 11607:60cd425a2f14, I am getting the following
error upon quit.  Running testsprite2, clicking the mouse, and
quiting it is enough to trigger it.  This is on my old Fedora9
x86-Linux:

X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0xb057340
  Serial number of failed request:  905
  Current serial number in output stream:  906

Reverting  https://hg.libsdl.org/SDL/rev/60cd425a2f14  removes
the error.
2017-10-13 19:30:34 -07:00
Sam Lantinga
cf9236488a Fixed bug 3879 - add missing SDLCALL to SDLTest_TrackedMalloc & co.
Ozkan Sezer

The attached trivial patch adds missing SDLCALL to SDLTest_TrackedMalloc & co.
2017-10-13 09:50:04 -07:00
Ryan C. Gordon
fa15674134 coreaudio: changed device close procedure to prevent long hangs in some cases.
The audioqueue thread needs to keep running, and processing the CFRunLoop
until the AudioQueue is disposed of, otherwise CoreAudio will hang waiting for
final data to feed the device.

At least, I think this is how it all works. It definitely fixes the bug here!

Since AudioQueueDispose() calls AudioQueueStop() internally, there's no need
for our thread to handle this, either, which is good because the AudioQueue
would be disposed by this point. So now the AudioQueue is disposed first, and
then our thread is joined, and everything works out okay.

Just in case, we mark the device "paused" before setting everything in motion,
so any further callbacks from CoreAudio will write silence and not fire the
app's audio callback again.

Fixes Bugzilla #3868.
2017-10-13 01:15:29 -04:00
Sam Lantinga
fc60db86b3 Fixed compiler warning 2017-10-12 17:17:09 -07:00
Sam Lantinga
22b6df511b Use the lower-case hex output to match other stack trace printouts 2017-10-12 14:46:28 -07:00
Sam Lantinga
7079195697 Fixed compiler warning 2017-10-12 14:44:54 -07:00
Sam Lantinga
5fc2017661 Fixed bug 3877 - missing SDLCALL in SDLTest_ExampleHitTestCallback
Ozkan Sezer

Following trivial patch adds missing SDLCALL to SDLTest_ExampleHitTestCallback()
2017-10-12 14:25:07 -07:00
Sam Lantinga
41a60394d0 Added missing file 2017-10-12 14:20:17 -07:00
Sam Lantinga
21cd2df694 Fixed compiler warning 2017-10-12 14:02:24 -07:00
Sam Lantinga
ba10d2b654 Fixed compiler warning 2017-10-12 13:55:35 -07:00
Sam Lantinga
9c580e14c9 Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
    SDL_SetMemoryFunctions()
    SDL_GetNumAllocations()
2017-10-12 13:44:28 -07:00
Sam Lantinga
1887c54c68 Fixed memory leak in Cocoa mouse code
The video quit call cleans up the mouse cursor driver data, which happens after mouse quit
2017-10-12 13:28:48 -07:00
Sam Lantinga
f4f9e39f62 Fixed bug 3874 - Compiler warnings SDL_Surface.c and SDL_cocoakeyboard.m 2017-10-12 08:41:11 -07:00
Sam Lantinga
a7c79c5e25 Normalize touch events to the render viewport (thanks Sylvain!) 2017-10-12 08:37:55 -07:00
Sam Lantinga
5bed4ca92e Fixed divide by zero with a 1x1 sized window 2017-10-12 08:27:22 -07:00
Ozkan Sezer
bef0fec121 make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL. 2017-10-12 14:28:05 +03:00
Sam Lantinga
0ce23a5498 Updated version to 2.0.7 2017-10-12 08:08:04 -07:00
Ethan Lee
84fb4893cf Check SDL_UDEV_DYNAMIC first, then SDL_UDEV_LIBS separately 2017-10-10 20:22:15 -04:00
Sam Lantinga
c0019b7f49 Fixed bug 3871 - Touch events are not normalised on X11
Trent Gamblin

The documentation for SDL_TouchFingerEvent says that the x and y coordinates are normalised between 0-1. I've found that to be true on Windows, Android and iOS but on X11 they are in pixel coordinates. This patch fixes the issue. This was the cleanest way I could do it with what was available without changing things around a lot but you may know a better way.
2017-10-11 13:31:21 -07:00
Sam Lantinga
b53c35df43 Fixed size in realloc 2017-10-11 13:26:58 -07:00
Ryan C. Gordon
5e5f2290f2 audio: Turns out the accumulation errors sound better. :/
Moving to double fixed the overflows, but using "time = i * incr" instead of
"time += incr" causes clicks in the output.
2017-10-11 12:07:43 -04:00
Ryan C. Gordon
9bd2c6b491 audio: Moved the resampler state up to double precision.
Fixes more buffer overflows.
2017-10-11 11:51:14 -04:00
Ryan C. Gordon
b2f5123b65 audio: calculate resampling time directly, don't increment (thanks, Eric!).
Fixes buffer overruns as floating point errors accumulate.

Partially fixes Bugzilla #3848.
2017-10-11 11:43:35 -04:00
Ryan C. Gordon
763c387149 audio: clamp resampler interpolation values to prevent buffer overflow.
Partially fixes Bugzilla #3848.
2017-10-11 02:33:55 -04:00
Ryan C. Gordon
0085f917e0 audio: Moved unchanging variable out of loop. 2017-10-11 02:31:58 -04:00
Ryan C. Gordon
cb8bf6bbaf audio: Make sure audio stream resampling doesn't overflow buffers. 2017-10-11 02:03:05 -04:00
Ryan C. Gordon
459e2b0bbe audio: Fixed check for minimum audio stream put size. 2017-10-11 01:37:11 -04:00
Sam Lantinga
8446d4a05a Changed overlapping memcpy to memmove 2017-10-10 20:11:05 -07:00
Sam Lantinga
eb9e6938cc Fixed potentially calling a callback after it has been removed (and userdata possibly deleted) 2017-10-10 19:44:33 -07:00
Ryan C. Gordon
903ff6414e audio: SDL_ResampleCVT() should use memmove instead of memcpy.
This copy can overlap.

Fixes Bugzilla #3849.
2017-10-10 22:31:02 -04:00
Ryan C. Gordon
42fff7ce2b audio: Don't stack-allocate resampler padding.
(I thought padding size ranged from 5 frames to ~30 frames (based around
RESAMPLER_ZERO_CROSSINGS, which is 5), but it's actually between 512 and
several thousands (based on RESAMPLER_SAMPLES_PER_ZERO_CROSSING)). It gets
big fast when downsampling.
2017-10-10 22:18:46 -04:00
Sam Lantinga
b647bd0692 The event filter and event watch functions are now thread-safe 2017-10-10 17:41:41 -07:00
Ryan C. Gordon
37d89aa10f audio: reworked audio streams to have right-hand resampling padding available.
Fixes Bugzilla #3851.
2017-10-10 16:12:56 -04:00
Ryan C. Gordon
28149e11c8 Added SDL_PeekIntoDataQueue(). 2017-10-10 11:56:54 -04:00
Sam Lantinga
d90fce3c9e Exposed the joystick locking functions for multi-threaded access to the joystick API 2017-10-10 11:10:15 -07:00
Sam Lantinga
2657dfae49 Fixed crash in SDL_IsGameController() on Windows if called when a controller is being removed 2017-10-09 11:45:15 -07:00
Sam Lantinga
b120fb879a Fixed bug 3865 - [PATCH] Support for GreenAsia Inc. PSX to USB converter as SDL_GameController
Manuel

I would like this small patch merged that adds support for my GreenAsia Inc. PSX to USB converter, so SDL_IsGameController() returns true when using this adaptor.
It's interesting because PSX/PS2 controllers connected using this model won't be detected as gamecontrollers otherwise, only as joysticks.
2017-10-08 10:59:03 -07:00
Sam Lantinga
d2a2b0c139 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

There are various YUV-RGB conversion coefficients, according to https://www.fourcc.org/fccyvrgb.php
I choose the first (from Video Demystified, with integer multiplication),
but the current SDL2 Dither functions use in fact the next one, which follows a specifications called CCIR 601.

Here's a patch to use the second ones and with previous warning corrections.
There are less multiplications involved because Chroma coefficient is 1.
Also, doing float multiplication is as efficient with vectorization.
In the end, the YUV decoding is faster: ~165 ms vs my previous 195 ms.

Moreover, if SDL2 is compiled with -march=native, then YUV decoding time drops to ~130ms, while older ones remains around ~220 ms.


For information, from jpeg-9 source code:
jpeg-9/jccolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   * Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
   * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
   * Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE

jpeg-9/jdcolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   *
   * R = Y                + 1.40200 * Cr
   * G = Y - 0.34414 * Cb - 0.71414 * Cr
   * B = Y + 1.77200 * Cb
2017-10-07 15:26:55 -07:00
Sam Lantinga
1bfe6d6026 Fixed restoring window size when coming out of fullscreen desktop mode.
Use the style of the window as it will be, not as it currently is at the
time of the AdjustWindowRect call.
2017-10-06 21:43:59 -07:00
Sam Lantinga
e9652b1987 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

Few issues with YUV on SDL2 when using odd dimensions, and missing conversions from/back to YUV formats.

1) The big part is that SDL_ConvertPixels() does not convert to/from YUV in most cases. This now works with any format and also with odd dimensions,
  by adding two internal functions SDL_ConvertPixels_YUV_to_ARGB8888 and SDL_ConvertPixels_ARGB8888_to_YUV (could it be XRGB888 ?).
  The target format is hard coded to ARGB888 (which is the default in the internal of the software renderer).
  In case of different YUV conversion, it will do an intermediate conversion to a ARGB8888 buffer.

  SDL_ConvertPixels_YUV_to_ARGB8888 is somehow redundant with all the "Color*Dither*Mod*".
  But it allows some completeness of SDL_ConvertPixels to handle all YUV format.
  It also works with odd dimensions.

  Moreover, I did some benchmark(SDL_ConvertPixel vs Color32DitherYV12Mod1X and Color32DitherYUY2Mod1X).
  gcc-6.3 and clang-4.0. gcc performs better than clang. And, with gcc, SDL_ConvertPixels() performs better (20%) than the two C function Color32Dither*().
  For instance, to convert 10 times a 3888x2592 image, it takes ~195 ms with SDL_ConvertPixels and ~235 ms with Color32Dither*().
  Especially because of gcc vectorize feature that optimises all conversion loops (-ftree-loop-vectorize).

  Nb: I put no image pitch for the YUV buffers. because it complexify a little bit the code and the API :
  There would be some ambiguity when setting the pitch exactly to image width:
  would it a be pitch of image width (for luma and chroma). or just contiguous data ? (could set pitch=0 for the later).


2) Small issues with odd dimensions:
  If width "w" is odd, luma plane width is still "w" whereas chroma planes will be "(w + 1)/2". Almost the same for odd h.
  Solution is to strategically substitute "w" by "(w+1)/2" at the good places ...

- In the repository, SDL_ConvertPixels() handles YUV only if yuv source format is exactly the same as YUV destination format.
  It basically does a memcpy of pixels, but it's done incorrectly when width or height is odd (wrong size of chroma planes). This is fixed.

- SDL Renderers don't support odd width/height for YUV textures.
  This is fixed for software, opengl, opengles2. (opengles 1 does not support it and fallback to software rendering).
  This is *not* fixed for D3D and D3D11 ... (and others, psp ?)
  Only *two* Dither function are fixed ... not sure if others are really used.

- This is not possible to create a NV12/NV12 texture with the software renderer, whereas other renderers allow it.
  This is fixed, by using SDL_ConvertPixels underneath.

- It was not possible to SDL_UpdateTexture() of format NV12/NV21 with the software renderer. this is fixed.

Here's also two testcases:
- that do all combination of conversion.
- to test partial UpdateTexture
2017-10-06 16:50:24 -07:00
Sam Lantinga
d9e1036e0f Fixed potential overflow in surface allocation (thanks Yves!) 2017-10-06 16:17:50 -07:00
Sam Lantinga
312da2623a Fixed bug 3854 - arguments to dbus_type_is_basic() were incorrect
Aaron

As of 2.0.6, all of my games are failing with the following error:

process 31778: arguments to dbus_type_is_basic() were incorrect, assertion "dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID" failed in file dbus-signature.c line 322.
This is normally a bug in some application using the D-Bus library.
  D-Bus not built with -rdynamic so unable to print a backtrace

(patch by  Ozkan Sezer)
2017-10-05 09:37:28 -07:00
Brandon Schaefer
db20e71d54 Fixed bug 3855 - Memory leak in SDL_FreeSurface 2017-10-02 10:50:33 -07:00
Brandon Schaefer
e564da78b7 revert files I didnt mean to commit! 2017-09-29 10:15:44 -07:00
Brandon Schaefer
e27f12e0da wayland: Fix bug 3814 -Wmissing-field-initializers 2017-09-29 10:07:37 -07:00
Sam Lantinga
aad58c622c Fixed bug 3852 - SDL_FreeSurface deallocates surface->map even if the surface is not yet freed
Evgeny Kapun

Commit 490bb5b49f11 [1], which was a fix for bug #3790, introduced a new bug: now, calling SDL_FreeSurface(surface) deallocates surface->map even if there are other references to the surface. This is bad, because some functions (such as SDL_ConvertSurface) assume that surface->map is not NULL.
2017-09-29 07:44:30 -07:00
Sam Lantinga
54685787ca Fixed bug 3847 - Hit Test x coordinate wrong on secondary monitor
Robert Turner

SDL_windowsevents.c contains code to retrieve the x and y coordinate for a requested hit test. It does this as follows:

    POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };

LOWORD(lParam) does not correctly mask off high bits that are set if the point is on a second (or third, etc.) monitor. This effectively offsets the x-coordinate by a large value.

MSDN documentation suggests that LOWORD() and HIWORD() are the wrong macros for the task, instead suggesting we should be doing something like the following:

    POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };

Testing this change on my Windows 10 machine with 2 monitors gives the correct results.
2017-09-26 15:07:35 -07:00
Alex Szpakowski
fb071a4cd9 Mac: Fix the menu bar not always working for non-.app-bundled apps. Fixes bug #3051. 2017-09-25 20:49:31 -03:00
Ryan C. Gordon
099ae43e81 audio: Fixed compiler warning on Visual Studio. 2017-09-22 22:28:21 -04:00
Sam Lantinga
58d1c54d06 Fixed spacing 2017-09-22 17:32:05 -07:00
Sam Lantinga
0fea9164eb Added an example for SDL_SetWindowHitTest() when you create a borderless resizable window. 2017-09-22 17:29:32 -07:00
Sam Lantinga
2fd5235145 Added stubs for simple Steam Controller support 2017-09-22 08:32:31 -07:00
Sam Lantinga
d828647944 Added stubs for simple Steam Controller support 2017-09-22 08:30:52 -07:00
Sam Lantinga
53b2c91d26 Separated out SDL Android java code so audio, controller, and filesystem APIs can be used independently of the SDL activity, in Qt apps for example. 2017-09-22 08:30:46 -07:00
Sam Lantinga
ad86eff1a8 Guarded EGL code with SDL_VIDEO_OPENGL_EGL 2017-09-22 08:30:37 -07:00
Sam Lantinga
499f928c33 borderless windows will have WM_NCCALCSIZE return 0 for the non-client area. When this happens, it looks like windows will send a resize message expanding the window client area to the previous window + chrome size, so shouldn't need to adjust the window size for the set styles. 2017-09-22 07:15:41 -07:00
Sam Lantinga
3176a7f5e9 sdl
- Fixing rendering borderless window. Need to force windows to send a WM_NCCALCSIZE then return 0 for non-client area size.

- Adding WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX to borderless windows, for reasons noted in comments.

- Fix SetupWindowData() setting SDL_WINDOW_BORDERLESS. This was being cleared at window creation, causing hanlding for the first WM_NCCALCSIZE message to fail
2017-09-22 07:11:36 -07:00
Sam Lantinga
fe6b8f1c31 Fixed Mac OS X build 2017-09-22 11:25:52 -07:00
Sam Lantinga
407e1693ae Fixed audio being silent on older iOS devices
Tested on an iPod running iOS 6.1
2017-09-22 11:15:14 -07:00
Sam Lantinga
5ab5c9b767 Avoid duplicate joystick axis events 2017-09-22 08:56:09 -07:00
Sam Lantinga
d74c00e67d Fixed memory leak when HAVE_ALLOCA isn't defined 2017-09-22 08:51:45 -07:00
Mark Callow
59d17bdee0 Avoid hitting ERR_MAX_STRLEN limit. 2017-09-22 22:30:02 +09:00
Ryan C. Gordon
6d206a7b28 audio: Stream resampling now saves some samples from previous run for padding.
Previously, the padding was silence, which was a problem when streaming since
you would sample a little bit of this silence between each buffer.

We still need a means to get padding data for the right hand side, but this
patch makes the resampler output more correct.
2017-09-22 07:42:24 -04:00
Brandon Schaefer
466ba57d42 [egl/mir] Need eglGetProc to find gl 4.5 core profile extensions 2017-09-21 18:38:07 -07:00
Alex Szpakowski
e5cfb58f4a iOS MoltenVK code style cleanup. 2017-09-21 20:30:25 -03:00
Sam Lantinga
b3ac0b6fb0 A hint with an empty string should be treated as the default value 2017-09-21 14:48:03 -07:00
Sam Lantinga
eaab6098eb Only apply the jitter filter to prevent unexpected motion on axes that haven't been touched. 2017-09-21 10:29:17 -07:00
Sam Lantinga
5ae90ef67a Fixed bug 3788 - software renderer crashes in SDL_RenderCopyEx with rotation and dstrect w or h is 0
Anthony

This is what's making the software renderer crash with rotated destination rectangles of w or h = 0:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
2017-09-21 01:22:40 -07:00
Sam Lantinga
8b660c5046 Added some missing "extern" declarations 2017-09-21 00:55:29 -07:00
Ryan C. Gordon
f40bd5ee24 audio: removed my perl experiment script. 2017-09-21 02:06:53 -04:00
Ryan C. Gordon
1a3b95a11e audio: Replaced the resampler. Again.
This time it's using real math from a real whitepaper instead of my previous
amateur, fast-but-low-quality attempt. The new resampler does "bandlimited
interpolation," as described here: https://ccrma.stanford.edu/~jos/resample/

The output appears to sound cleaner, especially at high frequencies, and of
course works with non-power-of-two rate conversions.

There are some obvious optimizations to be done to this still, and there is
other fallout: this doesn't resample a buffer in-place, the 2-channels-Sint16
fast path is gone because this resampler does a _lot_ of floating point math.
There is a nasty hack to make it work with SDL_AudioCVT.

It's possible these issues are solvable, but they aren't solved as of yet.
Still, I hope this effort is slouching in the right direction.
2017-09-21 02:51:14 -04:00
Mark Callow
3c45e662f5 macOS: remove unneeded #includes. 2017-09-21 14:01:12 +09:00
Sam Lantinga
f0a324f8eb Reverted Alex's commit 131cba1768a5 - we're about to release 2.0.6, don't remove support for the iOS 7 SDK yet. 2017-09-20 19:59:34 -07:00
Alex Szpakowski
d452b89f9b iOS: I don't think SDL compiles with the iOS 7 SDK anymore, so we might as well drop the #ifdefs trying to guard for that. 2017-09-20 11:01:32 -03:00
Alex Szpakowski
12fb004fba iOS: remove an unused static variable 2017-09-20 10:53:41 -03:00
Sam Lantinga
c08a7a74a5 Added a hint SDL_HINT_AUDIO_CATEGORY to control the audio category,
determining whether the phone mute switch affects the audio
2017-09-15 17:27:32 -07:00
Patrice Mandin
46ec130528 Fix for 3829. Revert adding GameSir G4s, uses same GUID as PS3 controller. 2017-09-14 21:45:14 +02:00
Patrice Mandin
73c85e986c Readd support for GameSir G4s, lost with changeset 11431 2017-09-14 19:33:32 +02:00
Sam Lantinga
cfe72c76e2 Fixed iOS keyboard positioning, based on the final position rather than the initial one 2017-09-14 09:55:27 -07:00
Ryan C. Gordon
76176486ce surface: Make sure SDL_ConvertSurface() deals with palettes (thanks, Sylvain!).
Fixes Bugzilla #3826.
Fixes Bugzilla #2979.
2017-09-14 08:37:27 -04:00
Sam Lantinga
ac782d7122 Added support for the PDP Battlefield One Xbox One controller on Linux 2017-09-12 05:53:47 -07:00
David Ludwig
78b83d3a6d WinRT: build fix when using recent versions of the Windows 10 SDK 2017-09-11 18:20:56 -04:00
Sam Lantinga
e98fc8972d Fixed bug 3812 - Fallthrough warnings gcc-7 2017-09-10 12:54:40 -07:00
Sam Lantinga
5f48ce0b64 Fixed bug 3815 - implicit-fallthrough warning - DUFFS_LOOP4 and friends 2017-09-10 12:49:41 -07:00
Sam Lantinga
19114b0378 Fixed bug 3813 - gcc7 fallthrough warnings in SDL_iconv.c and SDL_pixels.c 2017-09-10 12:42:38 -07:00
Sam Lantinga
849c4c1472 Fixed tabs to spaces 2017-09-10 12:40:45 -07:00
Sam Lantinga
8ed16ea465 Fixed compile warning 2017-09-10 10:43:04 -07:00
Ryan C. Gordon
93583d461c alsa: removed snd_pcm_wait() call before writing to playback device.
This would cause playback problems in certain situations, such as on the
Raspberry Pi. The device that the wait was added for seems to not benefit from
it in modern times, and standard desktop Linux seems to do the right thing
when a USB device is unplugged now, without this patch.

Fixes Bugzilla #3599.
2017-09-09 21:17:46 -04:00
Sam Lantinga
b2ba8963b3 Fixed bug 3809 - Restore after maximize leads to wrong size
Andreas Falkenhahn

My app opens a 640x480 window. When I click on the window's maximize button, the window correctly fills the entire screen and loses its borders. But clicking on the restore button now doesn't restore the window to its original 640x480 size. Instead, the window size is identical to the screen size now. The only difference to the previous state is that the window now has borders again but it isn't restored to 640x480.
2017-09-09 11:00:25 -07:00
Sam Lantinga
676c3a9263 Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

The window is now resized to its specified size, but it moves to the top left corner of the screen. That is unexpected because neither the user nor the program moved it there. Test program attached (the same one as before).
2017-09-09 10:31:44 -07:00
Sam Lantinga
fcd9c19022 Fixed window size when leaving fullscreen mode (thanks Eric!) 2017-09-09 09:31:12 -07:00
Sam Lantinga
f465f24d73 Fixed bug 3760 - RWops doesn't check for integer overflow when stdio_fseek only supports 32 bits
Simon Hug

When RWops seeks with fseek or fseeko it uses the types long or off_t which can be 32 bits on some platforms. stdio_seek does not check if the 64-bit integer for the offset fits into a 32-bit integer. Offsets equal or larger than 2 GiB will have implementation-defined behavior and failure states would be very confusing to debug.

The attached patch adds range checking by using the macros from limits.h for long type and some bit shifting for off_t because POSIX couldn't be bothered to specify min and max macros.

It also defines HAVE_FSEEKI64 in SDL_config_windows.h so that the Windows function gets picked up automatically with the default config.

And there's an additional error message for when ftell fails.
2017-09-09 08:36:37 -07:00
Sam Lantinga
9a73909bbd Fixed bug 3808 - fix a typo in SDL_stretch.c
Ozkan Sezer

The following patch fixes a minor _MSC_VER typo in SDL_stretch.c,
and also does a tiny tidy-up for assembly opcodes cpp checks.
2017-09-09 08:20:56 -07:00
Sam Lantinga
222d25ad4b Fixed bug 3805 - Why is there no --enable-video-rpi option in configure?
Andreas Falkenhahn

When compiling SDL for the Raspberry Pi, I have to use the --host parameter to enable compilation of the native Raspberry Pi video driver, like so:

    --host=arm-raspberry-linux-gnueabihf

It took me a while to figure out that this was necessary in order to have the native Raspberry Pi video driver compiled in. I think it would be better if there was an option like --enable-video-rpi that could be passed to configure and that would also show up when saying configure --help. Currently, it?s rather difficult to figure out that you have to use the --host parameter with arm-raspberry-linux-gnueabihf in order to get Raspberry Pi video support. It?s also somewhat inconsistent because most other video drivers can in fact be enabled/disabled through specific configure parameters but there is no such parameter for the native Raspberry Pi video driver.
2017-09-08 22:21:01 -07:00
Sam Lantinga
e8059221bd Fixed bug 3806 - Fixes for MSVC compiler warnings
Simon Hug

These are the remaining compiler warnings I see in the current tip cb049cae7c3c.

- SDL_test_log.c defines _CRT_SECURE_NO_WARNINGS without checking if it was already set.

- SDL_windowskeyboard.c converts integers to pointers without going over the (U)INT_PTR types. That bothers MSVC.
2017-09-08 18:26:25 -07:00
Sam Lantinga
0ddac338b0 keep joystick thread from waking unnecessarily, and from possibly blocking for 300ms at shutdown if a joystick was just plugged in
CR: SamL
2017-09-08 07:15:47 -07:00
Sam Lantinga
1b2492ed8a Fixed 64-bit build warning 2017-09-08 15:08:03 -07:00
Sam Lantinga
4657d9f33c We don't need to pass the renderer into SDLTest_CleanupTextDrawing() 2017-09-08 04:53:31 -07:00
Sam Lantinga
65c55fdd84 Fixed build 2017-09-08 04:38:46 -07:00
Sam Lantinga
b0b3da7702 Added a function to clean up test text drawing 2017-09-08 04:14:05 -07:00
Ryan C. Gordon
ca15c7d67f wave: SDL_LoadWAV now supports 24-bit audio. 2017-09-07 10:56:08 -04:00
Ryan C. Gordon
fb28393200 vulkan: use "unsigned int" instead of "unsigned" 2017-09-06 19:35:36 -04:00
Ryan C. Gordon
0c892abcd0 raspberrypi: The latest Raspbian moved its EGL and GLES2 libs elsewhere.
Now we try the new (hardware-specific) pathnames first, and if those fail to
load, we'll try the more generic names that earlier versions of Raspbian used.

Fixes Bugzilla #3800.
2017-09-06 19:34:23 -04:00
Sam Lantinga
fa0eeff7f5 sdl:
Cleans up AdjustWindowEx calls
2017-09-06 07:29:34 -07:00
Sam Lantinga
20c5bc9135 You can have a borderless resizable window 2017-09-06 05:23:26 -07:00
Sam Lantinga
4ca5d8622a Fixed bug 3780 - GCC 7 implicit fallthrough warnings
Martin Gerhardy 2017-08-28 06:58:01 UTC

SDL_blit.h, SDL_fillrect.c and SDL_stdinc.h produces a lot of the (new) gcc-7 implicit fallthrough warnings.
2017-09-06 04:32:30 -07:00
Sam Lantinga
c8e3e0c414 Fixed bug 3799 - SDL_CreateWindow fails with SDL_WINDOW_VULKAN (libvulkan.so.1 not found)
Manuel Sabogal

Android NDK defines Vulkan as libvulkan.so, not libvulkan.so.1. This is causing the program to not being able to create a window using SDL_WINDOW_VULKAN.

To fix this issue just change the line http://hg.libsdl.org/SDL/file/bbaec41e93b5/src/video/android/SDL_androidvulkan.c#l53 from "libvulkan.so.1" to "libvulkan.so"
2017-09-06 01:10:10 -07:00
Ryan C. Gordon
c9e73c3e00 x11: make sure SDL_GetGlobalMouseState notices mouse warping through SDL APIs. 2017-09-05 16:15:54 -04:00
Sam Lantinga
0782f9be51 Fixed bug 3273 - Fix for slow video subsystem initialization when using XRandR.
Mart?n Golini

I'm having a very slow initialization of the video subsystem that locks the window creation for about 500 ms ( tested in at least 4 different systems ). What i found is that X11_InitModes_XRandR is using XRRGetScreenResources, that explicitly ask to poll the hardware for changes. This is not really necessary since if the data is already available you can use XRRGetScreenResourcesCurrent.
I attached a tentative patch that fix this issue. With the patch there's no lock when the subsystem is initialized and the window creation is instant in my applications. The patch only uses XRRGetScreenResourcesCurrent in X11_InitModes_XRandR but it could be potentially used in X11_GetDisplayModes and X11_SetDisplayMode.
2017-09-05 08:24:38 -07:00
Sam Lantinga
c1fd0fbb32 Fixed compiler warning with mingw-w64 2017-09-04 22:14:57 -07:00
Sam Lantinga
67f9348baa Fixed bug 3790 - Memory leak with surfaces blitting on each other
bastien.bouclet

When creating two surfaces and blitting them onto the other, SDL's internal reference counting fails, and one of the surfaces is not freed when calling SDL_FreeSurface.

Example code :

SDL_Surface *s1 = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 32, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface *s2 = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 32, SDL_PIXELFORMAT_ARGB8888);

SDL_BlitSurface(s1, NULL, s2, NULL);
SDL_BlitSurface(s2, NULL, s1, NULL);

SDL_FreeSurface(s2);
SDL_FreeSurface(s1);

With this example, s1 is not freed after calling SDL_FreeSurface, its refcount attribute is still positive.
2017-09-04 11:46:14 -07:00
David Ludwig
532446a6bd macOS: bug-fix for #3793, "fullscreen toggle does not maintain SDL_Renderer's logical size"
This also seems to fix the follow-up issue in bug #3719, whereby the initial fix caused the SDL window to move, after transitioning from fullscreen to windowed-mode
2017-09-03 17:33:49 -04:00
Ryan C. Gordon
167398b363 video: Let video targets optionally decide their default OpenGL configs.
This is necessary because the Raspberry Pi is a strange beast, that believes
it has OpenGL support (through glX?) but generally has GLES2 support.

So when using the raspberry video target, we need to force this to default
to a GLES2 context, or by default SDL_CreateWindow() will fail, deep down
when it tries to load the proper GL library.

Fixes testsprite2 (and basically everything else that wasn't testgles2) when
run on a Raspberry Pi without a X server.

Please note that other targets might also need this filled in, the Raspberry
Pi is just the most prominent and readily-available System-On-A-Chip style
thing on my desk.  :)
2017-09-02 19:35:32 -04:00
Ryan C. Gordon
3267398d15 sndio: Patched to compile if SIO_DEVANY isn't defined.
(It isn't in whatever Raspbian is currently shipping.)
2017-09-02 16:41:14 -04:00
Sam Lantinga
c26946e9f2 Fixed bug 3792 - [KMS/DRM] Wrong GBM format
Romain Tisserand

Using KMS/DRM driver from WIP SDL2.0.6 on Linux/ARM SoC RockChip RK3328 (ARM Mali 450 MP2 GPU).

The current code is using GBM_BO_FORMAT_XRGB8888 as GBM buffer format specifier.

The Mali driver (it has been confirmed some other vendor implementations too) expects GBM_FORMAT_XRGB8888.

The Mesa implementation is actually handling both values as the same, but it's not implemented like this into every gbm.h vendor header.

https://github.com/ideak/mesa/blob/master/src/gbm/backends/dri/gbm_dri.c

So with stock SDL2 on my card (Mali vendor implementation), it does not work, eglCreateWindowSurface fails, and gbm_is_format_supported fails too (with the BO variant).
It runs fine with GBM_FORMAT_XRGB8888.

Here is a link of the gbm.h from Mali user-space driver :

https://github.com/rockchip-linux/libmali/blob/rockchip/include/gbm.h
2017-09-01 12:54:38 -07:00
Ryan C. Gordon
74043994b8 x11: Correctly restore previous GL context after sacrificial context is done. 2017-09-01 14:08:09 -04:00
Ryan C. Gordon
a3dda100f4 x11: don't try to make a NULL GL context current when we already did that. 2017-09-01 14:00:11 -04:00
Ryan C. Gordon
4649ac463c x11: Clean up sacrificial GL context code.
Check for failures, restore any previously-current context.
2017-09-01 13:57:40 -04:00
Ryan C. Gordon
507659c6ac x11: Make a sacrificial glX context to check for extensions during init.
This is necessary because we need to see if GLES compat extensions exist.

All of this code (including ShouldUseTextureFramebuffer()) should be
revisited after 2.0.6 ships; ideally we don't make throwaway contexts if
we can avoid it...but maybe we can't. I hear Vulkan is pretty cool.

Fixes Bugzilla #3725.
2017-09-01 13:27:53 -04:00
Alex Szpakowski
20207abf80 macOS: Update controller mapping of Steelseries Stratus XL to account for reversed thumbstick y-axis values (bug #3483). 2017-08-31 22:07:28 -03:00
Alex Szpakowski
d7ae313134 macOS: Fix menubar items being enabled when they shouldn't be. 2017-08-31 21:34:29 -03:00
Alex Szpakowski
b959be2569 Code style cleanup in the Cocoa and UIKit vulkan files. 2017-08-31 21:26:13 -03:00
Alex Szpakowski
cfd7a7fac6 macOS: Prevent unwanted native fullscreen (Spaces) toggles when the window is in fullscreen or isn't resizable. Fixes bug #3691. 2017-08-31 21:13:32 -03:00
Sam Lantinga
b54bcb34d0 Fixed bug 3483 - Steelseries Nimbus MFi controller reversed Y-axis analog stick
benjamin.feng

Probable underlying cause: https://bugzilla.libsdl.org/show_bug.cgi?id=3124#c5

"If you download and build the HID Calibrator sample you can see that these are totally legitimate HID devices (except for inverting the Y-axis of joysticks, which is contrary to the HID specification but does make them more compatible with games compiled expecting XBOX controllers)."
2017-08-30 23:30:24 -07:00
Sam Lantinga
8e160a34a7 Convert tabs to spaces in game controller database entries 2017-08-30 23:02:39 -07:00
Sam Lantinga
9ca6292372 Added some missing render capability flags 2017-08-29 23:14:39 -07:00
Sam Lantinga
c3d428d402 Fixed line breaks in verbose test logging output 2017-08-29 23:12:26 -07:00
Sam Lantinga
94e0f3e95b Added some debug messaging for previously unhandled events 2017-08-29 22:52:17 -07:00
Sam Lantinga
2d10a3f2b9 The dummy video driver check is now covered by explicitly checking for cocoa above. 2017-08-29 22:24:59 -07:00
Sam Lantinga
92bf608527 Fixed bug 3616 - SDL_GL_CreateContext fails with SDL_GL_CONTEXT_DEBUG_FLAG and ANGLE/GLES 2.0
Colin Barrett

Using the pre-built x86 devel libs from here:
https://www.libsdl.org/release/SDL2-devel-2.0.5-VC.zip

If I have:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);

and I'm using ANGLE/(a GL driver that doesn't provide an ES2 context) such that SDL_EGL_CreateContext is called by SDL_GL_CreateContext, I get the error "Could not create EGL context (context attributes are not supported)" and no context is created.

Looking at the code in SDL_EGL_CreateContext - if gl_config.flags is non-zero, it looks like the code in the section guarded with "#ifdef EGL_KHR_create_context" should be executed - but it apparently isn't.

Is it possible this section hasn't been compiled into the pre-built libraries? If I build SDL2.dll myself using the Visual C++ solution (VS2015 Community Update 3) then the call succeeds as I expect
2017-08-29 22:04:43 -07:00
Sam Lantinga
8fc1fb0805 Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

When exiting a "fullscreen space" on OS X, windows don't go to their defined "windowed mode size", but go back to their previous size.

Steps to reproduce:
1. Create a windowed mode SDL window
2. Toggle it to fullscreen with the SDL_WINDOW_FULLSCREEN_DESKTOP flag
3. While in fullscreen, change the windowed mode size using SDL_SetWindowSize
4. Toggle the window back to windowed mode

Expected result:
- The window has the size specified during step 3.

Actual result:
- The window has the size specified when creating the window in step 1.

Attached is a minimal reproduction test case.
The attached test case works as expected on X11 and Windows.
2017-08-29 21:42:22 -07:00
Ryan C. Gordon
21e32bac10 egl: Cast to size_t, in case platform's NativeDisplayType isn't a pointer.
(fixes compiler warnings on QNX.)
2017-08-29 16:30:49 -04:00
Ryan C. Gordon
ae667da638 Fixed a bunch of compiler warnings. 2017-08-29 15:52:49 -04:00
Sam Lantinga
130138fa59 Fixed bug 3785 - fix windows build after revision 11382
Ozkan Sezer

fix windows build after revision 11382: commit 2026e42e377a renamed
_SDL_msctf_h to SDL_msctf_h_ . SDL_windowskeyboard.c relies on that
macro, so update it accordingly.
2017-08-28 22:44:48 -07:00
Sam Lantinga
8ac85744cd Fixed Vulkan configure check for Android and added one for Mac OS X 2017-08-28 22:36:45 -07:00
Sam Lantinga
90b38a5d61 Fixed bug 3786 - building against a Mac OS X SDK < 10.11 fails since the vulkan merge
Ozkan Sezer

Since the Vulkan merge, building against a Mac OS X SDM older than
10.11 fails in SDL_cocoametalview.m because Metal.framework is not
present. There is no conditional compiling in SDL_cocoametalview.m
either, so --disable-video-vulkan doesn't help with anything. (The
configury doesn't check darwin for x86_64 either, but it's another
story.)

I cross-build against 10.8 SDK on linux using clang-3.4.2 and this
is a problem for me.  Will this be fixed?
2017-08-28 22:13:45 -07:00
Sam Lantinga
d619d88560 Fixed bug 3662 - Error message when using the audio conversion setup without an initialized audio subsystem is a bit vague
Simon Hug

This issue actually raises the question if this API change (requirement of initialized audio subsystem) is breaking backwards compatibility. I don't see the documentation saying it is needed in 2.0.5.
2017-08-28 21:42:39 -07:00
Ryan C. Gordon
b128e8802d audio: A whole bunch of improvements to audio conversion (thanks, Solra!).
"Major changes, roughly in order of appearance:

- Use float math everywhere, instead of promoting to double and casting back
all the time.
- Conserve sound energy when downmixing any channel into two other channels.
- Add a QuadToStereo filter. (The previous technique of reusing StereoToMono
never worked, since it assumed an incorrect channel layout for 4.0.)
- Add a 71to51 filter. This removes just under half of the cases the previous
code would silently break in.
- Add a QuadTo51 filter. More silent breakage fixed.
- Add a 51to71 filter, removing another almost-half of the silently broken
cases.
- Add 8 to the list of values SDL_SupportedChannelCount will accept.
- Change SDL_BuildAudioCVT's channel-related logic to handle every case, and
to actually fail if it fails instead of silently corrupting sound data and/or
crashing down the road."

(Note that SDL doesn't otherwise support 7.1 audio yet, but hopefully it will
soon and the 7.1 converters are an important piece of that.  --ryan.)

Fixes Bugzilla #3727.
2017-08-29 00:41:45 -04:00
Ryan C. Gordon
620f5342b5 stdlib: An implementation of SDL_scalbn using ldexp() (thanks, Ozkan!).
Fixes Bugzilla #3767.
2017-08-29 00:36:17 -04:00
Ryan C. Gordon
a0cd7d6bce audio: Converting audio samples from int to float was using wrong equation.
Fixes Bugzilla #3775.
2017-08-29 00:02:04 -04:00
Sam Lantinga
1067b528d3 Fixed building with an older Mac OS X SDK 2017-08-28 20:52:05 -07:00
Sam Lantinga
aa85436ec7 Fixed compile warning 2017-08-28 14:45:19 -07:00
Sam Lantinga
da84c3bf6e Added a log message for nativeRunMain() 2017-08-28 14:44:21 -07:00
Sam Lantinga
dbb0a2aa74 Removed the need for libSDL2main.a on Android, and separated JNI initialization out for other integrations 2017-08-28 14:34:15 -07:00
Sam Lantinga
9341589925 Removed unneeded Vulkan symbol definitions 2017-08-28 13:40:32 -07:00
Sam Lantinga
2a945b44cb Fixed bug 2361 - [Android] Joysticks do not have unique IDs
David Brady

When I attempted to make a mapping file for Android gamepads, I quickly discovered that most of the ones that I have here show up as the same device (Broadcom Bluetooth HID), meaning that it was impossible to make mappings on Android, since every device looked the same.

This patch will check for the existence of the getDescriptor function added in Jelly Bean, and use it if it's there.  The Android Dashboard says that the majority of Android phones should support this function, and doing it this way will not force us to bump up our API version.
2017-08-28 10:03:39 -07:00
Sam Lantinga
0560544d1c Fixed 3783 - Default libGL path for directFB on Linux differs from x11 path
Clayton Craft

The default path used by directfb for libGL is different than the default path used by x11 in SDL2:

./src/video/directfb/SDL_DirectFB_opengl.c:
path = "libGL.so";

./src/video/x11/SDL_x11opengl.c:
#define DEFAULT_OPENGL  "libGL.so.1"

On at least one distro (Alpine Linux), libGL.so is not created (or more accurately the symlink to libGL.so.1 is not created). For consistency, the 'path' variable in SDL_DirectFB_opengl.c should patch the DEFAULT_OPENGL in SDL_x11opengl.c ("libGL.so.1")
2017-08-28 09:51:25 -07:00
Sam Lantinga
959ae9019d Instantiate the CAMetalLayer so SDL_Vulkan_CreateSurface() doesn't fail
Error message was:
[mvk-info] MoltenVK version 0.18.2. Vulkan version 1.0.51.
[***MoltenVK ERROR***] VK_ERROR_INITIALIZATION_FAILED: On-screen rendering requires a view that is backed by a layer of type CAMetalLayer.
2017-08-28 02:17:29.579 testvulkan[95627:1716939] ERROR: SDL_Vulkan_CreateSurface(): vkCreateMacOSSurfaceMVK failed: VK_ERROR_INITIALIZATION_FAILED
2017-08-28 02:30:41 -07:00
Sam Lantinga
6dd3f55d55 Fixed WinRT build after changing the header guard preprocessor symbol 2017-08-28 01:59:53 -07:00
Sam Lantinga
ff8d2e1493 Fixed build when Wayland is dynamically loaded 2017-08-28 01:42:18 -07:00
Sam Lantinga
edaa0ef53f Fixed analyzer warning "Call to 'calloc' has an allocation size of 0 bytes" 2017-08-28 00:54:02 -07:00
Sam Lantinga
3c7f9d692a Fixed redefinition of typedef warnings and errors on BSD 2017-08-28 00:51:14 -07:00
Sam Lantinga
50efbda736 Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h 2017-08-28 00:43:14 -07:00
Sam Lantinga
0d011ec66d Renaming of guard header names to quiet -Wreserved-id-macro 2017-08-28 00:22:23 -07:00
Sam Lantinga
ce2b16445e Be clear that disabling Vulkan surface support disables the entire SDL Vulkan integration 2017-08-28 00:11:38 -07:00
Sam Lantinga
5cd1a95910 Fixed Android build with Vulkan support 2017-08-27 23:53:09 -07:00
Sam Lantinga
0cebef607b Fixed code style for new Vulkan API functions 2017-08-27 23:39:55 -07:00
Sam Lantinga
37ce9f2773 Fixed typedef redefinition errors when including both SDL_vulkan.h and vulkan.h
You should always include vulkan/vulkan.h first, then include SDL_vulkan.h
2017-08-27 23:13:15 -07:00
Sam Lantinga
9da4717d12 Fixed Windows warning 2017-08-27 22:36:03 -07:00
Sam Lantinga
82ffabc86a Fixed Android build 2017-08-27 22:34:15 -07:00
Sam Lantinga
ded5b3a4b4 Fixed crash at shutdown if the window couldn't be created 2017-08-27 21:05:18 -07:00
Sam Lantinga
eb5392ad61 Added the new Vulkan API functions to exported functions 2017-08-27 20:41:29 -07:00
Ryan C. Gordon
c722e58d1f vulkan: Include a copy of vulkan.h and vk_platform.h.
Now we can provide Vulkan support in the build even if the build box doesn't
have a Vulkan SDK, since we dynamically link to the library anyhow.
2017-08-27 23:25:12 -04:00
Ryan C. Gordon
25e3a1ec90 vulkan: Initial Vulkan support!
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
2017-08-27 22:15:57 -04:00
Sam Lantinga
8e7998e19d Fixed bug 3710 - SDL_OpenAudio(desired, obtained) doesn't update desired's size when obtained is NULL
David Ludwig

I've created a new set of patches.  I am happy to create more, if it would help.

One version only copies 'size'.

A second version copies both 'size' and 'silence'.  When looking over the documentation for SDL_OpenAudio in SDL_audio.h, it mentioned that both 'size' and 'silence' were things that SDL_OpenAudio would calculate.

Regarding *both* patches, I did notice that SDL 1.2 appears to have always modified desired's size and silence fields.  The SDL wiki, at https://wiki.libsdl.org/SDL_OpenAudio#Remarks , does note:
2017-08-27 19:10:30 -07:00
Sam Lantinga
003d491f86 Fixed bug 3724 - Allow Angle Static Link
Carlos

We would like to add a switch (define) that allows us to compile Angle statically with SDL. That is, getting rid of the OpenGL DLL. Usually you need OpenGL to be loaded dynamically as DLL because implementation is provided by the system but no need with Angle.

Only 2 files need modification and it shouldn't affect current behaivor:
include/SDL_egl.h and src/video/SDL_egl.c, as in here

https://github.com/native-toolkit/sdl/pull/10/files

The flag name could be SDL_VIDEO_STATIC_ANGLE (instead of NATIVE_TOOLKIT_STATIC_ANGLE) as discussed here https://github.com/native-toolkit/sdl/pull/10

We have tested this with both Windows and UWP, using NME engine (https://github.com/haxenme/nme).

Releated issue: https://bugzilla.libsdl.org/show_bug.cgi?id=1820
2017-08-27 19:05:57 -07:00
Sam Lantinga
b7c5d15152 SDL_dynapi.c: add missing SDLCALL to macros. 2017-08-27 18:53:30 -07:00
Sam Lantinga
a38f127e88 Swapped conditional arguments for standard SDL readability 2017-08-27 18:52:43 -07:00
Sam Lantinga
30fe9a6799 SDL_dynapi.h: revert commit ee88fe3e353e in order to enable dynapi
[ optional ]
2017-08-27 18:49:36 -07:00
Sam Lantinga
50d3fe21aa SDL_dynapi_procs.h: adjust SDL_CreateThread for os/2 2017-08-27 18:49:11 -07:00
Sam Lantinga
fe21a74763 Fixed bug 2266 - please add notifications for clipboard updates on Android
Sylvain

Hi! here's a patch for that with two class loaded regarding API level.
Test both case : before API 11 and after.

I also remove now unused GetSystemServiceFromUIThread() and minor clean-up (haptic warning prototype).
2017-08-27 18:43:52 -07:00
Patrice Mandin
bbd9acdddb Add support for GameSir G4s 2017-08-26 21:20:20 +02:00
Ryan C. Gordon
73f866cf0a windows: Attempt to make Visual Studio not hardcode a call to memset(). 2017-08-25 15:16:39 -04:00
Ryan C. Gordon
e58c7920bf x11: Patched to compile with DEBUG_XEVENTS defined. 2017-08-25 12:51:42 -04:00
Ryan C. Gordon
8c39d1d0b5 OS/2: fixed inverted logic bug (thanks, Ozkan!). 2017-08-25 12:27:18 -04:00
Ryan C. Gordon
2213077a95 OS/2: proper fix for dynapi (thanks, Ozkan!). 2017-08-25 11:31:12 -04:00
Ethan Lee
685890a229 Fix KHR_no_error support 2017-08-24 22:57:42 -04:00
Ryan C. Gordon
d8fc70ea1e opengl: add support for GL_KHR_no_error.
This is completely untested!

Fixes Bugzilla #3721.
2017-08-24 21:30:53 -04:00
Ryan C. Gordon
a3890ff6d7 dynapi: fill in OS/2 loading code (thanks, Ozkan!).
Partially fixes Bugzilla #3765.
2017-08-22 15:50:39 -04:00
Brandon Schaefer
17453d495a x11: Move screen_w/h inside the only ifdef they are referenced in to avoid compiler warnings 2017-08-21 23:44:46 -07:00
Brandon Schaefer
a6dc4ed568 kmsdrm: Remove moved file 2017-08-21 17:22:00 -07:00
Brandon Schaefer
1171718473 kmsdrm: Cleanup unused headers, rename SDL_kmsdrmevents_c.h -> SDL_kmsdrmevents.h 2017-08-21 17:20:50 -07:00
Sam Lantinga
fcf83e7908 Fixed bug 3768 - provide a quick copysign() solution for watcom
Ozkan Sezer

The following patch provides a quick copysign solution for Watcom/x86
2017-08-21 16:30:24 -07:00
Sam Lantinga
f6ad070b82 SDL_dynapi.h: disable dynapi for os/2. 2017-08-21 13:00:58 -07:00
Sam Lantinga
b821ded96c SDL_cpuinfo.c: add os/2 support to SDL_GetCPUCount() and SDL_GetSystemRAM(). 2017-08-21 13:00:40 -07:00
Sam Lantinga
834ab350e5 Fixed bug 3644 - Wayland touch event support
Moritz Bitsch

Attached is a small patch which enables multitouch events on Wayland.
2017-08-21 11:19:38 -07:00
Ryan C. Gordon
f5a38f234b x11: specify event mask for buttons when grabbing pointer (thanks, Stas!).
This fixes a strange corner case (notes appended below), and should be
safe to do anyhow.

Fixes Bugzilla #3674.

"I did more tests.
It appears the bug only happens if there is
another window on the screen that has "always
on top" property. For me it is xawtv - it is
always opened in a screen corner. Closing
xawtv or removing "always on top" property
from it makes the problem to go away.
Plus, it doesn't appear like the buttons are
not delivered at all. It appears that instead
the button presses are delivered on some mouse
positions, but not delivered when you move the
mouse to other part of the window... So this is
really weird and is likely somewhere deep in the
Xorg.
Maybe somehow it happens that the cursor is
actually above the xawtv window, but, because
my app uses grab, it is not visible there, and
in that case the events are not delivered to
my app?
But with my patch the button events are
always delivered flawlessly, it seems.

Hmm, and that indeed seems to explain my problem:
if the mask is set properly and my app uses
grab, then, even if the mouse is above some
other window, the events would still be delivered
to the grabbing app, which is what actually wanted
because my app uses relative mouse mode, so it
doesn't know the pointer can cross some other window
(my app draws the pointer itself).
So my current theory is that my patch only enforces
the mouse grab, which otherwise can be tricked by
some other window preventing the button events
delivery (but motion events are still delivered
via xinput2, which makes it all look very obscure)."
2017-08-21 00:42:06 -04:00
Ryan C. Gordon
5574b43376 x11: Pass generic XEvents by pointer instead of copying to stack for XInput2. 2017-07-31 12:22:18 -04:00
Ryan C. Gordon
01e0d8fc85 opengl: Add support for [GLX|WGL]_ARB_create_context_robustness.
This patch was originally written by Marc Di Luzio for glX and enhanced by
Maximilian Malek for WGL, etc. Thanks to both of you!

Fixes Bugzilla #3643.
Fixes Bugzilla #3735.
2017-08-19 15:02:03 -04:00
Sam Lantinga
30d554e3d6 Fixed building SDL applications with Visual Studio and the clang toolset
Also fixed building 64-bit SDL with clang. 32-bit doesn't build because of the inline assembly for C runtime support.
2017-08-19 03:07:44 -07:00
Alex Szpakowski
3d0f521be5 iOS 10: Work around screen bounds orientation bug. Fixes bugs #3465 and #3505. 2017-08-18 23:23:30 -03:00
Sam Lantinga
2dc5d32fab Updated version to 2.0.6 2017-08-18 18:16:37 -07:00
Sam Lantinga
bcf0e07107 Added WASAPI audio target to autoconf build process 2017-08-18 17:29:44 -07:00
Ryan C. Gordon
e3e6b4fd35 audio: better docs on conversion APIs, error if not init'd (thanks, Simon!).
Fixes Bugzilla #3662.
2017-08-18 16:52:19 -04:00
Ozkan Sezer
500378eb52 Add atomics for Watcom/x86 as inline asm
Partially fixes Bugzilla #3758.
2017-08-18 16:35:55 -04:00
Ozkan Sezer
c68d3ab785 Watcom supports __FUNCTION__ identifier (and surely not __PRETTY_FUNCTION__)
Partially fixes Bugzilla #3758.
2017-08-17 21:35:46 -04:00
Ryan C. Gordon
7a9b9e05e0 SDL_mouse.c doesn't need default_cursor.h. 2017-08-17 20:47:16 -04:00
Ryan C. Gordon
00905c98be filesystem: Patched to compile on QNX. 2017-08-17 03:22:44 -04:00
Ryan C. Gordon
e50d3cdf8e filesystem: QNX should use SDL_LoadFile() instead of rolling it from scratch. 2017-08-17 02:58:46 -04:00
Ryan C. Gordon
c13c45c7be qnx: Implemented SDL_GetBasePath(). 2017-08-17 01:25:48 -04:00
Ryan C. Gordon
adecda5080 cpuinfo: Add SDL_HasNEON() support for ARM-based QNX. 2017-08-16 21:31:03 -04:00
Alex Szpakowski
a0a09f646c Improve iOS keyboard demo code a bit. 2017-08-15 22:53:57 -03:00
Alex Szpakowski
2e4248ed44 Address a compiler warning. 2017-08-15 18:29:47 -03:00
Ryan C. Gordon
c7b4f2b92e rwops: Fixed 64-bit file i/o on QNX. 2017-08-15 16:30:26 -04:00
Sam Lantinga
e83764a5e0 Fixed bug 2137 - SDL Message Boxes don't cope with fixed width fonts (in windows at least)
Pegasus Epsilon

With the system dialog font set to Arial or Tahoma or another variable-width font, everything works just as expected. When using a fixed-width font, like Courier or DejaVu Sans Mono, the text gets cut off. Example screenshots attached.
2017-08-14 23:45:06 -07:00
Sam Lantinga
1d0584d558 Hopefully fixed Wayland build 2017-08-14 21:35:16 -07:00
Sam Lantinga
a4cfa93670 Fixed bug 2293 - Precise scrolling events
Martijn Courteaux

I implemented precise scrolling events. I have been through all the folders in /src/video/[platform] to implement where possible. This works on OS X, but I can't speak for others. Build farm will figure that out, I guess. I think this patch should introduce precise scrolling on OS X, Wayland, Mir, Windows, Android, Nacl, Windows RT.

The way I provide precise scrolling events is by adding two float fields to the SDL_MouseWheelScrollEvent datastructure, called "preciseX" and "preciseY". The old integer fields "x" and "y" are still present. The idea is that every platform specific code normalises the scroll amounts and forwards them to the SDL_SendMouseWheel function. It is this function that will now accumulate these (using a static variable, as I have seen how it was implemented in the Windows specific code) and once we hit a unit size, set the traditional integer "x" and "y" fields.

I believe this is pretty solid way of doing it, although I'm not the expert here.

There is also a fix in the patch for a typo recently introduced, that might need to be taken away by the time anybody merges this in. There is also a file in Nacl which I have stripped a horrible amount of trailing whitespaces. (Leave that part out if you want).
2017-08-14 21:28:04 -07:00
Sam Lantinga
72b195d27c Fixed Android build warning 2017-08-14 20:45:14 -07:00
Sam Lantinga
04e76499ea Fixed build warning 2017-08-14 20:37:07 -07:00
Sam Lantinga
e086a1c183 Added missing files from the previous commit 2017-08-14 20:25:53 -07:00
Sam Lantinga
fb835f9e3b Fixed bug 2330 - Debian bug report: SDL2 X11 driver buffer overflow with large X11 file descriptor
manuel.montezelo

Original bug report (note that it was against 2.0.0, it might have been fixed in between):  http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=733015

--------------------------------------------------------
Package: libsdl2-2.0-0
Version: 2.0.0+dfsg1-3
Severity: normal
Tags: patch

I have occasional crashes here caused by the X11 backend of SDL2. It seems to
be caused by the X11_Pending function trying to add a high number (> 1024)
file descriptor to a fd_set before doing a select on it to avoid busy waiting
on X11 events. This causes a buffer overflow because the file descriptor is
larger (or equal) than the limit FD_SETSIZE.

Attached is a possible workaround patch.

Please also keep in mind that fd_set are also used in following files which
may have similar problems.

src/audio/bsd/SDL_bsdaudio.c
src/audio/paudio/SDL_paudio.c
src/audio/qsa/SDL_qsa_audio.c
src/audio/sun/SDL_sunaudio.c
src/joystick/linux/SDL_sysjoystick.c


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

On Tuesday 24 December 2013 00:43:13 Sven Eckelmann wrote:
> I have occasional crashes here caused by the X11 backend of SDL2. It seems
> to be caused by the X11_Pending function trying to add a high number (>
> 1024) file descriptor to a fd_set before doing a select on it to avoid busy
> waiting on X11 events. This causes a buffer overflow because the file
> descriptor is larger (or equal) than the limit FD_SETSIZE.


I personally experienced this problem while hacking on the python bindings
package for SDL2 [1] (while doing make runtest). But it easier to reproduce in
a smaller, synthetic testcase.
2017-08-14 20:22:19 -07:00
Sam Lantinga
9451cd81ae Fixed compiler warnings 2017-08-14 20:07:30 -07:00
Sam Lantinga
aebe17d34f Fixed bug 2344 - CHECK_WINDOW_MAGIC should include __FILE__ and __LINE__
Martin Gerhardy

just for easier debugging issues in the own code...

SDL_CreateRenderer should maybe also use this macro

Ryan C. Gordon

I'll go one better: it should have an SDL_assert().
2017-08-14 16:34:54 -07:00
Sam Lantinga
96e15fa7f6 Fixed Windows build due to an implicit memcpy generated by the optimizer 2017-08-14 16:09:44 -07:00
Sam Lantinga
e9d4e31044 Fixed bug 3753 - Android : load methodID during initialization
Sylvain

Small patch to load some java methodID at start-up (and avoid a potential crash at run-time).
2017-08-14 14:14:45 -07:00
Sam Lantinga
64dd829b0a Fixed bug 2418 - Structure SDL_gestureTouch leaking
Leonardo

Structure SDL_gestureTouch gets reallocated for every new added gesture but its never freed.

Proposed patch add the function SDL_GestureQuit() that takes care of doing that and gets called when TouchQuit is called.

Gabriel Jacobo

Thanks for the patch. I think it needs a bit of extra work though, looking at the code in SDL_gesture.c , I see that SDL_numGestureTouches only goes up, I think the right fix here involves adding SDL_GestureDelTouch (hooked into SDL_DelTouch) as well as SDL_GestureQuit (as you posted in your patch).
2017-08-14 13:48:13 -07:00
Sam Lantinga
f142a7961e Fixed bug 2441 - SDL_DuplicateSurface
Rainer Deyke

I've written a small patch that adds a small SDL_DuplicateSurface function to SDL.  I've written the function as part of a larger (as yet unfinished) patch, but I think this function is useful enough that it merits inclusion in SDL on its own.
2017-08-14 13:37:14 -07:00
Sam Lantinga
362d549690 Fixed bug 2500 - X11: SDL tries (and fails) to hide foreign windows
Alvin

I'm interested in this bug as well. I have experienced it when trying to embed an SDL_Window into a FLTK application. To do this, I create a FLTK window (window inside a window - think video player) and then use SDL_CreateWindowFrom() on the inner most window's Xlib Window*. After which, I create a renderer.

In my situation I am using the FLTK GUI toolkit.

What I have experienced is that the SDL_CreateRender() will recreate the window in order to properly setup OpenGL capability. As part of this process, the window is hidden and a call is executed that waits indefinitely for an acknowledgement that the window was indeed unmapped. This is where my program hangs.

Please correct me if I am wrong, but should SDL2 not make Xlib calls that effect the Xlib Window in this situation (e.g. When SDL_CreateWindowFrom() is used)? The toolkit being used typically assumes responsibility and, I presume, tracks all Xlib Windows it creates.

On line src/video/SDL_video.c:1372 the comment associated with setting SDL_WINDOW_FOREIGN reads:

  /* Can't destroy and re-create foreign windows, hrm */

Since I do not know the reason for hiding the window in the first place, the attached patch simply does not wait for a response when X11_XWithdrawWindow() and X11_XMapRaised() are issued by X11_HideWindow() and X11_ShowWindow(), respectively. I presume that the GUI toolkit (GTK, FLTK, etc.) has or will consume the acknowledging event as it is managing the Xlib Window (or it thinks it is).

I have tested the patch against hg 5c645d037de2 and I have successfully tested:
* Embedding the SDL_Window inside a FLTK application.
* Calling SDL_SetWindowSize() when FLTK resizes the window (e.g. dragging cursor on the edge of the window).
* Filling the renderer's default target blue and drawing a red fill square at the centre (exciting, I know!)
* Calling SDL_Quit() when the application terminates

I do not receive any Xlib erorr messages (BadWindow, etc.) in any of those situations.
2017-08-14 10:28:47 -07:00
Sam Lantinga
36ba92485c Fixed setting the texture blend mode in the OpenGL ES2 renderer 2017-08-14 10:04:59 -07:00
Sam Lantinga
de91b1248f Fixed bug 3745 - specify SDLCALL as the calling convention for API callbacks
Patches contributed by Ozkan Sezer
2017-08-14 06:28:21 -07:00
Sam Lantinga
c59d9923b3 Implemented more flexible blending modes for accelerated renderers
This fixes bug 2594 - Propose new blend mode, SDL_BLENDMODE_BLEND_DSTA

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD,
	                                       SDL_BLENDFACTOR_ZERO,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_ADD);

This fixes bug 2828 - Subtractive Blending

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_SRC_ALPHA,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_SUBTRACT,
	                                       SDL_BLENDFACTOR_ZERO,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDOPERATION_SUBTRACT);


This goes partway to fixing bug 3684 - Add support for a pre-multiplied alpha blending mode

	blendMode = SDL_ComposeCustomBlendMode(SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD,
	                                       SDL_BLENDFACTOR_ONE,
	                                       SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
	                                       SDL_BLENDOPERATION_ADD);
2017-08-14 05:51:44 -07:00
Sam Lantinga
f8e1874d01 Fixed bug 2646 - Problems with software renderer when SDL_SetRenderLogicalSize set
Fixed setting the software renderer clip rectangle when a viewport is set
2017-08-13 22:50:23 -07:00
Sam Lantinga
7af3786def Fixed bug 2755 - SDL2 fails to build on Solaris 10 u3
UX-admin

I am compiling with the Sun Studio 12 u2 compiler. There are multiple issues with the build, but this particular issue appears to be that it is illegal to declare a union of a struct of floats and a float. While GCC 4.8.1 does not flag this as an error, Sun Studio is much more standards compliant and strict, halting further compilation with an error.
2017-08-13 21:55:42 -07:00
Sam Lantinga
72ab258812 Fixed bug 2764 - Timer is not rescheduled with the returned interval
afwlehmann

Sorry for re-opening, but it turns out that the current interval is indeed not updated. I've just checked the source code of the 2.0.3 release again:

   163	    if (current->canceled) {
   164	        interval = 0;
   165	    } else {
   166	        interval = current->callback(current->interval, current->param);
   167	    }
   168
   169	    if (interval > 0) {
   170	        /* Reschedule this timer */
   171	        current->interval = interval; // <-- this line is missing
   172	        current->scheduled = tick + interval;
   173	        SDL_AddTimerInternal(data, current);
   174	    } else {

According to the documentation: "The callback function is passed the current timer interval and the user supplied parameter from the SDL_AddTimer() call and returns the next timer interval. If the returned value from the callback is 0, the timer is canceled."

If I understand the text correctly, then the current interval should in fact be updated according to the returned value. Otherwise there would be a discrepancy between the next time for which the timer is actually re-scheduled and the value that's passed to the callback once the timer fires again.

This could be fixed by adding line #171.
2017-08-13 21:48:40 -07:00
Sam Lantinga
eb06aba8ae Fixed bug 3742 - minor warning fixes 2017-08-13 21:16:58 -07:00
Sam Lantinga
3cae0c38d2 Fixed bug 3746 - remove SDLCALL attribute from SDL_BlitFunc() funcptr
Ozkan Sezer

The attached patch removes SDLCALL attribute from SDL_BlitFunc() funcptr.

As far as I can see, *SDL_BlitFunc() is completely internal to SDL with
no specific calling convention requirements.  The actual functions assigned
to SDL_BlitFunc seem to not have any calling conventions specified. So,
easy solution is simply removing the strict calling convention from the
type.
2017-08-13 21:09:00 -07:00
Sam Lantinga
ca5c304814 Fixed bug 3744 - missing SDLCALL in several functions
Ozkan Sezer

The attached patch adds missing SDLCALL to several functions, so that
they properly match the headers as intended.
2017-08-13 21:06:52 -07:00
Sam Lantinga
e54eede265 Provide the correct state of the on-screen keyboard to the API (patch from Sylvain) 2017-08-13 21:05:15 -07:00
Sam Lantinga
6ee661398d Fixed bug 3235 - Make the Android window creation similar to iOS' window creation
Sylvain

Here's a patch.
It tries to get the hint first. Resizable will allow any orientation. Otherwise it uses width/height window.

setOrientation method is splitted in static and non-static, so that it can be overloaded in a user subclass.

Some artefact observed :
surfaceChanged() can be called twice at the beginning. When the phone starts in portrait and run a landscape application.
2017-08-13 20:55:59 -07:00
Sam Lantinga
6ef1a25d18 Fixed bug 3751 - DirectFB linux_input disabled by default
Clayton Craft

linux_input module is disabled by default, despite the comments in source code that it is otherwise:

src/video/directfb/SDL_DirectFB_video.c:
    devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0);       /* default: on */

src/video/directfb/SDL_DirectFB_video.h:
    #define DFBENV_USE_LINUX_INPUT      "SDL_DIRECTFB_LINUX_INPUT"      /* Default: on  */

When using the directfb driver, the linux_input module is suppressed unless the SDL app is started with "SDL_DIRECTFB_LINUX_INPUT=1" set in the environment. I recall seeing at one point that the directfb folks recommended using linux_input over the other input drivers, but I am having trouble locating this recommendation. In any case, I believe that this should really be defaulted to 'on' since it's vastly superior to the other dfb input drivers!
2017-08-13 20:51:08 -07:00
Sam Lantinga
ddeaa6016c Fixed bug 3299 - DirectInput: Incorrect joystick mapping when attaching new joysticks
Jimb Esser

Note: This is using DirectInput, I have to disable XInput as that causes all but the first 4 controllers to be completely ignored by SDL (I can find no way to reconcile XInput devices with DirectInput devices, otherwise I would make a patch that accepts the fifth and later controllers with DirectInput...).  XInput does not seem to have the problem below, only DirectInput.

I plug in 3 identical wireless Xbox 360 controllers, call them J1, J2, J3.  Direct Input shows them as having GUIDs G1, G2, G3.  I unplug J1, then J2 and J3 show up as having GUIDs G1 and G2!  Not so "unique"...  I start my SDL app when just J2 and J3 are plugged in, and open J2 and J3.  Then I plug in a new controller, SDL sees that now G3 exists, assigns that a new SDL joystick instance ID, which I request to be opened, but G3 at this point is J3, which I already had opened!  So I end up with two instances of J3 opened, and none of J1.  "Re-"opening G1 would get the actual handle to the newly attached controller, but there's no current way to know this.  This is clearly a bug or poor design in DirectInput or my wireless receiver drivers, but is a showstopping bug for my 8-20 player games (as soon as any one controller runs out of battery or goes to sleep and gets turned back on, suddenly things are busted requiring a restart (or, at least, a reinitialization of all controllers - the game can't go on)).

The solution I found is to use HID paths instead of GUIDs to uniquely identify joysticks.  GUIDs are still needed to open a controller, however I have added code to re-find the GUIDs for all joysticks whenever a new joystick is attached or removed.  This does now require opening of all joysticks (instead of just enumerating them), though if your app, like mine, is opening all of them anyway so that any can press a button to join, that doesn't change much (although perhaps they joysticks should be kept open in this case, instead of closed and re-opened).  If your app only ever opens one joystick, this will do more work at startup than it did previously.
2017-08-13 20:42:41 -07:00
Sam Lantinga
ea9bc659f5 Added check for XBOX in addition to Xbox and X-Box 2017-08-13 20:39:00 -07:00
Sam Lantinga
78865effb5 Fixed compiler warning 2017-08-13 20:38:06 -07:00
Sam Lantinga
f1829d956f Added SDL_wcscmp() 2017-08-13 20:37:49 -07:00
Sam Lantinga
af9ec8f6b5 Fixed copy-paste error, thanks Alen! 2017-08-13 20:13:11 -07:00
Sam Lantinga
df2d299447 Fixed bug 2812 - Make libSDL2main.a usable on Android via a dummy symbol
Jonas Kulla

This eliminates the need to manually compile in SDL_main_android.c.
Instead, add "-lSDL2main -Wl,-u,SDL_main_dummy" when linking.

I don't know how the nkd-build process works, but unless it was
for some reason linking libSDL2main.a it should be unaffected.
2017-08-13 18:12:06 -07:00
Sam Lantinga
c87e1d525c Fixed bug 2841 - Hint to set resource id for window icon
Alexey

Seems to be a missing functionality. I want to set an icon from RC file. I cant pass MAKEINTRESOURCE(X) string to SDL_RegisterApp() cause string returned by MAKEINTRESOURCE string is not actually a string and SDL_strlen will crash. Moreover LoadImage seems to be loading wrong icon size. LoadIcon seems to be fine.
2017-08-13 14:15:52 -07:00
Ryan C. Gordon
18cceb5ce0 x11: Patched to compile. 2017-08-13 01:00:01 -04:00
Ryan C. Gordon
0a1b905b6c x11: Fix message box titles with Unicode chars on some window managers.
Fixes Bugzilla #2971.
2017-08-13 00:58:23 -04:00
Sam Lantinga
bfd5a13473 Fixed bug 2931 - Large relative mouse motion jumps when using touch input 2017-08-12 20:25:49 -07:00
Sam Lantinga
b2e2bcc203 Added test debug logs for additional event types 2017-08-12 20:21:34 -07:00
Alex Szpakowski
9be597a0d6 iOS: Fix app orientation when creating a landscape fullscreen window with the device currently in portrait orientation. 2017-08-12 22:16:04 -03:00
Sam Lantinga
059d9e4627 Fixed bug 2950 - wrong axes values are set on joystick initialization
Edward Rudd

Device: Logitech Rumble Gamepad F510 in Xinput mode.

Upon opening the joystick the values of the axes are queried via PollAllValues are not actually set on the device all the time.

This can easily be seen in the testjoystick or testgamecontroller test programs,as the testjoystick shows all axes in the center until one 'tickles' the triggers., and the testgamecontroller will show the triggers as 'on' until on 'tickles' the triggers.

Upon further research the culprit is the SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS hint. In the default value events are ignored until there is an active window, Thus in cases where the joystick system is initialized and controllers opened before the initial window is created & focuses, the initial values will be incorrect.

Here is my current workaround in the game I'm working on porting..

SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
SDL_GameController* gamepad = SDL_GameControllerOpen(index);
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
2017-08-12 17:41:59 -07:00
Sam Lantinga
7bab2913c2 Fixed Windows build 2017-08-12 17:01:14 -07:00
Sam Lantinga
05facb3d4e Fixed bug 2979 - SDL_ConvertSurface does not convert color keys consistently
Edmund Horner

When a 16-bit "565 format" surface has a colour key set, it will blit with correct transparency.  If, however, it has its colour key set then is converted to a 32-bit ARGB format surface, the colour key in the converted image will not necessarily be the same pixel value as the transparent pixels.  It may not blit correctly, because the colour key does not match the right pixels.

In my case, with an image using 0xB54A for transparency, the colour key was converted to 180,170,82; but the corresponding pixels (with the same original value) were converted to 180,169,82.  Blitting the converted image did not use transparency where expected.

I have attached a test case.  The bug has been replicated on both x86_64 Linux (SDL 2.0.2), and 32-bit MS C++ 2010 on Windows (SDL 2.0.0).
2017-08-12 16:59:00 -07:00
Sam Lantinga
d226594fcc Workaround for bug 3049 - SDL_Init(SDL_INIT_VIDEO) - XDM authorization key matches an existing client!
malferit

Hello, I began a little program with SDL2 on Linux in C, and when I call SDL_Init(SDL_INIT_VIDEO) I get an error and this is printed in the console:

XDM authorization key matches an existing client!

I searched through Internet, and found that some people suggest to run 'xhost +' or to specify this in /etc/X11/xdm/xdm-config:

DisplayManager*authName:        MIT-MAGIC-COOKIE-1

I don't think an end user needs to know that...

But what bothered me is that first I started this little program in Pascal using the Freepascal compiler and it works. In freepascal you only use some thin header bindings in Pascal and then it links with the dynamic SDL library, so I don't understood why it worked with Freepascal and not in C.

I run ldd to the two generated applications:

Application in C:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb76ac000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb766e000)
	libc.so.6 => /lib/libc.so.6 (0xb74e2000)
	libm.so.6 => /lib/libm.so.6 (0xb74a0000)
	libdl.so.2 => /lib/libdl.so.2 (0xb749a000)
	librt.so.1 => /lib/librt.so.1 (0xb7491000)
	/lib/ld-linux.so.2 (0xb77b3000)

Application compiled with Freepascal:

	linux-gate.so.1 (0xffffe000)
	libSDL2-2.0.so.0 => /usr/lib/libSDL2-2.0.so.0 (0xb762a000)
	libX11.so.6 => /usr/lib/libX11.so.6 (0xb74f3000)
	libc.so.6 => /lib/libc.so.6 (0xb7367000)
	libm.so.6 => /lib/libm.so.6 (0xb7325000)
	libdl.so.2 => /lib/libdl.so.2 (0xb731f000)
	libpthread.so.0 => /lib/libpthread.so.0 (0xb7305000)
	librt.so.1 => /lib/librt.so.1 (0xb72fc000)
	libxcb.so.1 => /usr/lib/libxcb.so.1 (0xb72dc000)
	libXau.so.6 => /usr/lib/libXau.so.6 (0xb72d9000)
	libXdmcp.so.6 => /usr/lib/libXdmcp.so.6 (0xb72d3000)
	/lib/ld-linux.so.2 (0xb7755000)

It seems that Freepascal is linking with libX11, libxcb, libXau and libXdmcp .

Linking my C application with libxcb solved the problem (linking with libXau and/or libXdmcp without libxcb didn't work). Linking with X11 links all the other libraries and works as well.

So I fill this bug report mainly to let you know about this. I don't know if it is a problem that can be solved on the libSDL side or not, but at least I hope it will help.

Hi, some tests:

1. Disabled XDM. Login in console and running 'startx'. The program works without having to link with X11.

2. Enabled XDM. Added 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' to /etc/X11/xdm/xdm-config.The program works without having to link with X11.

3. Enabled XDM without 'DisplayManager*authName: MIT-MAGIC-COOKIE-1' in /etc/X11/xdm/xdm-config . I get the authentication error unless I link with X11.
2017-08-12 16:48:46 -07:00
Sam Lantinga
45cec28bc4 Fixed bug 3058 - Slight mistake in GetWindowStyle in SDL_windowswindow.c
Coriiander

There's a slight mistake in the function "GetWindowStyle" found in file "SDL_windowswindow.c".

When a window is marked to be resizable, the resizable style is being added regardless of whether the window has a border or not. While for some arcane, hidden semantics this can be ok, it's still inconsistent in this case.
2017-08-12 16:44:00 -07:00
Sam Lantinga
e3f3a757f3 Fixed bug 3158 - SDL display window scrambled over VNC
Witek Jachimczyk

I'm using SDL to develop a video viewer for MATLAB.  The window is scrambled while using thightVNC with its default mode of RGB656.

SDL does not correctly recognize the pixel mode.


I found a solution for this problem.  The solution involves modifying
SDL/src/video/SDL_pixels.c

Adding the following "if statement" under case 16: of SDL_MasksToPixelFormatEnum resolves the issue:

        if (Rmask == 0x003F &&
            Gmask == 0x07C0 &&
            Bmask == 0xF800 &&
            Amask == 0x0000) {
            return SDL_PIXELFORMAT_RGB565;
        }

I hope that this helps someone.  I took me a while to figure it out.
2017-08-12 16:02:33 -07:00
Sam Lantinga
4a9c6f0a14 Fixed bug 3173 - SDL_GL_GetAttribute overwrites error code from SDL_GL_GetProcAddress
Yann Dirson

When SDL_GL_GetProcAddress returns in error, the cause of the error is overwritten
in GL_GL_GetAttribute, reporting to the user "Failed getting OpenGL glGetString entry point", whereas the original "OpenGL library not loaded" never makes it
to the user.

Pushed a fix to:
f94cb13708


Note that the "OpenGL library not loaded" error looks like no root cause either,
and I'm still puzzled by the code path used: I'm forcing opengles2 renderer on
the x11 video driver on a rpi2, as in https://bugzilla.libsdl.org/3169, and although I now know that I must force the use of the RPI video driver instead
of the x11 one, I suspect even more accurate info can be given to user.
2017-08-12 15:55:54 -07:00
Sam Lantinga
3b837a2659 Fixed bug 3188 - AZERTY keyboard support broken and inconsistent
Daniel Gibson

AZERTY keyboard layouts (which are the default layouts in France and Belgium) don't have the number keys (1, 2, ..., 9, 0) in the first row of keys, but ?, &, ?", ', (, -, ?_, ??), = (with small differences between the France and Belgian variants). Numbers are reached via shift.

On Linux and OSX, SDL seems to use the corresponding ISO 8859-1 codes (231 for ?232 for ?tc) as SDL_Keycode (but no SDK_* constants exists for those values!), while on Windows SDL seems to map those keys to SDLK_1, SDLK_2 etc, like you'd get on QWERTY.
I don't know how other platforms behave.

So we have two problems:
1. At least on Linux and OSX invalid/undefined SDL_Keycodes are returned
2. Different platforms behave differently (Windows vs Linux/OSX)

It's unclear what behavior is desired: Should SDL_* constants for those keys be introduced (and Windows behavior changed accordingly)?
Or should all platforms behave like Windows here and use the existing SDLK_1, ..., SDLK_0 keycodes?

This bug on the mailing list:
https://forums.libsdl.org/viewtopic.php?t=11555 (my post about Linux/Windows)
https://forums.libsdl.org/viewtopic.php?t=11573 (Tim Walters discovered the same problem on OSX about 1.5 weeks later).
2017-08-12 15:41:03 -07:00
Sam Lantinga
1a5441451c Fixed bug 3309 - SDL_ConvertSurface adds AlphaMod when input surface has ColorKey
Sylvain

Let's you have a SDL_Surface that has ColorKey, but no Alpha Modulation.
When this surface is duplicated with SDL_ConvertSurface function, the result has ColorKey and Alpha Modulation (BLEND, and Opaque 255).

I think SDL_ConvertSurface should strictly keeps the input format.


example
=======

SDL_Surface *input; // ... Set up a surface with ColorKey and no AlphaMod

SDL_Surface *output = SDL_ConvertSurface(input, input->format, input->flags);

// "output" surface has a ColorKey but *also* AlphaMod (BLEND, and Opaque 255).
2017-08-12 15:21:26 -07:00
Sam Lantinga
6f843b902d Fixed bug 3243 - SDL_SetRenderDrawColor() behaves wrong with RGBA=0
Simon Hug

The bug is in the GL_ResetState and GLES_ResetState functions which get called after a new GL context is created. These functions set the cached current color to transparent black, but the GL specification says the initial color is opaque white.

The attached patch changes the values to 0xffffffff to reflect the initial state of the current color. Should the ResetState functions get called anywhere else in the future, this probably has to call the GL functions itself to ensure that the colors match.
2017-08-12 12:59:22 -07:00
Sam Lantinga
47c2c7d585 Cleaned up WindowsScanCodeToSDLScanCode() so VKeytoScancode() always takes precedence for the keys it handles and the rest of the logic is easier to read. 2017-08-12 12:56:28 -07:00
ouned
34769abd46 prefer virtual keycodes over scancodes for extended keys 2017-06-03 09:13:08 +02:00
Sam Lantinga
195b8bd8ee Fixed bug 3249 - keysym.mod is incorrect when mod keys are pressed for SDL_KEYDOWN events
Adam M.

The keysym.mod field does not reflect the state of the modified keys when processing key down events for the modifier keys themselves. The documentation says that it returns the current key modifiers, but they are not current for key down events involving modifier keys. I interpret "current" to mean "equal to SDL_GetModState() at the instant the event is processed/enqueued".

For example, if you depress the Shift key you get a key down event with .mod == 0. However, .mod should not be 0 because a shift key is down. If you then release the Shift key, you get a key up event with .mod == 0. Neither event reports the modifier key.

If you press Shift and then A, .mod is incorrect (== 0) when Shift is pressed, but is correct later when A is pressed (== KMOD_LSHIFT).

You might say this behavior is deliberate, i.e. keysym.mod is the value /before/ the event, not the current value as documented, but that explanation is incorrect because only key down events behave that way. Key up events correctly give the current value, not the value before the event.

Not only is it inconsistent with itself, I think it makes keyboard processing harder.

The problem is near line 740 in SDL_keyboard.c:

if (SDL_KEYDOWN == type) {
    modstate = keyboard->modstate; // SHOULD THIS BE MOVED DOWN?
    switch (keycode) {
    case SDLK_NUMLOCKCLEAR:
        keyboard->modstate ^= KMOD_NUM;
        break;
    case SDLK_CAPSLOCK:
        keyboard->modstate ^= KMOD_CAPS;
        break;
    default:
        keyboard->modstate |= modifier;
        break;
    }
} else {
    keyboard->modstate &= ~modifier;
    modstate = keyboard->modstate;
}

In the key down path, modstate (and thus keysym.mod) ends up being the modifier state /before/ the event, but in the key up path modstate ends up being the modifier state /after/ the event. Personally I think the "modstate = keyboard->modstate" line should just be moved after the entire if/else statement, so that keysym.mod always reflects the current state.
2017-08-12 12:34:09 -07:00
Sam Lantinga
c086251266 Fixed bug 3128 - Removing all the static variables from android SDLActivity and accompanying JNI calls.
owen

I removed all the static variables from SDLActivity.java

Updated all the SDL_android.c jni calls as well

I added a new function to SDL_android.c/ h
void Android_JNI_SeparateEventsHint(const char* c);

This is called by SDL_androidtouch.c so that this TU doesn't need to call any JNI functions.
2017-08-12 12:24:59 -07:00
Sam Lantinga
0a52db54bd Fixed bug 3191 - haptic system on android?
Patch provided by jintiao and Milan Nikolic, thanks!
2017-08-12 08:15:09 -07:00
Sam Lantinga
78c84e7029 Fixed part of bug 3227 - patch for multiple buttons at the same time not working
Philipp Wiesemann

There is another problem with the current implementation which maybe should be fixed first (to prevent some work). It was written as if it would get the number of a button from the Java side but actually it gets the state of all buttons. That is why it should not work if more than one button is pressed at once.
2017-08-12 08:06:16 -07:00
Sam Lantinga
b425050baf Fixed compiler warnings on Visual Studio 2013 2017-08-12 00:04:46 -07:00
Sam Lantinga
affab6ade5 More fixes for the SDL_scanf code 2017-08-12 00:01:24 -07:00
Sam Lantinga
e27dcd1c3b Fixed Android build 2017-08-11 23:54:06 -07:00
Sam Lantinga
7229397c0c Fixed bug 3258 - SDL_TryLockMutex blocks for pthreads with FAKE_RECURSIVE_MUTEX
Ian Abbott

I just spotted what I think is a bug in "src/thread/pthread/SDL_sysmutex.c" in the SDL_TryLockMutex function when FAKE_RECURSIVE_MUTEX is defined (for an implementation of Pthreads with no recursive mutex support).  It calls pthread_mutex_lock instead of pthread_mutex_trylock, so it will block until the mutex is available instead of returning SDL_MUTEX_TIMEDOUT if it cannot lock the mutex immediately.
2017-08-11 21:47:31 -07:00
Sam Lantinga
b5ea3c6d07 Fixed bug 3284 - minor correction for SDL_setenv on _WIN32__ platform
Coriiander

Here is a minor correction for a non-breaking mistake in SDL_setenv for __WIN32__ platform. See below for details.

FILE:
"SDL/src/stdlib/SDL_getenv.c"

FUNCTION: (__WIN32__ platform)
int SDL_setenv(const char *name, const char *value, int overwrite)

CODE:
    if (!overwrite) {
        char ch = 0;
        const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
        if (len > 0) {
            return 0;  /* asked not to overwrite existing value. */
        }
    }


WHAT'S WRONG:
The 3th argument to GetEnvironmentVariable (being DWORD nSize) must be the number of characters, not the number of bytes. SDL currently passes "the size of 1 char", rather "1". While it is non-breaking (1=1 after all), it is incorrect. Furthermore there is no need to specify the 2nd and 3th arguments at all.

CORRECTION 1: (corrected argument_
    if (!overwrite) {
        char ch = 0;
        const size_t len = GetEnvironmentVariableA(name, &ch, 1);
        if (len > 0) {
            return 0;  /* asked not to overwrite existing value. */
        }
    }

CORRECTION 2: (stripped of unneeded code)
    if (!overwrite) {
        if (GetEnvironmentVariableA(name, NULL, 0) > 0) {
            return 0;  /* asked not to overwrite existing value. */
        }
    }
2017-08-11 21:30:06 -07:00
Sam Lantinga
a48c9e6df8 Fixed bug 3292 - SDL_rwops and 64-bit file I/O
Juha Niemim?

On AmigaOS 4 platform with Newlib 'C' library, there is a problem with failing fseeko64. This seemed to be caused by using fopen instead of fopen64.
2017-08-11 21:16:33 -07:00
Sam Lantinga
4c239e55f9 Fixed bug 3297 - Horizontal and Vertical flip swapped on PSP
Littlefighter19

When trying to mirror something on the PSP, I've stumbled upon the problem,
that using SDL_RenderCopyEx with SDL_FLIP_HORIZONTAL flips the image vertically, vise-versa SDL_FLIP_VERTICAL flips the image horizontally.
Proposed patch would be swapping the check in line 944 with the one in line 948 in SDL_render_psp.c
2017-08-11 20:54:06 -07:00
Sam Lantinga
79a846d486 Fixed bug 3334 - SDL_ShowMessageBox uses wrong index and accesses un-allocated memory
romain.lacroix

For the windows implementation of SDL_ShowMessageBox() : ./src/video/windows/SDL_windowsmessagebox.c:345 WIN_ShowMessageBox()

The implementation in 2.0.4 uses "button index" for parameter "id" of function AddDialogButton().

It then expects the value provided in param wParam of function MessageBoxDialogProc() to be a valid index of a button.

It uses this value to index in the array of buttons when DialogBoxIndirect() returns (line 474 : *buttonid = buttons[which].buttonid;)

However, when dismissing this box with Escape, the return value of DialogBoxIndirect will be SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT (=2) which is not always a valid index of array buttons.

When the array buttons has a length less or equal than 2, the memory access is invalid; I can see that the value written to *buttonId is uninitialized memory (random value).

The fix I propose : use value "buttonid" (field of button) for parameter "id" of AddDialogButton(), then copy return value of DialogBoxIndirect() in *buttonid. This way, we will not use an out-of-bounds index in array buttons.
2017-08-11 19:42:39 -07:00
Sam Lantinga
441d9ba2b0 Fixed bug 3341 - SDL_sscanf() problem
e_pluschauskas

Why does SDL_sscanf() always returns the number of format specifiers and doesn't implements standard C library behavior?
2017-08-11 19:36:12 -07:00
Sam Lantinga
1da252c2d8 Fixed crash in bug 3367 - RGBA_FROM_PIXEL macro can't handle SDL_PIXELFORMAT_ARGB2101010
Simon Hug

The RGBA_FROM_PIXEL macro in src/video/blit.h [1] is not designed to work with more than 8 bits per channel and the ARGB2101010 format makes it read outside of the array bounds causing access violations. This can happen during blitting with the BlitNtoNPixelAlpha and SDL_Blit_Slow functions.

When SDL_InitFormat tries to calculate the loss of the channels [2], the Uint8 will wrap around and it will end up at 254 for the 10-bit channels. Clearly way over the 9 entries of the SDL_expand_byte array. (Not that a signed integer would help.) Then the macro tries to access the lookup table with the channel value which could be up to 1023. If the previous indirection didn't cause an access violation this one will.

I guess it's not worth modifying this macro for a format that only a few will use. It will only make the other blitters slower. I don't have good ideas to solve this issue.

Attached is a test case that does three blits. A copy one that work and the two that use the functions mentioned above.

[1] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_blit.h#l303
[2] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_pixels.c#l540
2017-08-11 18:56:41 -07:00
Sam Lantinga
6de66e984f Fixed bug 3324 - SDL_RenderReadPixels: Wrong rect coordinates with software renderer
Daniel

SDL_RenderReadPixels with SDL_RENDERER_SOFTWARE reads pixels from wrong coordinates.

SW_RenderReadPixels adjusts the rect coordinates according to the viewport. But since this is already done by SDL_RenderReadPixels, the final rect has x2 bigger X and Y.
2017-08-11 11:54:24 -07:00
Sam Lantinga
658975f381 Fixed bug 3639 - SDL_GetPrefPath returns a path with two consecutive slashes on Unix if org is omitted
Fabian Greffrath

we use SDL_GetPrefPath() in Chocolate Doom to get a reasonable directory to save and restore config files and savegames:

https://github.com/chocolate-doom/chocolate-doom/blob/sdl2-branch/src/m_config.c#L2162

However, since there is no "organization" behind Chocolate Doom and there is really only one "product" called Chocolate Doom, we pass an empty string for the org parameter and the package string for app.

This leads to two consecutive slashes in the path returned by SDL_GetPrefPath() like this:

/home/user/.local/share//chocolate-doom/

While this is harmless, it sure looks bad.

I believe that it should be possible to either pass a NULL pointer for the org parameter or at least have the function detect an empty string as a means to express "there is no origanization, just a single product". The generation of the path string to be returned by the function will have to get adapted accordingly.
2017-08-11 11:32:00 -07:00
Sam Lantinga
3c852360f6 Fixed bug 3646 - SDL_test_common.c: Add key bindings for testing SDL_SetWindowPosition
Eric Wasylishen

Alt-Up/Down/Left/Right switches between displays using SDL_WINDOWPOS_CENTERED_DISPLAY

Shift-Up/Down/Left/Right shifts the window by 100px
2017-08-11 10:42:26 -07:00
Sam Lantinga
96305832bc Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries
Simon Hug

Some code in SDL loads libraries with SDL_LoadObject to get more information or use newer APIs. SDL_LoadObject may fail, set an error message and SDL will continue with some fallback code. Since SDL will overwrite the error or exit the function with a return value that indicates success, the error form SDL_LoadObject for the optional stuff might as well be cleared right away.
2017-08-11 10:21:19 -07:00
Sam Lantinga
6e1b11bae4 Fixed bug 3714 - Windows: SDL_WINDOW_FULLSCREEN_DESKTOP broken on 3 monitor setup w/ DPI scaling
Eric Wasylishen 2017-07-26 18:42:58 UTC
I set up an (admittedly exotic) 3-monitor setup, and when I enter fullscreen-desktop on the middle display (#2), the SDL window is off center. (covers half of monitor #2 and most of monitor #3).

The displays are arranged from left to right:

Display #1 (main): 2880x1800, 200% scaling
Display #2: 1920x1200, 150% scaling
Display #3: 1920x1080, 100% scaling

SDL display bounds:
INFO: Bounds: 1440x900 at 0,0
INFO: Bounds: 1281x801 at 1921,0  (these are incorrect)
INFO: Bounds: 1920x1080 at 4800,0

Correct bounds reported by calling EnumDisplayMonitors and printing the LPRECT param of the callback:
1440x900 at (0, 0)
1280x800 at (2880, 0)
1920x1080 at (4800, 0)

It seems like you need 3 displays to reproduce this, and the left two need DPI scaling, and the 3rd display needs to have a different scale factor than the others.

Related: https://bugzilla.libsdl.org/show_bug.cgi?id=3709

SDL: current hg (11235:6a587b9e0ec8)
Windows 10, Version 10.0.15063 Build 15063
Tested with testdraw2 and testgl2, and pressing alt+enter to enter fullscreen desktop.

This patch reworks SDL_windowsmodes.c to use EnumDisplayMonitors instead of EnumDisplayDevices, so we always have an HMONITOR for each SDL display.

With access to an HMONITOR, we can get the monitor bounds in virtual screen coordinates the proper way, by calling GetMonitorInfo. (whereas the original code was doing some calculations - e.g. "data->DeviceMode.dmPosition.x * data->ScaleX" - to try to get virtual screen coordinates. These worked in simple cases, but failed in more complex cases like this bug)

The one potential problem with my patch is, the ChangeDisplaySettingsEx docs say that you're supposed to get the display name from EnumDisplayDevices, but I'm getting the display name from GetMonitorInfo now.
2017-08-11 10:18:45 -07:00
Sam Lantinga
a05522a089 Fixed bug 3723 - Possible double free in kmsdrm init code on certain errors
Simon Hug

KMSDRM_VideoInit allocates and frees some connectors and encoders but doesn't set the pointer to NULL after freeing. The cleanup code at the end may free one of those garbage pointer should an error happen in the initialization.
2017-08-11 10:05:45 -07:00
Sam Lantinga
843293bed0 Fixed bug 3701 - WM_TOUCH message may cause calls to null if touch functions are not properly loaded
Simon Hug

When WIN_WindowProc processes the WM_TOUCH message, it doesn't check if the touch functions have been properly loaded and may call a NULL pointer. It's probably an extremely rare case, but here's a patch that adds some checks anyway.
2017-08-09 20:26:16 -07:00
Sam Lantinga
af44a5953a Fixed bug 3672 - Add joystick to controllerdb
Moritz M-H

The following entry needs to be added to the gamecontrollerdb for the Qanba fighter stick under linux
2017-08-09 20:20:35 -07:00
Ryan C. Gordon
69092c7e47 haiku: Fixed compiler warning. 2017-08-09 18:30:48 -04:00
Sam Lantinga
03250690d6 Added a private hint for Steam to bypass the controller filtering for the Steam virtual gamepad 2017-08-09 12:38:20 -07:00
Sam Lantinga
f15dbc8f63 Fixed Linux build 2017-08-09 12:11:59 -07:00
Sam Lantinga
c49fa37c5b Added SDL hints to filter the set of game controllers reported by SDL 2017-08-09 11:59:29 -07:00
Sam Lantinga
dc40018438 Added an API SDL_LoadFile_RW() to load all the data from an SDL data stream, and a convenience macro SDL_LoadFile() to load all the data from a file. 2017-08-09 11:58:38 -07:00
Ryan C. Gordon
a412ba0d75 haiku: Patched SDL_bopengl.cc to compile on x86-64 Haiku.
Fixes Bugzilla #3729.
2017-08-09 01:01:41 -04:00
Ryan C. Gordon
d5215d9df9 Fixed up some compile warnings and errors on x86-64 Haiku. 2017-08-09 00:56:05 -04:00
Sam Lantinga
4e43c631b8 Re-added missing entry for the Steam Virtual Gamepad (was Valve Streaming Gamepad) 2017-08-08 20:38:23 -07:00