Commit Graph

1975 Commits

Author SHA1 Message Date
Ryan C. Gordon
5f123e31a3 atomic: Spin locks now try to use the x86 PAUSE instruction for short waits.
Fixes Bugzilla #4151.
2018-06-25 15:58:35 -04:00
Ryan C. Gordon
5a8ecf4e79 yuv: Patched to make static analysis happy (warned about unused variable). 2018-06-25 13:14:52 -04:00
Ryan C. Gordon
4773690d0f Deal with possible malloc(0) calls, as pointed out by static analysis. 2018-06-25 12:55:23 -04:00
Ryan C. Gordon
915a7e0341 gles2: Whoops, overzealous copy/paste on my part. :) 2018-06-25 01:57:28 -04:00
Ryan C. Gordon
c8ac909674 wayland: Implemented xdg-wm-base support.
This is just in parity with the existing zxdg-shell-unstable-v6 code. Making
the Wayland target robust (and uh, with title bars) is going to take a lot
of work on top of this.
2018-06-24 22:42:36 -07: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