Commit Graph

6274 Commits (d71df6448b04d756555d9d9d285ba4c36b7e9f61)

Author SHA1 Message Date
Northfear 5292156398 End Scene on RunCommandQueue on Vita 2021-09-22 11:54:26 -07:00
Cameron Cawley 08ae790497 Replace calls to asprintf with SDL_asprintf 2021-09-22 11:53:46 -07:00
Cameron Cawley 25a614bc3e Add SDL_asprintf and SDL_vasprintf 2021-09-22 11:53:46 -07:00
Sam Lantinga 79b0aae86c The return value of SDL_snprintf is the number of characters that would have been written.
Fixes https://github.com/libsdl-org/SDL/issues/4762
2021-09-22 11:46:24 -07:00
Ethan Lee 9b74623be9 wayland: Woops, forgot to assign cursor theme size... 2021-09-22 13:52:36 -04:00
Ethan Lee 8e54698aa6 wayland: Add support for high-DPI cursors 2021-09-22 10:37:42 -07:00
Sam Lantinga 432ee7d8ad Fixed building SDL_dynapi.c without stdio support 2021-09-22 09:29:21 -07:00
Sam Lantinga 345c161feb Fixed some accidental uses of external C runtime functions 2021-09-22 09:06:45 -07:00
Sam Lantinga 5d455cabf9 Don't process raw input when the window is being dragged or clicked on. 2021-09-21 18:15:11 -07:00
Sam Lantinga 0fd54f91f4 Fixed using a tablet with raw input relative motion
Tested with a Wacom Cintiq Pro 16"
2021-09-21 18:15:11 -07:00
Sam Lantinga 8fee82d1fd Improve relative motion handling over RDP
CR and research: @danielj
2021-09-21 18:15:09 -07:00
Sam Lantinga eb3bf80f9c Fixed compiler warnings using Visual Studio 2019 2021-09-21 18:15:09 -07:00
Ryan C. Gordon ce11caa80f
alsa: Map 7.1 audio channels to match what Windows and macOS expect.
This matches what we did a long time ago for 5.1 audio.

Fixes #55.

(FIFTY FIVE. Bug reported 15 years, 3 months, and 11 days ago! lol)
2021-09-21 16:49:44 -04:00
pkubaj 9886d897e2 Fix AltiVec detection on FreeBSD
The previous code was not correct, because there's no PPC_FEATURE_HAS_ALTIVEC MIB.
Instead, elf vector check should be done.
2021-09-21 09:57:10 -07:00
Ryan C. Gordon c45facf2ca
alsa: clean up macro salsa a little. 2021-09-21 11:13:46 -04:00
Northfear 3b2fbb1cb7 End current scene before destroying the texture on Vita 2021-09-20 15:55:36 -07:00
Northfear fc4296c114 Use aligned stride in sceGxmColorSurfaceInit 2021-09-20 13:23:42 -07:00
Northfear 7080bc2a91 Fallback to SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE if CDRAM texture allocation fails 2021-09-20 13:23:42 -07:00
Ivan Epifanov 512355d7aa Vita: fix thread detach. Remove leftover KillThread 2021-09-20 11:03:02 -07:00
Ivan Epifanov ddcd847c8e Vita: fix thread priority Add support for thread name and stack size 2021-09-20 08:59:25 -07:00
Ryan C. Gordon 478f9eed28
x11: Don't include X11/extensions/extutil.h
We don't use it, it was a leftover from 1.2, I think, and it doesn't exist
on Solaris, so this should hopefully fix the build there.

This also means we don't need the configure/cmake checks for
SDL_VIDEO_DRIVER_X11_CONST_PARAM_XEXTADDDISPLAY, so that was removed also.

Fixes #1666.
2021-09-20 10:22:50 -04:00
Ryan C. Gordon ca9a321715
render: GL/GLES now draw lines almost perfectly matching software renderer.
One place known to differ in a significant way is a single line segment that
starts and ends on the same point; the GL renderers will light up a single
pixel here, whereas the software renderer will not. My current belief is this
is a bug in the software renderer, based on the wording of the docs:

"SDL_RenderDrawLine() draws the line to include both end points."

You can see an example program that triggers that difference in Bug #2006.

As it stands, the GL renderers might _also_ render diagonal lines differently,
as the the Bresenham step might vary between implementations (one does three
pixels and then two, the other does two and then three, etc). But this patch
causes those lines to start and end on the correct pixel, and that's the best
we can do, and all anyone really needs here.

Not closing any bugs with this patch (yet!), but here are several that it
appears to fix. If no other corner cases pop up, we'll call this done.

Reference Bug #2006.
Reference Bug #1626.
Reference Bug #4001.
...and probably others...
2021-09-19 15:47:24 -04:00
Ryan C. Gordon 857cc7c0c9
render: constified some local variables in SDL_AllocateRenderVertices. 2021-09-19 00:38:06 -04:00
Ryan C. Gordon 5faea84c63
render: Mark viewport/cliprect dirty when window is resized.
Fixes #4751.
2021-09-18 11:54:25 -04:00
Cameron Gutman 5dccffd7e4 Allow usage of the new Condition Variable code with Critical Sections
Vista and later provide the SleepConditionVariableCS() function for this.

Since SDL_syscond_srw.c doesn't require SRW locks anymore, rename it to
SDL_syscond_cv.c which better reflects the implementation of condition
variables rather than the implementation of mutexes.

Fixes #4051.
2021-09-17 19:38:09 -04:00
Alex R ebdfd0e175 atomic: detect clang separately 2021-09-16 17:33:52 -07:00
Ivan Epifanov 8d1e0ca324 Vita: add support for disabling 'screensaver' (screen dimming and suspend) 2021-09-16 09:03:17 -07:00
Ivan Epifanov 79ec8986d3 Vita: refactor gxm texture render and add SDL_RenderGeometry support 2021-09-16 09:03:17 -07:00
Zach Reedy 2a8938f2bf
Fixed: Whitespace being striped from the end of IME strings incorrectly + Regression with SDL_SetTextInputRect (#4752)
* Fixed: Whitespace being striped from the end of IME strings incorrectly

* Fixed: Google IME Candidate Window not placing correctly

* Why are PostBuild events stored in the vcxproj and not a user file?

* Revert SDL.vcxproj properly...

* Remove whitespace as per code review

* Fix Werror=declaration-after-statement error in code
2021-09-15 09:40:22 -07:00
Ivan Epifanov ce177049f7 Vita: Allow completely skipping pvr init to override apphint from app 2021-09-14 16:20:50 -07:00
Misa 4a9947336c `SDL_RenderSetVSync()`: Restrict `vsync` to 0 or 1
In the future, we might want to support special swap intervals. To
prevent applications from expecting nonzero values of vsync to be the
same as "on", fail with SDL_Unsupported() if the value passed is neither
0 nor 1.
2021-09-14 16:18:02 -07:00
Misa 4549769d7d Add `SDL_RenderSetVSync()`
Currently, if an application wants to toggle VSync, they'd have to tear
down the renderer and recreate it. This patch fixes that by letting
applications call SDL_RenderSetVSync().

This is the same as the patch in #3673, except it applies to all
renderers (including PSP, even thought it seems that the VSync flag is
disabled for that renderer). Furthermore, the renderer flags also change
as well, which #3673 didn't do. It is also an API instead of using hint
callbacks (which could be potentially dangerous).

Closes #3673.
2021-09-14 09:56:29 -07:00
Ivan Epifanov b2504b5da6 Fix typos 2021-09-11 20:40:50 +03:00
Jaylon Gowie e455659467 Simplify Backspace and Enter 2021-09-10 19:49:47 -07:00
Jaylon Gowie f162d9ee23 Fix Indentation 2021-09-10 19:49:47 -07:00
Jaylon Gowie 058c4d36b2 Add envvar to disable touchpads independently 2021-09-10 19:49:47 -07:00
Jaylon Gowie 4435543db1 Add PVR On Screen Keyboard Support 2021-09-10 19:49:47 -07:00
Ivan Epifanov 10d3df44f1 Vita: fix copyright dates 2021-09-09 07:22:01 -07:00
Ivan Epifanov 2a83686071 Fix default path 2021-09-09 07:22:01 -07:00
Ivan Epifanov 134dd46819 Add pvr gles/gles2 context support 2021-09-09 07:22:01 -07:00
Sam Lantinga ff85d4fbe5 Fixed Xbox Series X controller being detected by both IOKit and GCController on macOS 2021-09-08 17:51:47 -07:00
Sam Lantinga 9f8552588d Added mapping for Xbox One S controller with newer firmware on macOS 2021-09-08 17:50:17 -07:00
Sam Lantinga bf97c5a22f Make sure SDL file descriptors don't leak into child processes 2021-09-08 14:47:40 -07:00
Ryan C. Gordon d49d955d73
render: SDL_RenderGeometry should still render when hidden, in most cases.
(otherwise render targets may fail, etc...the check is a legacy helper for
iOS apps that crash if you try to use OpenGL while in the background.)
2021-09-08 11:44:17 -04:00
Sam Lantinga 7d66fa209a Fixed double-copy of the report in BlueZ >= 5.56 2021-09-07 17:38:26 -07:00
Sam Lantinga 7ed7644a26 Fixed compiling HIDAPI Steam Controller support with C89 compiler 2021-09-07 17:37:47 -07:00
Sam Lantinga 27a48b142b Check the pathname first, as that's a faster check for XInput devices 2021-09-07 15:50:21 -07:00
Zach Reedy 6f97205229 Added: Support for showing the IME Candidate Window on Windows 2021-09-02 02:28:54 -10:00
Sylvain 183eb0673b
Fixed bug #4711: prevent opengl SDL_renderer from crashing if GL_ARB_multitexture isn't supported 2021-09-01 15:46:32 +02:00
Rokas Kupstys 515b7e93b5 Fix horizontal wheel scroll direction of X11. 2021-09-01 03:25:49 -10:00
David Gow a1ffeda0ed Add SDL_HINT_APP_NAME and DBUS inhibition hint
See SDL bug #4703. This implements two new hints:
- SDL_APP_NAME
- SDL_SCREENSAVER_INHIBIT_ACTIVITY_NAME

The former is the successor to SDL_HINT_AUDIO_DEVICE_APP_NAME, and acts
as a generic "application name" used both by audio drivers and DBUS
screensaver inhibition. If SDL_AUDIO_DEVICE_APP_NAME is set, it will
still take priority over SDL_APP_NAME.

The second allows the "activity name" used by
org.freedesktop.ScreenSavver's Inhibit method, which are often shown in
the UI as the reason the screensaver (and/or suspend/other
power-managment features) are disabled.
2021-08-30 09:15:11 -04:00
Lee Salzman 9fae8f7088 Treat empty SDL_VIDEODRIVER var to check all video drivers. 2021-08-30 05:00:51 +03:00
Lee Salzman 7d90df0ece Restore previous behavior of empty SDL_AUDIODRIVER trying all drivers.
The recent change to make SDL_AUDIODRIVER support comma-separated lists
broke the previous behavior where an SDL_AUDIODRIVER that was empty
behaved the same as if it was not set at all. This old behavior was
necessary to paper over differences in platforms where SDL_setenv may
or may not actually delete the env var if an empty string is specified.
This patch just adds a simple check to ensure SDL_AUDIODRIVER is not
empty before using it, restoring the old interpretation of the empty
var.
2021-08-30 05:00:51 +03:00
Sam Lantinga 8b1f8b6ec5 Use the high speed alternate setting on new Microsoft Xbox controllers 2021-08-27 11:14:09 -07:00
Sylvain 1fe9ad04be
SDL_ConvertSurface: add an intermediate variable to remove static analysis false positive (see bug #4600) 2021-08-27 14:09:47 +02:00
Sylvain be6bee0b5a
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:47:28 +02:00
Sylvain 54ca1d190e
SW_RenderGeometry: add a redundant check to clear static analysis (see bug #4600) 2021-08-27 07:44:03 +02:00
Sylvain b17aa5d080
SW_RenderGeometry: remove a few static analysis false positives (see bug #4600) 2021-08-27 07:16:40 +02:00
David Gow 3261f7f6ce audio: Support "pulse" as an alias for "pulseaudio"
Originally, SDL 1.2 used "pulse" as the name for its PulseAudio driver.
While it now supports "pulseaudio" as well for compatibility with SDL
2.0 [1], there are still scripts and distro packages which set
SDL_AUDIODRIVER=pulse [2]. While it's possible to remove this in most
circumstances or replace it with "pulseaudio" or a comma-separated list,
this may still conflict if the environment variable is set globally and
old binary builds of SDL 1.2 (e.g. packaged with older games) are being
used.

To fix this on SDL 2.0, add a hardcoded check for "pulse" as an audio
driver name, and replace it with "pulseaudio". This mimics what SDL 1.2
does (but in reverse). Note that setting driver_attempt{,_len} is safe
here as they're reset correctly based on driver_attempt_end on the next
loop.

[1] d951409784
[2] https://bugzilla.opensuse.org/show_bug.cgi?id=1189778
2021-08-25 22:43:32 -10:00
Sam Lantinga 503ea8e89f Don't modify the Nintendo Switch home LED state by default 2021-08-25 14:42:16 -07:00
Vanfanel b1e492d1fc Search for an appropiate plane instead of simply using the first one. 2021-08-25 10:51:26 -10:00
Eric Engestrom 23ffa3d914 Update SDL's copy of the EGL headers from Khronos 2021-08-25 10:50:21 -10:00
Ethan Lee 524964f966 Add SDL_HINT_VIDEO_EGL_ALLOW_TRANSPARENCY 2021-08-25 16:40:02 -04:00
Eric Engestrom 5113fedfa0 video/wayland: use EGL_EXT_present_opaque when available 2021-08-25 16:40:02 -04:00
Sam Lantinga 130b6bebae Manually scan for Linux joysticks before udev scan runs
This allows us to have joysticks sorted by insert time at startup, fixing https://github.com/libsdl-org/SDL/issues/4688
2021-08-24 17:03:19 -07:00
Sam Lantinga cbccf5bb50 Use SDL_GetHint() instead of SDL_getenv() for Linux joystick hints 2021-08-24 17:03:19 -07:00
Shawn Ellis 0ae2a9f8c3 Fixed the Atari gamecontroller mappings and added Atari Xbox 360
This change corrects the mappings for the Atari gamecontroller and
adds support for the Atari Xbox 360 compatible gamecontroller. The Atari
game controller can switch between Atari and Xbox 360 mappings.
2021-08-24 13:06:27 -10:00
Ryan C. Gordon d5fe9c308a x11: Log a warning if we decide to use XVidMode.
Reference issue #1782.
2021-08-24 14:29:39 -04:00
Ryan C. Gordon 9504bb121d
pulseaudio: Fix some function signatures that expect const pointers.
This might have changed at some point in the Pulse API, or this might have
always been wrong, but we didn't notice because the dynamic loading code
hides it by casting things to void *. The static path, where it
assigns the function pointer directly, puts out a clear compiler warning,
though.
2021-08-23 00:47:25 -04:00
Sylvain e426bb80cb
Fixed bug #4671 - D3D_QueueGeometry: use "count / 3" (Thanks alittlesail!) 2021-08-20 07:50:30 +02:00
Oschowa 70c23b25f0 audio: pipewire: Reset hotplug atomic variables on deinit. 2021-08-19 22:26:25 -04:00
Sylvain ae5336a3d2
Fixed bug #4669: D3D_QueueGeometry: -0.5f offset position of vertexs
This similar to D3D_QueueCopy positions
2021-08-19 14:03:10 +02:00
Ozkan Sezer 8270172e74 fix -Wshorten-64-to-32 warnings in android builds.
see: https://github.com/libsdl-org/SDL/pull/4195#issuecomment-901506386
2021-08-19 12:11:10 +03:00
Ozkan Sezer ccb06296b9 SDL_windowsevents.c: fix build against older SDKs. 2021-08-19 03:15:02 +03:00
Sylvain 154384a776 Add (uintptr_t) casts 2021-08-19 00:10:59 +02:00
Sylvain 08d6a4653e Fix dynapi prototypes 2021-08-19 00:10:59 +02:00
Sylvain 1670104ad8 Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain a8f89a01aa Change 'size_indice' to 'size_indices' 2021-08-19 00:10:59 +02:00
Sylvain 47db47c1cc Add SDL_HAVE_RENDER_GEOMETRY to compile or not with RenderGeometry support 2021-08-19 00:10:59 +02:00
Sylvain b9bd9da78f OpenGLES2: transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain Becker c6ceaaeb4b METAL: use Uchar4Normalized format to transfert color as 4 bytes, instead of 4 floats 2021-08-19 00:10:59 +02:00
Sylvain eff840bb9b Add OpenGLES implementation 2021-08-19 00:10:59 +02:00
Sylvain 32e7910135 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain 6e47f53869 Fix warnings 2021-08-19 00:10:59 +02:00
Sylvain 4869a3d294 Add Direct3D9 implementation (not tested) 2021-08-19 00:10:59 +02:00
Sylvain 4ba3763897 Save and restore SDL renderer state after transforming triangles to rect 2021-08-19 00:10:59 +02:00
Sylvain cd0663e053 Fix declaration-after-statement and remove tabs 2021-08-19 00:10:59 +02:00
Sylvain Becker cd4663dfcb Update D3D11 for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain Becker 9f59170743 Update METAL backend for SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain 61d9e9164f For the software renderer, try to reinterpret triangles as SDL_Rect
With Dear ImGui + software renderer, it draws:
- by default at 250 fps
- drops to 70 fps if you show the color picker
- drops to 10 fps if put the color picker fullscreen
2021-08-19 00:10:59 +02:00
Sylvain cc37c38e30 Add SDL_RenderGeometry based on SDL_RenderGeometryRaw 2021-08-19 00:10:59 +02:00
Sylvain e481261173 Move to SDL_RenderGeometryRaw prototype with separate xy/uv/color pointer parameters 2021-08-19 00:10:59 +02:00
Sylvain 111c70e141 Use 64 bits precision to prevent overflow when interpolating color / texture with wide triangles 2021-08-19 00:10:59 +02:00
Sylvain f73c1eff10 Use normalized texture coordinates 2021-08-19 00:10:59 +02:00
Sylvain 5828cc415a Update METAL backend: fix a typo in drawline 2021-08-19 00:10:59 +02:00
Sylvain 9eab5195fe Update dynapi files 2021-08-19 00:10:59 +02:00
Sylvain Becker 9a8a8e65b8 Update SDL_render_d3d11.c
Fix D3D11 compilation
2021-08-19 00:10:59 +02:00
Sylvain Becker 121114d061 Update METAL compiled shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker 2d01573bb9 Add METAL shaders 2021-08-19 00:10:59 +02:00
Sylvain Becker 1e77dae7b7 Add METAL implementation 2021-08-19 00:10:59 +02:00
Sylvain 1ebef0732a Add D3D11 implementation (not yet tested) 2021-08-19 00:10:59 +02:00
Sylvain 3ee511d71c Add software renderer implementation 2021-08-19 00:10:59 +02:00
Sylvain 37f78fc1cc Add OpenGL implementation 2021-08-19 00:10:59 +02:00
Sylvain faded41ab1 Add OpenGLES2 implementation 2021-08-19 00:10:59 +02:00
Sylvain 6e26d320c6 Add sysrender interface 2021-08-19 00:10:59 +02:00
Sylvain 53a2608bd2 Renderer opengles2: turn color Uniform into Attribute.
all attributes are copied interleaved (based on rmg-nik initial patch+
+ minor clean up of data structure
+ add check for colorswap
2021-08-19 00:10:59 +02:00
Oschowa bfa159313b audio: pipewire: Set PW_KEY_NODE_RATE to suggest a rate.
This can be used by recent pipewire to avoid resampling.
2021-08-18 12:40:13 -04:00
Aleksey Rybalkin 402b86f2a8 waylandevents: prevent segfault if xkb compose table is not found
this can happen e.g. on pure wayland system where there is no X11
locales for xkbcommon to find.
2021-08-15 10:11:19 -04:00
Jānis Rūcis 454943cf3e emscripten: Don't flag window fullscreen on external requests
Also, the condition was always true.
2021-08-14 17:04:46 +01:00
Joseph Kogut 55af8dcad9 emscripten: use emscripten_set_window_title api 2021-08-14 17:04:46 +01:00
Joseph Kogut d8baad7e48 emscripten: use emscripten_get_screen_size api 2021-08-14 17:04:46 +01:00
Charlie Birks abc04270b7 emscripten: Fix framebuffer array creation optimisation 2021-08-14 17:04:46 +01:00
Charlie Birks b4f11a3669 emscripten: Drop commented out code from the dummy driver 2021-08-14 17:04:46 +01:00
David Gow fbc364908a Use the new SDL_clamp() macro where sensible
There were a few places throughout the SDL code where values were
clamped using SDL_min() and SDL_max(). Now that we have an SDL_clamp()
macro, use this instead.
2021-08-14 09:01:14 -07:00
Charlie Birks 07a2d71e90 emscripten: Feed silence to device when paused 2021-08-14 12:24:35 +01:00
Sam Lantinga dcc5eef0e2 Clarify that one of the PIDs of the Xbox Elite Series 2 controller is used in Bluetooth mode 2021-08-14 00:31:46 -07:00
Sam Lantinga 91a55a02de Relative mouse motion is delivered to the window with keyboard focus
This was the original intent (note SDL_UpdateWindowGrab() in SDL_OnWindowFocusGained() and SDL_OnWindowFocusLost()) and fixes a bug where relative motion unexpectedly stops if the task bar is covering the bottom of the game window and the mouse happens to move over it while relative mode is enabled.

Another alternative would be to confine the mouse when relative mode is enabled, but that generates mouse motion which would need to be ignored, and it's possible for the user moving the mouse to combine with the mouse moving into the confined area so you can't easily tell whether to ignore the mouse motion. See https://github.com/libsdl-org/SDL/issues/4165 for a case where this is problematic.
2021-08-14 00:00:57 -07:00
Sam Lantinga 694771513c Get the window size for the window receiving the mouse motion
This is the mouse focus except in the case where relative motion is enabled and the mouse is over a window floating on top of the application window (e.g. the taskbar)
2021-08-14 00:00:57 -07:00
Sam Lantinga 6a1e1ed9ae Relative mouse mode grab is based on the window with the input focus
This fixes restoring the cursor clip rectangle after the mouse has moved off of the window.

Also try to better synchronize cursor visibility with mouse position changes when changing relative mode. This doesn't work perfectly, but it seems to improve things on Windows.
2021-08-14 00:00:57 -07:00
Sam Lantinga e42e9a12de Fixed build 2021-08-13 20:48:56 -07:00
Sam Lantinga 441fbcaa3d Added HIDAPI support for the Xbox Adaptive Controller 2021-08-13 20:48:54 -07:00
Sam Lantinga b5e5c1ef48 Added Ctrl-T to toggle topmost mode in test programs 2021-08-13 17:53:39 -07:00
Sam Lantinga 4d9efcb55c Fixed flag test for boolean correctness 2021-08-13 11:52:25 -07:00
Sam Lantinga b28ed02803 Don't warp the mouse for relative mode when the window doesn't have focus 2021-08-13 11:39:41 -07:00
Sam Lantinga 629e9f820a Fixed return value of SDL_GetGrabbedWindow() when we have an internal grab because of mouse relative mode 2021-08-13 11:06:43 -07:00
Sam Lantinga 6aa1498b98 This assert wasn't correct, we set the internal grab for mouse relative mode as well. 2021-08-13 11:03:19 -07:00
Sam Lantinga 907943a236 Added support for the Xbox One S Controller with 5.x series firmware 2021-08-12 17:51:08 -07:00
Joshua Root 1e92135297 Improve portability of SDL_Convert51ToStereo_AVX
Don't rely on checking __clang_major__ since it is not comparable
between different vendors. Don't use "#pragma clang attribute" since it
is only available in relatively recent versions, there's no obvious way
to check if it's supported, and just using __attribute__ directly (for
gcc as well) results in simpler code anyway.
2021-08-12 16:04:35 -07:00
Ozkan Sezer 7aec0b90ee SDL_hidapi_xboxone.c: fix bogus 'uninitialized' warning from clang.
The last 'size == 50' check is always true anyway.
2021-08-13 01:56:56 +03:00
Sam Lantinga cec5a129f5 Fixed libudev hotplug notifications in the HIDAPI driver 2021-08-12 15:49:33 -07:00
Sam Lantinga 6eb4ebb502 Simplified the HIDAPI Xbox One controller initialization 2021-08-12 15:49:33 -07:00
Simon McVittie 25cd749adb x11: Don't change mode if we are already in the correct mode
If we are already in the desired mode, changing it is a no-op at best,
and harmful at worst: on Xwayland, it sometimes happens that we disable
the crtc and cannot re-enable it.

Resolves: https://github.com/libsdl-org/SDL/issues/4630
Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-08-12 12:23:40 -07:00
Sam Lantinga 584b89abe6 Added support for the color LED on the Xbox Elite Series 2 controller 2021-08-12 08:17:10 -07:00
Sam Lantinga 64882b2466 Added support for the Xbox One Elite 2 Controller with 5.x series firmware 2021-08-12 08:17:08 -07:00
Ozkan Sezer ed6eb07e79 SDL_wasapi.c: fixed build against older SDKs. 2021-08-12 01:40:50 +03:00
Andrei Alexeyev 68ca35c318 wayland: fix memleak in output listener 2021-08-11 14:11:52 -07:00
Andrei Alexeyev e9179314c4 joystick/linux: fix memleaks; streamline joylist item removal 2021-08-11 14:11:52 -07:00
Ozkan Sezer 44a76710d1 Don't disable clang avx instrinsics on win32 if __AVX__ is defined.
C.f.: https://github.com/libsdl-org/SDL/issues/4533
2021-08-11 08:47:52 -07:00
Ethan Lee ae7ee2a59c wayland: Ignore stateless/sizeless configs when starting in fullscreen mode 2021-08-11 11:02:33 -04:00
Sam Lantinga ac32c522ad Try using the built-in WASAPI audio rate conversion
Fixes https://github.com/libsdl-org/SDL/issues/4608
2021-08-10 18:11:09 -07:00
Sam Lantinga cb1e20b058 Added KMOD_SCROLL to track the scroll lock state
Fixes https://github.com/libsdl-org/SDL/issues/4566
2021-08-10 17:50:17 -07:00
Sam Lantinga f5794f9eeb Added SDL_SetTextureUserData() and SDL_GetTextureUserData() to associate a user-specified pointer with an SDL texture 2021-08-10 15:17:59 -07:00
Sam Lantinga a0af7ce731 OSS is no longer the preferred audio backend on modern UNIX systems
Fixes https://github.com/libsdl-org/SDL/issues/4207
2021-08-10 15:05:49 -07:00
Sam Lantinga 3f6ebffff4 Updated to version 2.0.17 for development 2021-08-10 15:02:36 -07:00
Sam Lantinga 016b02f24c Fixed build, C89 doesn't allow non-constant static initializers 2021-08-10 12:17:37 -07:00
Ozkan Sezer 77c8d11137 configuration updates for dlopen:
- cmake, configure (CheckDLOPEN): --enable-sdl-dlopen is now history..
  detach the dl api discovery from SDL_LOADSO_DLOPEN functionality.
  define HAVE_DLOPEN. also define DYNAPI_NEEDS_DLOPEN (CheckDLOPEN is
  called only for relevant platforms.)
- update SDL_config.in and SDL_config.cmake accordingly.
- SDL_dynapi.h: set SDL_DYNAMIC_API to 0 if DYNAPI_NEEDS_DLOPEN is
  defined, but HAVE_DLOPEN is not.
- pthread/SDL_systhread.c: conditionalize dl api use to HAVE_DLOPEN
- SDL_x11opengl.c, SDL_DirectFB_opengl.c, SDL_naclopengles.c: rely
  on HAVE_DLOPEN, not SDL_LOADSO_DLOPEN.
- SDL_config_android.h, SDL_config_iphoneos.h, SDL_config_macosx.h,
  SDL_config_pandora.h, and SDL_config_wiz.h: define HAVE_DLOPEN.

Closes: https://github.com/libsdl-org/SDL/pull/4351
2021-08-10 12:07:32 -07:00
hgs3 cb0fd05eeb Adding a clarifying comment in case a programmer unfamiliar with UTF-16 and UTF-32's relationship chances upon the code. 2021-08-10 12:07:11 -07:00
Henry G. Stratmann III 3470112969 Optimizing the implementation. 2021-08-10 12:07:11 -07:00
Henry G. Stratmann III 712e0d1f06 Fixing WM_CHAR event handling for Unicode characters outside the Basic Multilingual Plane. 2021-08-10 12:07:11 -07:00
Sam Lantinga fcfd19db86 Added support for SDL_RENDERER_PRESENTVSYNC to the software renderer
This fixes https://github.com/libsdl-org/SDL/issues/4612
2021-08-10 12:02:59 -07:00
Sebastian Krzyszkowiak 25f9ed87ff audio: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly;
for example "a" can get matched with "alsa" since it only checks
whether the string matches up to the length of the requested
driver name.
2021-08-10 08:34:07 -07:00
Sebastian Krzyszkowiak b3a989d0df video: Fix false positives in driver name comparison
Without this change, driver names don't get matched correctly;
for example "x" can get matched with "x11" since it only checks
whether the string matches up to the length of the requested
driver name.
2021-08-10 08:34:07 -07:00
Sam Lantinga de6ba40d9e Added support for the Flydigi Vader 2 controller in 2.4G Android mode 2021-08-09 11:38:22 -07:00
Sam Lantinga 3f440daad9 Added support for the Flydigi Vader 2 controller in Bluetooth mode 2021-08-09 10:40:36 -07:00
Cameron Gutman 6ae227d011 x11/wayland: fix screensaver suspension via D-Bus
b08b1bde introduced a subtle bug. Despite not using D-Bus types directly,
the code used the SDL_USE_LIBDBUS definition set by SDL_dbus.h to conditionally
compile calls SDL_DBus_ScreensaverTickle() and SDL_DBus_ScreensaverInhibit().
As a result, it still compiled without SDL_dbus.h included, but screensaver
suspension silently failed to work.

The D-Bus stuff could probably use some tweaks to be harder to accidentally
break, but for now just restore the header includes.
2021-08-08 23:47:42 -05:00
Sebastian Krzyszkowiak 2e6dac870f wayland: Add a hint to allow disabling libdecor use
Useful for testing xdg-shell path with compositors like Weston.
2021-08-08 18:05:47 -07:00
Cameron Gutman 092a20d945 wayland: Avoid busy waiting for vsync 2021-08-08 18:04:08 -07:00
Cameron Gutman 791d9d3ff6 Fixed DInput mapping for NVIDIA Virtual Gamepad 2021-08-07 14:20:43 -07:00
Ethan Lee 7be970db31 wayland: Avoid setting floating width/height when re-entering fullscreen 2021-08-06 19:51:27 -04:00
Sam Lantinga bec783571b Better fix for compiling using clang on Windows
This fixes https://github.com/libsdl-org/SDL/issues/4533
2021-08-06 14:20:55 -07:00
Sam Lantinga a91ab883e9 Fixed building on Windows with cmake, ninja, and clang 2021-08-06 12:28:24 -07:00
Ryan C. Gordon dd683073bb
hidapi: Patched to compile on QNX.
Fixes #4591.
2021-08-06 15:13:40 -04:00
Sam Lantinga cae7bd9b65 Don't use AVX with clang if the compiler isn't building with AVX instructions
Fixes https://github.com/libsdl-org/SDL/issues/4533
2021-08-06 12:01:24 -07:00
Ethan Lee 10979d37fb wayland: Always assume configure is wrong for non-resizable windows.
Configure events from compositors have an extremely annoying habit of giving us
completely bogus sizes, from all sorts of places. Thankfully, the protocol
gives us the ability to completely ignore the width/height and just stick with
what we know, so for all windows that are not meant to be resized, pretend we
never even got the width/height at all, the compositor is required to respect
our dimensions whether they match configure's suggestion or not.
2021-08-05 17:19:11 -04:00
Sam Lantinga 88674b4a0e Fixed build 2021-08-04 13:17:35 -07:00
Sam Lantinga c14813a879 Fixed spacing 2021-08-04 13:00:14 -07:00
Sam Lantinga 3cad447ee7 Only update the window size if setting the display mode succeeded 2021-08-04 12:57:51 -07:00
Daniel Gibson 0eb6f79190 SDL_SetWindowDisplayMode(): If already fullscreen, adjust window size
Otherwise only the display resolution is changed, but the SDL window size
(and for example the window-surface size) aren't adjusted accordingly
and thus don't fill the whole screen.
See #3313
2021-08-04 12:48:48 -07:00
Daniel Gibson 72d8128520 Improve SDL_CreateWindow() fullscreen support on Windows
.. and maybe other platforms as well (though X11 was not affected)?

The issue was that passing a higher resolution than the current desktop
resolution to SDL_CreateWindow() with SDL_WINDOW_FULLSCREEN didn't switch
to that resolution (even though it did switch to lower resolutions).

When creating a fullscreen window, window->fullscreen wasn't even set
at all (only zeroed out), setting it only happened if the user explicitly
called SDL_SetWindowDisplayMode(). So without that, SDL_CreateWindow()
-> SDL_UpdateFullscreenMode() -> SDL_GetWindowDisplayMode() used the
resolution from window->windowed.w/h which were limited to the desktop size
due to some weird combination of WIN_AdjustWindowRectWithStyle() and
WIN_WindowProc() being called after a call to SetWindowPos().

fixes #3313
2021-08-04 12:48:48 -07:00
Sam Lantinga 9fdb06450d Added support for the Joy-Con Charging Grip when SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS is enabled 2021-08-04 11:34:06 -07:00
Ryan C. Gordon d483970262
dbus: Wrap init in a spinlock.
This prevents a race if two threads that need d-bus try to init it at the
same time. Note that SDL_Init will likely handle this from a single thread
at startup, but there are places outside of init where one might trigger
D-Bus init, like setting thread priority (a common first thing for a new
thread to do) resulting in SDL trying to use RTKit.

Fixes #4587.
2021-08-04 13:30:12 -04:00
Cameron Gutman b08b1bde66 linux: remove d-bus lazy init dead code
Lazy init in X11/Wayland is dead code since dbdbae4
2021-08-04 13:14:57 -04:00
Ryan C. Gordon 5fc13fcb21 direct3d: Commit viewport state before clearing, attempt 2.
This reintroduces the fix from 0e16ee8330, but just marks
the viewport state as dirty after a clear that needs to expand the
viewport to fill the render target, as we'll need to also reset
the orthographic projection state elsewhere, and that won't
happen if we clear the dirty flag here.

Fixes #4210.
(again.)
(...sorry...!)
2021-08-04 07:00:17 -04:00
Ryan C. Gordon ed6ce5ccb0
log: Fixed compiler warnings on 64-bit Visual Studio. 2021-08-04 02:34:09 -04:00
Ryan C. Gordon 7e88e772d7
winrt: Fixed incorrect code in a Windows Phone #ifdef. 2021-08-04 02:30:47 -04:00
Ethan Lee 32f909f7e3 wayland: Remove redundant waylanddyn.h includes.
All files including waylanddyn.h already include waylandvideo.h first.
2021-08-03 14:57:22 -04:00
Ethan Lee 124405a0bc wayland: Fix building without Vulkan support 2021-08-03 14:57:22 -04:00
David Gow 4077f7a2d9 Update the Renderer dpi_scale on SIZE_CHANGED event (fix #4580)
The Renderer logical scaling code scales mouse coordinates, and needs to
take the window DPI into account on HIGHDPI windows. However, the
variable which tracks this, renderer->dpi_scale, is set once when the
renderer is created, and then not updated. In the event that the window
is moved to another screen, or the screen DPI otherwise changes, this
will be outdates, and potentially the coordinates will be all wrong.

So let's update the dpi_scale on the SIZE_CHANGED event: it's at least a
possibility that this will be issued on some OSes when DPI changes, and
it's otherwise already handled by SDL_Renderer's event filter.
2021-08-03 09:30:43 -07:00
Sam Lantinga 9b4884d58a Warn if you're building a partially functional RAWINPUT driver without device notifications 2021-08-03 09:25:14 -07:00
Sam Lantinga 886eb02eba Fixed detection of Steam Virtual Gamepad with the WGI driver 2021-08-03 09:25:14 -07:00
Sam Lantinga 7c63e1d37a Added WGI mappings for the Amazon Luna and Google Stadia controllers 2021-08-03 09:25:14 -07:00
Sam Lantinga 99c8972b25 Added WGI mappings for PS4 and PS5 controllers 2021-08-03 09:25:14 -07:00
Sam Lantinga 2dfc92ca1e Added default mapping for WGI game controllers 2021-08-03 09:25:13 -07:00
Sam Lantinga 9d64e6b442 Revert "direct3d: Commit dirty viewport state before clearing."
This reverts commit 0e16ee8330.
2021-08-03 00:29:33 -07:00
Sam Lantinga 993a56766d Only use the default Xbox mapping on Linux
On Windows, this is already covered by XInput and is the wrong mapping if we try to use it with DirectInput/RAWINPUT/WGI controllers
2021-08-03 00:15:24 -07:00
Ryan C. Gordon 0e16ee8330 direct3d: Commit dirty viewport state before clearing.
Otherwise you might have set the viewport to the full size of
the render target in SDL's API but this change hasn't been
transmitted to Direct3D yet by the time we attempt to clear.

Fixes #4210.
2021-08-03 02:32:56 -04:00
Sam Lantinga 7edc7d5392 Added a mapping for the Steam Virtual Gamepad when it's detected in DirectInput mode 2021-08-02 22:45:07 -07:00
Ryan C. Gordon 350ca0f908 winrt: Don't register orientation hint callback in startup code.
SDL_AddHintCallback() uses SDL_malloc(), which means this would
run before main(), so the app wouldn't be able to supply its own
replacement SDL_malloc() implementation in time.

This code was moved to under SDL_Init. Since the hint callback
already makes efforts to not override the app manifest's
orientation settings, this is safe to move until after pre-main()
startup.

Fixes #4449.
2021-08-03 05:07:39 -04:00
Ryan C. Gordon 834a84fabb winrt: Don't use LoadLibraryA on WinRT.
This removes the CM_Register_Notification code on WinRT. Note
that this API _is_ available to UWP apps as of Windows 10.0.17763
(version 1809, released October 2018), according to:

https://docs.microsoft.com/en-us/uwp/win32-and-com/win32-apis#apis-from-api-ms-win-devices-config-l1-1-1dll

So it might be worth readding with some sort of preprocessor check
for minimum targeted version, or whatever is appropriate for WinRT
development.
2021-08-03 05:07:39 -04:00
Ethan Lee 7082fb04af wayland: Only dispatch on fullscreen set when the window is visible.
Fixes hang-on-startup described in #4572.
2021-08-02 22:42:30 -04:00
Ethan Lee 0f5b8a99f0 wayland: For libdecor, dispatch immediately after setting fullscreen
Reference: #4578
2021-08-02 19:48:31 -04:00
Sam Lantinga 022235012c Fixed crash if WGI didn't give us the name for a controller 2021-08-02 16:40:58 -07:00
Ethan Lee 4562da622c wayland: Make libdecor configure match xdg_toplevel 2021-08-02 18:56:14 -04:00
Ethan Lee 1fb1aa1983 wayland: Keep the fullscreen check for maximize/restore events 2021-08-02 12:57:28 -04:00
Ethan Lee 584673a5a1 wayland: Don't ignore configs for non-fullscreen, non-resizable windows.
This was causing configure events to not inform SDL of window size
changes, even when they were based on resizes that we fully expected. The
result was fullscreen->windowed not working at all, because it would
retain the desktop resolution instead of reverting to the floating size
that it had before moving to fullscreen mode.

Fixes Super Hexagon fullscreen toggling.
2021-08-02 12:54:39 -04:00
Sebastian Krzyszkowiak 2506729893 wayland: Flush in SetWindowFullscreen
The flush has been removed in e5f9fae034.
Unfortunately, even though ideally the flush shouldn't be necessary,
our resize sequence isn't... well, perfect, and removing that flush causes
tons of troubles.

We're also still flushing in other paths where the window size can be
changed by the compositor and where we may potentially have to obey that
change, like in Wayland_MaximizeWindow.

This also removes the hack introduced in 7f261d3b76,
which introduces problems with protocol violations and seems to not be
necessary when flushing.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak ea28187cd5 wayland: Hack surface resize into compliance with set_window_geometry
We have issues with correct resize sequence and happen to commit old-sized
buffers even after configure event for the new size has been already
acknowledged. While the reason for that stays unknown, let's at least
workaround the problem by faking window geometry into expected size.
This does not fix visual glitch on e.g. fullscreen toggling, but having
a split-second glitch is still a much better outcome than being
terminated by the compositor for protocol violation.
2021-08-02 12:18:23 -04:00
Sebastian Krzyszkowiak b5210cac44 wayland: Initialize floating size at window creation
This allows the windowed size to be restored for windows initially
created already in non-floating state.
2021-08-02 12:11:06 -04:00
Ethan Lee dab33844e3 wayland: Fix a warning in handle_configure_xdg_toplevel 2021-08-02 12:05:13 -04:00
Ethan Lee 754aa2d321 Mostly revert cfcdfb7be9.
This was causing window changes to completely break, resulting in broken
decorations and bizarre frame timing, I don't know what exactly it's doing
but it's not good. Kept the libdecor_frame_is_floating logic, at least.
2021-08-02 12:05:10 -04:00
Ethan Lee 8803589fc3 wayland: Avoid redundant SetWindowBordered for libdecor 2021-08-02 12:05:06 -04:00
Sebastian Krzyszkowiak b4c4060ad2 wayland: Clean up Wayland_HandlePendingResize
Commit 871c11191b removed delayed
resize handling, but it left the whole structure untouched that
now became unnecessary. To help with code clarity, get rid
of the structure where pending resize state used to be stored
and pass all the data directly to Wayland_HandlePendingResize
(now renamed to Wayland_HandleResize, since it's not "pending"
anymore but applied immediately)
2021-08-01 21:07:51 -07:00
Sebastian Krzyszkowiak 9bb24ad0cf wayland: Always call Wayland_SetWindowBordered when showing the window
Otherwise our windows have no window decoration on compositors that
support xdg-decoration-unstable-v1, but default to client-side mode.

Contrary to what the comment was stating, there is nothing in the protocol
that would make redundant calls to zxdg_toplevel_decoration_v1::set_mode
problematic.
2021-08-01 21:07:14 -07:00
Christian Rauch cfcdfb7be9 libdecor: use same fullscreen/maximised restore logic as for xdg-toplevel 2021-08-01 15:14:44 -07:00
Christian Rauch 42452f8ca5 wayland: store and restore floating states
Some Wayland compositors send (0,0) as "suggested" configure event sizes to
indicate that the client has to decide on its own which sizes to used. This
is commonly done when restoring from maximised, fullscreen or tiles states
to fullscreen.
We now store the last known floating states in a new set of variables and
restore them when we receive such a (0,0) configure event.
2021-08-01 15:14:44 -07:00
Sebastian Krzyszkowiak d4e1b4974a unix: OpenURL: Move unsetenv above vfork
From the vfork manpage:

> The  vfork()  function has the same effect as fork(2), except that
> the behavior is undefined if the process created by vfork() either
> modifies any data other than a variable of type pid_t used to store
> the return value from vfork(), or returns from the function in which
> vfork() was called, or calls any other function before successfully
> calling _exit(2) or one of the exec(3) family of functions.

unsetenv is still called inside a child process, so it does not
influence the rest of the application.
2021-08-01 03:58:49 -07:00
Sam Lantinga 9b7b928765 Clear LD_PRELOAD so Chrome opens correctly when this application is launched by Steam
This fixes https://github.com/libsdl-org/SDL/issues/4565
2021-07-31 23:28:59 -07:00
Sebastian Krzyszkowiak 54aea2446e wayland: Disable key repeat when repeat rate equals 0
This fixes a crash on pressing keyboard button when compositor sends
zero as repeat rate, indicating that key repeat should be disabled.

From Wayland protocol spec:

> Negative values for either rate or delay are illegal. A rate of zero
> will disable any repeating (regardless of the value of delay).
2021-07-31 21:40:27 -07:00
Sam Lantinga b033cd0d2e Fixed XSync sequence to match other cases where we set the X11 error handler 2021-07-31 16:01:48 -07:00
Ryan C. Gordon 4c7825f6bd
x11: XSync while trying to catch XRRSetScreenSize error.
Reference issue #4561
2021-07-31 18:27:14 -04:00
Sam Lantinga cb1fd30e9a Updated to version 2.0.16 for release 2021-07-31 13:28:54 -07:00
Ryan C. Gordon d0effadf68
x11: Don't let XRRSetScreenSize fire a BadMatch error.
This is a workaround and not a proper fix, but this is possibly complicated,
and possibly a corner case, so this will do for 2.0.16, if not the
foreseeable future.

Reference issue #4561
2021-07-31 15:58:31 -04:00
Sam Lantinga 3a4b217d6c Allow defining SDL_MAIN_HANDLED on iOS if you're using another runtime that provides an application delegate 2021-07-31 12:44:29 -07:00
Sam Lantinga deed21a83d Removed useless forward declaration 2021-07-31 12:44:11 -07:00
Ethan Lee e5594e6677 wayland: Prefer our SSD implementation if available 2021-07-30 22:19:48 -07:00
Sam Lantinga 2d0075eff8 Updated comments for third party Nintendo Switch controllers 2021-07-30 18:23:43 -07:00
Sam Lantinga 16010f7561 Added support for the PowerA Nintendo Switch Fusion Arcade Stick 2021-07-30 18:23:43 -07:00
Sam Lantinga b33f470901 Fixed detection of the PDP Afterglow Wireless Switch Controller over Bluetooth 2021-07-30 18:23:42 -07:00
Sam Lantinga 6af6950dbc Added support for the Victrix Gambit Tournament Controller 2021-07-30 18:23:42 -07:00
Sam Lantinga 243a8836af The PowerA Nintendo Switch Fusion Pro Controller has a working USB mode, enabled via the switch on the underside of the controller. 2021-07-30 18:23:41 -07:00
Ethan Lee 71897cc1c9 wayland: Always trigger a resize when handling a configure event.
When we removed the OpenGL resize workaround it introduced a problem for
fullscreen windows in particular: When leaving fullscreen we tried to send a
resize event, but UpdateFullscreenMode would send a SIZE_CHANGED immediately
after, deleting our resize event and causing the following configure event's
resize to be ignored. This timing issue resulted in fullscreen windows not
being resized at all when becoming a floating window.

By always forcing resize events from configure events, we ensure that RESIZED
always makes it through. SetWindowSize-type changes should be unaffected as
they do not fire configure events.
2021-07-30 16:05:06 -04:00
David Gow 8f06a629aa render: Fix -Wmaybe-uninitialized warning in RenderDrawLinesWithRects{,F}
The RenderDrawLinesWithRects and RenderDrawLinesWithRectsF functions can
sometimes call QueueCmdFillRects() with the data pointed to by frects
uninitialised. This can occur if none of the lines can be replaced with
rects, in which case the frects array is empty, and nrects is 0.

gcc 10.3.0 will detect this possibility, and print a warning like:
/home/david/Development/SDL/src/render/SDL_render.c: In function 'RenderDrawLinesWithRectsF':
/home/david/Development/SDL/src/render/SDL_render.c:2725:15: warning: '<unknown>' may be used uninitialized [-Wmaybe-uninitialized]
 2725 |     retval += QueueCmdFillRects(renderer, frects, nrects);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/david/Development/SDL/src/render/SDL_render.c:499:1: note: by argument 2 of type 'const SDL_FRect *' to 'QueueCmdFillRects' declared here
  499 | QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect * rects, const int count)
      | ^~~~~~~~~~~~~~~~~

This is harmless, because when this is uninitialised, nrects is always
0, so QueueCmdFillRects() does nothing anyway. We therefore can work
around this by only calling QueueCmdFillRects() when nrects is nonzero.
Somewhat impressively, gcc recognises that this is now safe.
2021-07-30 10:53:49 -04:00
Ethan Lee c20ab7dae9 wayland: Fix GetWindowWMInfo for <2.0.15 2021-07-30 00:16:52 -07:00
Ryan C. Gordon 585c11c5ae
direct3d: Fix possibly-incorrect scissor test when clearing.
Thanks to @JayFoxRox who did the detective work on this!

Fixes #3357.
2021-07-30 00:33:15 -04:00
Cameron Gutman 6f684f674e cocoa: Add keyboard grab support
CGSSetGlobalHotKeyOperatingMode() is not a public API, so we will only
compile this in if SDL_MAC_NO_SANDBOX=1 is defined during compilation.
2021-07-29 19:06:43 -07:00
Sam Lantinga 69518b9ecc Make sure we don't send a resize event while a window is being destroyed
This fixes https://github.com/libsdl-org/SDL/issues/3669
2021-07-29 17:09:24 -07:00
Ryan C. Gordon 659e1f0a3f
audiocvt: The to-5.1 converters now soften FL and FR channels more.
This is experimental and might be tweaked further.

Reference #4104.

Also reference:

https://github.com/Keriew/augustus/issues/194#issuecomment-847655049
2021-07-29 17:55:59 -04:00
Christian Rauch f20a85818c commit after setting/unsetting limits 2021-07-29 14:55:03 -07:00
Sam Lantinga 9984891ba8 Use the wl_touch object as a touch ID on Wayland (thanks @russelltg!)
This fixes https://github.com/libsdl-org/SDL/issues/4517
2021-07-29 14:46:24 -07:00
Ethan Lee 74162b7401 wayland: Add support for text-input-unstable-v3 2021-07-29 14:43:46 -07:00
Jessica Clarke 02daab8736 Fix pointer provenance in SDL_SIMDRealloc
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

The C standard does not guarantee that if two pointers compare equal
they are the same pointer, as C pointers have a notion of provenance,
and compilers have been known to exploit this during optimisation. For
CHERI, this becomes even more important, as in-place expansion can
result in realloc returning a capability to the same address but with
increased capability bounds, and so reusing the old capability will trap
trying to access outside the bounds of the original allocation.

In the case that ptr == mem, memdiff and ptrdiff should still be equal,
so the only overhead is a small amount of pointer arithmetic and a store
of the new pointer (which is required per the C standard in order to not
be undefined behaviour when next loaded).

This also fixes the calculation of oldmem to use uintptr_t rather than
size_t as casting the pointer to size_t on CHERI will strip the
capability metadata, including the validity tag, with the subsequent
cast back to void * resulting in a null-derived capability whose
validity tag is clear and thus cannot be dereferenced without trapping.
2021-07-29 14:42:15 -07:00
Jessica Clarke 8f38ba4d68 Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.

The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
2021-07-29 14:42:15 -07:00
Sam Lantinga 9d457aa446 Don't uninitialize COM because of what appears to be a bug in Microsoft WGI reference counting.
This fixes https://github.com/libsdl-org/SDL/issues/4488
2021-07-29 14:25:13 -07:00
Sam Lantinga b3a0174b26 Scale the values correctly based on the sensor type (thanks @meyraud705) 2021-07-29 14:25:13 -07:00
Sam Lantinga a186a503e7 Added SDL_GameControllerGetSensorDataRate() to get the sensor update rate for a controller. 2021-07-29 06:43:39 -07:00
Brick 53987e9b4f Optimized SDL_Convert51ToStereo_AVX 2021-07-28 16:11:04 -07:00
Sam Lantinga 8e35ff5cb3 By default minimize real fullscreen windows when they lose focus so the desktop video mode is restored.
This fixes https://github.com/libsdl-org/SDL/issues/4039
2021-07-28 14:20:29 -07:00
Aaron Plattner 1e07dba09b x11: Use glXChooseFBConfig when available in X11_GL_GetVisual
When choosing an X11 Visual for a window based on its GLX capabilities, first
try glXChooseFBConfig (if available) before falling back to glXChooseVisual.
This normally does not make a difference because most GLX drivers create a
Visual for every GLXFBConfig, exposing all of the same capabilities.

For GLX render offload configurations (also know as "PRIME") where one GPU is
providing GLX rendering support for windows on an X screen running on a
different GPU, the GPU doing the offloading needs to use the Visuals that were
created by the host GPU's driver rather than being able to add its own. This
means that there may be fewer Visuals available for all of the GLXFBConfigs the
guest driver wants to expose. In order to handle that situation, the NVIDIA GLX
driver creates many GLXFBConfigs that map to the same Visual when running in a
render offload configuration.

This can result in a glXChooseVisual request failing to find a supported Visual
when there is a GLXFBConfig for that configuration that would have worked. For
example, when the game "Unnamed SDVX Clone" [1] tries to create a configuration
with multisample, glXChooseVisual fails because the Visual assigned to the
multisample GLXFBConfigs is shared with the GLXFBConfigs without multisample.

Avoid this problem by using glXChooseFBConfig, when available, to find a
GLXFBConfig with the requested capabilities and then using
glXGetVisualFromFBConfig to find the corresponding X11 Visual. This allows the
game to run, although it doesn't make me any better at actually playing it...

Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Fixes: https://forums.developer.nvidia.com/t/prime-run-cannot-create-window-x-glxcreatecontext/180214

[1] https://github.com/Drewol/unnamed-sdvx-clone
2021-07-28 13:48:16 -07:00
Ozkan Sezer cf85710cf8 SDL_audiocvt.c: disable AVX for clang < 5 and gcc < 4.9
See: https://github.com/libsdl-org/SDL/issues/4533
2021-07-28 22:55:10 +03:00
Ryan C. Gordon cc4ab10195
windows: convert "//" comment to "/**/", add a FIXME.
Reference #4129
Reference #4177
2021-07-28 14:37:33 -04:00
Adam a203194893
Added in a MIME-type to the X11 clipboard. (#4385) 2021-07-28 14:06:51 -04:00
Ethan Lee ad310d3900 wayland: libdecor support for SetWindowModalFor 2021-07-28 09:45:10 -07:00
Ethan Lee 93976ade3b wayland: libdecor support for GetWindowWMInfo 2021-07-28 09:45:10 -07:00
David Gow 1fb4429bc0 wayland: Avoid a pointer→TouchID cast warning
As of [1], SDL now compiles with a warning in SDL_waylandevents.c on
32-bit systems under gcc 10.3.0:

/tmp/SDL/src/video/wayland/SDL_waylandevents.c: In function 'seat_handle_capabilities':
/tmp/SDL/src/video/wayland/SDL_waylandevents.c:958:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  958 |         SDL_AddTouch((SDL_TouchID)seat, SDL_TOUCH_DEVICE_DIRECT, "wayland_touch");
      |                      ^
/tmp/SDL/src/video/wayland/SDL_waylandevents.c:964:22: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  964 |         SDL_DelTouch((SDL_TouchID)seat);
      |                      ^

This is due to SDL_TouchID always being 32-bit, but seat being a pointer
which is (obviously) only 32-bit on 32-bit systems. The conversion is
therefore harmless, so silence it with an extra cast via intptr_t.

This is what the cocoa backend does (and is similar to what the Win32
backend does, except with size_t).

Fixes: 03c19efbd1 ("Added support for multiple seats with touch input on Wayland")

[1]: 03c19efbd1
2021-07-28 09:05:23 -07:00
David Gow 18303c92bc Wayland: Fix building with --disable-wayland-shared with libdecor.
When wayland is not dynamically loaded (--enable-wayland-shared=no)
libdecor.h is not included unless SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC
is set, so it fails to build.  We can't simply move the libdecor.h
include above the #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC block, as
libdecor.h itself #includes wayland headers we need to replace with
#defines. Instead, duplicate the #include.

Fixes https://github.com/libsdl-org/SDL/issues/4543

Note that this doesn't fix any of the underlying issues of libdecor
being treated as part of wayland, it just fixes the build. A better
solution would probably be to decouple the wayland dynamic loading
from the libdecor dynamic loading completely, though that is a lot
more work...
2021-07-28 17:01:02 +03:00
David Gow 21cba92423 wayland: Don't create zxdg toplevel decoration twice
Each window can have at most one zxdg toplevel decoration, but as of
[1], we accidentally create two. (If libdecor is not in use). This
causes wayland windows with server-side decorations (e.g. on KDE/KWin)
to crash with the message:

zxdg_decoration_manager_v1@7: error 1: decoration has been already constructed

This extra zxdg_decoration_manager_v1.get_toplevel_decoration() call was
introduced while deprecating wl-shell and xdg-shell-stable[1] support,
and possibly was a bad interaction with [2], which moved the decoration
creation around.

Fixes: 6aae5b44f8 ("Remove wl-shell and xdg-shell-unstable-v6 support (#4323)")

[1]: https://github.com/libsdl-org/SDL/pull/4323
[2]: https://github.com/libsdl-org/SDL/pull/4374
2021-07-28 04:12:39 -07:00
Ethan Lee 7b239edb83 wayland: Assign frame_callback on window creation.
Fixes a crash when creating and destroying a window without calling SwapWindow.
2021-07-28 00:48:05 -07:00
Sam Lantinga 41e1a2360f Correct the maximized size and position for borderless resizable windows
This fixes bug https://github.com/libsdl-org/SDL/issues/4043
2021-07-27 16:51:08 -07:00
Ethan Lee 03185e748b wayland: Tag/Check wl_output objects as well, fixes crashes when libdecor is in use 2021-07-27 16:05:53 -07:00
Ryan C. Gordon 871c11191b wayland: handle pending resizes immediately, not on SwapWindow.
This was originally a workaround for an old Mesa bug, since fixed, apparently,
and causes other problems.

Fixes #4326.
2021-07-27 18:24:09 -04:00
Sam Lantinga 51c61d7cdf Run the entire Cocoa messagebox function on the main thread.
This fixes bug https://github.com/libsdl-org/SDL/issues/4420
2021-07-27 14:57:18 -07:00
Sam Lantinga dfd3f30e88 Make Cocoa_HandleTitleButtonEvent() static since it's not used anywhere else 2021-07-27 14:27:37 -07:00
Ethan Lee a3eb297ec2 wayland: Rework enter/leave and update_scale_factor to avoid bogus wl_output data.
Also remove get_window_scale_factor() which was just pointless indirection.
2021-07-27 14:21:32 -07:00
Simon Zeni 6aae5b44f8
Remove wl-shell and xdg-shell-unstable-v6 support (#4323)
* wayland-protocol: update wayland.xml to 1.19.0

* wayland: remove shell_surface field from SDL_SysWMinfo

* wayland: remove wl_shell support

* waypand-protocols: update xdg-shell.xml to 1.20

* wayland: remove xdg-shell-unstable-v6 support

* wayland: deprecate wl shell surface syswm info, add xdg surface
2021-07-27 14:12:26 -07:00
Sam Lantinga 88e4755c26 Make sure we don't try to turn on relative mouse mode while clicking on the window title bar.
This fixes bug https://github.com/libsdl-org/SDL/issues/4469
2021-07-27 12:43:45 -07:00
Splamy c72aef2664 Fixed microphone randomly stop working
WASAPI_WaitDevice is used for audio playback and capture, but needs to
behave slighty different.
For playback `GetCurrentPadding` returns the padding which is already
queued, so WaitDevice should return when buffer length falls below the
buffer threshold (`maxpadding`).
For capture `GetCurrentPadding` returns the available data which can be
read, so WaitDevice can return as soon as any data is available.

In the old implementation WaitDevice could suddenly hang. This is
because on many capture devices the buffer (`padding`) wasn't filled
fast enough to surpass `maxpadding`. But if at one point (due to unlucky
timing) more than maxpadding frames were available, WaitDevice would not
return anymore.

Issue #3234 is probably related to this.
2021-07-27 14:19:11 -04:00
Ryan C. Gordon 4ef8674df1
Revert "wasapi: Open capture devices the way we used to."
This reverts commit 0d0fee7569.
2021-07-27 14:18:44 -04:00
Ryan C. Gordon 0d0fee7569
wasapi: Open capture devices the way we used to.
This should work around the regression in #3234, since it basically reverts
the problem change, but only for capture devices.

Fixes #3234.
2021-07-27 14:13:31 -04:00
Ryan C. Gordon f4eb7f329e
spinlock: Favor gcc-style atomics over MSVC interfaces.
This resolves a problem when using Clang on Windows.

Fixes #4346.
2021-07-27 13:45:33 -04:00
Ryan C. Gordon 736a424ff4
pulseaudio: Optionally add "monitor" sources to device list.
There's a new hint to enable this.

Fixes #2917.
2021-07-27 13:12:57 -04:00
Ryan C. Gordon 8d790b10f8
audiocvt: stereo-to-mono SSE3 now uses unaligned accesses.
On modern CPUs, there's no penalty for using the unaligned instruction on
aligned memory, but now it can vectorize unaligned data too, which even if
it's not optimal, is still going to be faster than the scalar fallback.

Fixes #4532.
2021-07-27 12:23:46 -04:00
Sam Lantinga 2a53f8315a Fixed controllers showing up under both MFI and HIDAPI drivers
The Game Controller Kit doesn't show the controllers at startup, so the HIDAPI driver sees them first and therefore gets preference when a controller is supported by both drivers.

This fixes bug https://github.com/libsdl-org/SDL/issues/4209
2021-07-26 23:29:20 -07:00
Sam Lantinga 46869db01c Fixed controller rumble on macOS
Needed to add a strong reference to the haptics engine
2021-07-26 23:27:13 -07:00
Sam Lantinga a850fec733 Added missing mapping for the Xbox Elite Controller on Linux
This fixes https://github.com/ValveSoftware/steam-for-linux/issues/7826
2021-07-26 15:05:02 -07:00
Ozkan Sezer d80ef3e5f5 SDL_VideoInit: silence 'may be used uninitialized' warning
src/video/SDL_video.c:475: warning: 'i' may be used uninitialized in this function
2021-07-26 22:51:24 +03:00
Luis Cáceres 45de0a1d13 Support comma-separated lists in SDL_AUDIODRIVER 2021-07-26 15:14:54 -04:00
Luis Cáceres 5ec69285fa Support comma-separated lists in SDL_VIDEODRIVER 2021-07-26 15:14:54 -04:00
Sam Lantinga ba8bc143c1 Sort joystick entries in /dev/input
This fixes https://github.com/libsdl-org/SDL/issues/4430
2021-07-26 12:09:33 -07:00
Sam Lantinga 8d527def81 Revert "hidapi_switch: Implement HD rumble effect (#4538)"
This reverts commit 19082b115b, which broke rumble on the Nintendo Switch Pro controller
2021-07-26 10:18:18 -07:00
Narr the Reg 19082b115b
hidapi_switch: Implement HD rumble effect (#4538) 2021-07-26 10:00:53 -07:00
Christian Rauch ac904b8e95 wayland: ignore resize in fullscreen or maximised mode 2021-07-25 14:54:12 -07:00
Christian Rauch ee062c644a wayland: implement toggling decorations 2021-07-25 14:54:12 -07:00
Christian Rauch 2b3cf36fd9 wayland: forward window events 2021-07-25 14:54:12 -07:00
Christian Rauch 48066984b7 wayland: enable/disable ACTION_RESIZE for fullscreen 2021-07-25 14:54:12 -07:00
Christian Rauch 9e6fcbe72c wayland: client-side decoration 2021-07-25 14:54:12 -07:00
Christian Rauch e5f9fae034 wayland: don't flush after setting fullscreen 2021-07-25 14:54:12 -07:00
Mathieu Eyraud 8e604a5f12 Fix error handling in X11_SetWindowTitle
X11_XChangeProperty return 1 on success.
2021-07-25 14:51:33 -07:00
Jaylon Gowie bc3b98f3ed Replace with SDL_SendKeyboardKeyAutoRelease 2021-07-25 07:41:30 -07:00
Jaylon Gowie 5cd37c0a7b Add Enter Key support to PSVita IME keyboard 2021-07-25 07:41:30 -07:00
Sam Lantinga 10ec4c8671 Added support for the PowerA Nintendo Switch Spectra Controller 2021-07-24 22:11:22 -07:00
Sam Lantinga 3c9559f765 Don't try to rumble third-party Nintendo Switch Pro controllers
Sending rumble to the PowerA Spectra Nintendo Switch controller hangs input reports for a couple of seconds.
2021-07-24 19:43:56 -07:00
Sam Lantinga cc19b13bc3 Fixed missing return statement 2021-07-24 19:21:29 -07:00
Sam Lantinga d4ac6b5ed9 Detect buffer overflow when getting DirectInput device state
This fixes bug https://github.com/libsdl-org/SDL/issues/4528
2021-07-24 15:58:33 -07:00
Sam Lantinga 3b85e3fdfc Fixed internal Windows key state when using Windows+Space or Windows+G shortcuts
This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4369
https://github.com/libsdl-org/SDL/issues/4500
2021-07-24 15:47:11 -07:00
Sam Lantinga 03c19efbd1 Added support for multiple seats with touch input on Wayland
This fixes bug https://github.com/libsdl-org/SDL/issues/4517
2021-07-24 15:25:50 -07:00
Sam Lantinga ff1b5e1bf7 Implemented the window flash operations for X11 2021-07-24 15:11:36 -07:00
Ryan C. Gordon 5ae0dd4b52
joystick: Split out Linux opening code for reuse by querying code.
This prevents an assertion whem LINUX_JoystickGetGamepadMapping tried to
open the stick temporarily and messed with global state by doing so. Now
the global state is only set in LINUX_JoystickOpen, but the common code
is shared by both interfaces.

Fixes #4198.
2021-07-24 17:48:26 -04:00
Sam Lantinga f1633127d1 Added a window flash operation to be explicit about window flash behavior 2021-07-24 13:42:19 -07:00
Joel Linn b2c8d3e9e4 audiocvt: 5.1 to Stereo conversion utilizing AVX 2021-07-24 15:39:17 -04:00
Joel Linn 638befc1a9 audiocvt: 5.1 to Stereo conversion utilizing SSE 2021-07-24 15:39:17 -04:00
Joel Linn db56526f14 audiocvt: Replace divisions
Division is expensive and the compiler can not replace it themselves.
Though we now we will be ok in terms of floating point edge behaviour.
2021-07-24 15:39:17 -04:00
Sam Lantinga e1c3a25034 Changed SDL_FlashWindow() so it doesn't take a flash count, and added the hint SDL_HINT_WINDOW_FLASH_COUNT to control behavior on Windows 2021-07-24 12:11:27 -07:00
Sam Lantinga 09d1cea733 Use the new controller type for the Luna and Stadia controllers 2021-07-24 11:15:09 -07:00
Sam Lantinga 808c3ae612 Allow mapping Android controllers that just have a D-PAD and face buttons
This fixes bug https://github.com/libsdl-org/SDL/issues/4327
2021-07-24 10:37:42 -07:00
Sam Lantinga 94b7a87645 Added SDL_GameControllerType enumerations for the Amazon Luna and Google Stadia controllers
Fixes bug https://github.com/libsdl-org/SDL/issues/4019
2021-07-24 09:10:18 -07:00
german77 e6e8fe6d4e hidapi_switch: Implement analog rumble 2021-07-24 01:06:05 -07:00
Sam Lantinga 669714cafe Added the ThrustMaster T.16000M as a flightstick 2021-07-23 23:51:35 -07:00
Sam Lantinga 384d86b584 Fixed compile warnings with Visual Studio 2021-07-23 23:48:23 -07:00
Sam Lantinga adb75d642c Fixed hotplug detection not working on UWP or when SDL isn't pumping Windows events
This fixes bugs:
https://github.com/libsdl-org/SDL/issues/4321
https://github.com/libsdl-org/SDL/issues/4147

Thanks to DJm00n for the suggestion!
2021-07-23 23:45:18 -07:00
Sebastian Krzyszkowiak 7b0092db6a vita: touch: Mark the back panel as an indirect absolute touch device
It's not a touchscreen, but an additional touch panel on the back of
the device.
2021-07-23 16:40:34 -07:00
Sam Lantinga 422b053b96 Added support for the full line of current PowerA Xbox Series X controllers 2021-07-23 16:32:35 -07:00
Jaylon Gowie 48bbe31bc6 Add PreSwapCallback for updating SceCommonDialog 2021-07-21 09:41:10 -07:00
Jaylon Gowie 9c1306bc5e Add elgext.h header 2021-07-21 09:41:10 -07:00
meyraud705 4ada14a267 Replace libc functions to SDL equivalent in wayland video subsystem
Wayland video subsystem uses a mix of libc and SDL function.
This patch switches libc functions to SDL ones and fixes a mismatch in memory
allocation/dealoccation of SDL_Cursor in SDL_waylandmouse.c (calloc on line 201
and SDL_free on line 313) which caused memory corruption if custom memory
allocator where provided to SDL.
2021-07-21 09:28:38 -07:00
Ivan Epifanov f806064e7e Remove 'support' for rgb/bgr textures, that was causing issues with them 2021-07-19 10:14:13 -04:00
Niklas Haas d6641d7123 kmsdrm: Explicitly set the surface transform and alpha mode
This is required by the specification. Set these to sensible defaults.
Fixes a validation layer error that occurs otherwise.
2021-07-19 10:12:54 -04:00
Niklas Haas 760074270a kmsdrm: Properly zero-initialize CreateInfo structs
As written, these contain undefined stack contents, which in practice
causes crashes/hangs and/or triggers the validation layers (they
complain about `pNext` and `flags` not being NULL).
2021-07-19 10:12:54 -04:00
Ivan Epifanov 817976da69 VITA: Rewrite and fix RenderCopyEx rotation 2021-07-13 08:45:33 -07:00
Sam Lantinga dc6f044309 Added mapping for the Xbox Series X controller on tvOS 2021-07-12 17:57:21 -07:00
Sam Lantinga 947ad6e13a Added support for the Xbox Series X controller on iOS and tvOS 2021-07-12 17:57:21 -07:00
Brick 7fe6dbafa3 Reset rawInputEnableCount when RawInput is not supported 2021-07-11 14:51:31 -07:00
Sam Lantinga 24059a19c5 The RAWINPUT driver is no longer tied to HIDAPI in any way 2021-07-09 18:11:42 -07:00
Sam Lantinga f93e9047eb Implemented the timeout in hid_read_timeout() on Android
This fixes detecting PS5 controllers connected over USB
2021-07-08 18:44:50 -07:00
Hanseul Jun 557d0f827f Commenting a false alarm in WIN_GLES_SetupWindow.
When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), assertion due to !_this->gl_config.driver_loaded can be causes while EGL is available.
2021-07-08 14:49:40 -07:00
Sam Lantinga d135c0762f Added SDL_GameControllerSendEffect() and SDL_JoystickSendEffect() to allow applications to send custom effects to the PS4 and PS5 controllers
See testgamecontroller.c for an example of a custom PS5 trigger effect
2021-07-08 13:22:41 -07:00
Ozkan Sezer 3da6d2cdde WIN_SetErrorFromHRESULT: kill CR/LF that FormatMessage sticks at the end
Fixes: https://github.com/libsdl-org/SDL_mixer/issues/320
2021-07-08 20:33:50 +03:00
Dean Herbert 8fb95034e8 Avoid warping the cursor to the center of the window when not in relative_warp_mode
When relative mode is enabled and not using warp mode, the cursor is
being clipped to the window. Therefore there is no reason to restore the
cursor position to the center.

Avoiding the warp to center simplifies mouse position event flow, as we
are no longer potentially receiving mouse events for the automated
movement of the cursor and can be (mostly) assured that an incoming
event from the windowing system is that of external means.
2021-07-08 09:27:09 -07:00
Dean Herbert 4359a47b3e Simplify ClipCursor behaviour when RelativeMouseMode is enabled
The implementation of clip logic for relative mode seemed to
unnecessarily limit the usable area to the middle of the window, in a
2x2 pixel region. This has the adverse side effect of moving the
operating system cursor to that location, even if it is in a valid
location in the window.

While in most scenarios this is handled correctly (by storing the
original position of the cursor in the window and restoring when leaving
relative mode), there are edge cases where this clip operation can cause
WM_MOUSEMOVE to fire at a point in time where it counts as a relative
delta from SDL's perspective.
2021-07-08 09:27:09 -07:00
Dean Herbert 3720e254c4 Trim some stray whitespace 2021-07-08 09:27:09 -07:00
Austin Shafer 16e3bfe807 SetDisplayMode: Call XRRSetScreenSize before setting CRTC config
X11_SetDisplayMode currently calls X11_XRRSetCrtcConfig alone. This results
in the monitor's viewport getting changed, but the underlying screen dimensions
stay the same.

The spec indicates that RRSetCrtcConfig only changes the crtc mode and has no effect
on the screen dimensions, only mentioning that the new crtc must fit entirely within the
screen size. For the size to change, RRSetScreenSize also needs to be called.

This affects Metro Exodus on Linux, when changing the resolution in the in-game settings
Metro gets stuck in a loop waiting for the size of its vulkan surface to change. Because
XRRSetScreenSize is not called the screen size is never changed, the vulkan surface dimensions
do not change, and Metro hangs forever watching for a surface size update that will
never come.

This change disables the CRTC, calls XRRSetScreenSize, and then updates the
CRTC configuration. This fixes changing the resolution from the Metro settings.

Tested with:
Metro Exodus, Portal 2
2021-07-08 08:41:29 -07:00
Sam Lantinga 4a20dd3e54 Removed unnecessary comment, the mic button is in byte 16 on all firmware versions 2021-07-08 07:38:18 -07:00
Sam Lantinga 46f19c311d Implemented mouse relative mode for iOS 14.1 and newer 2021-07-08 07:23:29 -07:00
Sam Lantinga 430bbcb87f Added HIDAPI support for the Amazon Luna Controller connected over USB in DirectInput mode 2021-07-07 09:49:33 -07:00
Sam Lantinga 863f566941 Fixed reading thumbstick axes and mic button on the Amazon Luna Controller firmware version 305164320 2021-07-07 08:55:16 -07:00
Dimitriy Ryazantcev 17ed8d8085 Added HIDAPI backend for Amazon Luna Controller Model T28B69 connected via Bluetooth LE (VID:0171, PID:0419).
To enter Bluetooth pairing mode hold B and Action (button with circle) buttons for 3 seconds.

It works via usual HIDAPI if special filter driver is not installed:
https://www.amazon.com/gp/help/customer/display.html?nodeId=GZCT4CTFHXLHEB9T

With that driver installed it mimics Xbox One controller and works via XInput under Windows.

Under DInput this controller is not usable at all.
2021-07-07 08:31:12 -07:00
Sam Lantinga 00d67620da Added the SteelSeries manufacturer to the Nimbus+ entry on macOS 2021-07-06 11:32:11 -07:00
Sam Lantinga 24e836b0db Added controller mapping for the Nimbus+ controller on macOS when MFi support is not available 2021-07-06 10:00:09 -07:00
Ivan Epifanov 0994a75879 Don't hardcode message length 2021-07-01 15:14:49 -07:00
Ivan Epifanov 3b6e999244 Vita: remove unused variable and allow Razor perf analysis 2021-07-01 15:14:49 -07:00
Ivan Epifanov 656eb7df35 Vite: return system installed memory 2021-07-01 15:14:49 -07:00
Ivan Epifanov b55ee12f69 Vita: fix clip rectangle 2021-07-01 15:14:49 -07:00
Ivan Epifanov e41d3e617e VIta: fix render clearing 2021-07-01 15:14:49 -07:00
Ivan Epifanov 6b12280510 Vita: proper syntax 2021-07-01 15:14:49 -07:00
Ivan Epifanov 32deb6f70c Vita: fix point size 2021-07-01 15:14:49 -07:00
Ivan Epifanov 9d4527193d Vita: append messagebox title 2021-07-01 15:14:49 -07:00
Dimitriy Ryazantcev 39302c9214 Add Steam Virtual Gamepad and Xbox 360 Wired Controller defines instead of magic values
See  https://partner.steamgames.com/doc/features/steam_controller/steam_input_gamepad_emulation_bestpractices for details on what is Steam Virtual Gamepad.
2021-06-30 08:48:13 -07:00
Sam Lantinga 0c4ac33a09 Added support for the Razer Wolverine Tournament Edition controller 2021-06-28 14:31:27 -07:00
Joshua Ashton ca383599b5 Fix Anne Pro II keyboard showing up as a joystick
Having used this for a couple years, I can definitely confirm that it is not a joystick.
2021-06-26 21:23:26 -07:00
Joshua Ashton c90bd3bf79 Add missing PS5 DualSense GUIDs
Fixes my DualSense controller not being recognised as a SDL GameController which breaks Steam Input filtering causing SDL to fight for input.
2021-06-26 21:21:46 -07:00
Sam Lantinga 205b951b46 SDL_DINPUT_JoystickPresent() needs to do the full device enumeration
It is called from WGI before the normal joystick detection has been run, so it needs to actually enumerate currently connected devices.

We can skip the logic checking for other drivers also supporting this device, because that logic is duplicated from the call site.
2021-06-25 14:20:08 -07:00
Sam Lantinga ae6d9e343b Correcting the name of the Amazon Luna Controller 2021-06-25 11:09:46 -07:00
Sam Lantinga 5042ab6f24 Added Linux and macOS mappings for the DirectInput mode of the Amazon Luna Controller 2021-06-24 18:09:06 -07:00
Sam Lantinga 5b051459ed Fixed warnings on Windows 2021-06-24 18:09:04 -07:00
Sam Lantinga 99700a5c52 SDL: add Windows mappings for Luna controllers for USB DirectInput mode and BT. Note: the triggers do not seem to work in BT mode. 2021-06-24 18:09:01 -07:00
Ozkan Sezer 33b84c8d15 s/memcmp/SDL_memcmp/ for conistency 2021-06-24 23:10:56 +03:00
Ethan Lee 56b77b12bc cocoa: Implement FlashWindow 2021-06-24 13:08:26 -07:00
scribam c2e8a791bb SDL_windowsevents: add support for multiple mice 2021-06-24 12:15:54 -07:00
Cameron Gutman 7948c16df2 Pump events each time through the loop in SDL_WaitEventTimeout_Device()
Not only is it more efficient to batch process pending events, it is
necessary for correctness with the Win32 backend. WIN_PumpEvents() runs
periodic updates of the cursor clip region and disambiguation of
left and right shift keys in addition to standard event processing.
2021-06-24 12:14:17 -07:00
Cameron Gutman 105de64c2d Only queue one wakeup event per wait
Queuing more than one can lead to a spurious wakeup on the next wait.
2021-06-24 12:14:17 -07:00
Anthony Pesch c262569cd8 kmsdrm: fix KMSDRM_SetDisplayMode being called for the default desktop mode doing nothing 2021-06-24 12:12:29 -07:00
Anthony Pesch 98bda39186 kmsdrm: sync the display's current mode with what's set in KMSDRM_CreateSurfaces 2021-06-24 12:12:29 -07:00
Anthony Pesch d031a24e00 kmsdrm: defer surface recreation inside of KMSDRM_SetWindowSize and
KMSDRM_SetWindowFullscreen as is done in KMSDRM_SetWindowDisplayMode
2021-06-24 12:12:29 -07:00
Anthony Pesch 5a296e2589 kmsdrm: avoid overriding the mode requested by SDL_SetWindowDisplayMode
when recreating surfaces
2021-06-24 12:12:29 -07:00
Sam Lantinga 814285d6e3 Workaround for crash on Apple Mac M1 hardware 2021-06-23 09:19:02 -07:00
Sam Lantinga 41fab8532d ControllerList: set the default deadzone for Ps5 controller back to same one as Xbox controllers. Too many users complained about drift. 2021-06-18 18:10:24 -07:00
Sam Lantinga a8b28939a6 ControllerList: add more Xbox controllers from minidumps 2021-06-18 18:10:23 -07:00
Sam Lantinga 08eff56a5b ControllerList: add Brooks Mars controller to PS4 controller list 2021-06-18 18:10:22 -07:00
Sam Lantinga afd100f02b Added support for the PowerA Fusion Pro 2 and the PDP Xbox Series X Afterglow and Blue controllers 2021-06-18 17:37:46 -07:00
Ryan C. Gordon 839387ed0a
video/dummy: Don't zero out the fake display mode before adding it.
The SDL_zero call was in the wrong place as a historical accident, I think.
2021-06-17 22:11:10 -04:00
Sam Lantinga 268fbcd460 Fixed compiler warning on Visual Studio 2021-06-17 11:23:47 -07:00
Sam Lantinga d8dba5bcf3 Added support for the Logitech G923 racing wheel 2021-06-17 11:22:08 -07:00
Ethan Lee 7f261d3b76 wayland: Fix returning to a window from fullscreen without calling SetWindowSize 2021-06-15 09:00:18 -07:00
Ivan Epifanov 8da0dd17a1 Oops. Renderer already queues viewport change 2021-06-15 08:58:53 -07:00
Ivan Epifanov 1fc519880d Reset/re-apply viewport on frame start/target change. Fixes SDL_RenderSetLogicalSize on PSVita 2021-06-15 08:58:53 -07:00
Phillip Trudeau bc7ac134db Windows: Fix SDL_GetBasePath() truncating paths
SDL_GetBasePath grows its path buffer for long paths, but GetModuleFileNameExW always truncates and succeeds,
so `len` was always equal to (buflen - 1) which is 127. This is easily fixed by checking for (buflen - 1) instead of buflen.
For paths longer than MAX_PATH, this problem sometimes got hidden by Windows path shortening ("C:\PROGRA~1\" etc.).

Tested on Windows 10 x64 19041 and 10586.
2021-06-12 23:07:46 -04:00
Paul Cercueil db5cd8c694 joystick: virtual: Fix event injection for axes/hats
SDL_JoystickSetVirtualAxisInner() and SDL_JoystickSetVirtualHatInner()
did not properly sanitize the 'axis' and 'hat' parameters.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-06-12 17:55:03 +03:00
Paul Cercueil f3cf019ecb joystick: Add missing comma in joystick drivers list
Without this comma it is impossible to enable both the Vita and Dummy
drivers at the same time.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-06-12 15:50:02 +03:00
Ozkan Sezer bc9888c9b5 OS2_GetDisplayModes: malloc a new copy of mode's driver data.
Based on a patch by Jochen Schäfer <josch1710@live.de> :

The problem is, that in the initialization code uses the same structure for
desktop_mode and current_mode.  See SDL_os2video.c:OS2_VideoInit():

  stSDLDisplay.desktop_mode = stSDLDisplayMode;
  stSDLDisplay.current_mode = stSDLDisplayMode;
  ...
  stSDLDisplayMode.driverdata = pDisplayData;

Then, if you call GetDisplayModes, current_mode will added to the modes
list, with the same driverdata pointer to desktop_mode.

  SDL_AddDisplayMode( display, &display->current_mode );

When VideoQuit gets called, first the modes list gets freed including the
driverdata, the desktop_mode gets freed.  See SDL_video.c:SDL_VideoQuit():

  for (j = display->num_display_modes; j--;) {
      SDL_free(display->display_modes[j].driverdata);
      display->display_modes[j].driverdata = NULL;
  }
  SDL_free(display->display_modes);
  display->display_modes = NULL;
  SDL_free(display->desktop_mode.driverdata);
  display->desktop_mode.driverdata = NULL;

So, the display_modes[j].driverdata gets freed, but desktop_mode->driverdata
points to the same memory, but is not NULL'ed. When desktop_mode->driverdata
gets freed the memory is already freed, and libcx crashes the application on
SDL_Quit.
2021-06-12 14:55:24 +03:00
Ozkan Sezer d28437de3c SDL_keyboard.c: Add bounds guards when assigning to the scancode array.
Based on a patch by Jochen Schäfer <josch1710@live.de> :
On a T420 pressing the ACPI button for volume control, big scancodes
were emitted. This was causing an overflow, because missing guards.
2021-06-12 08:00:50 +03:00
Ethan Lee eb15b4e962 wayland: Drop SwapWindow calls for hidden windows 2021-06-11 21:50:18 -07:00
Ryan C. Gordon 37d35a3e34
kmsdrm: hook up KMSDRM_GLES_DefaultProfileConfig for use.
Fixes #3678.
2021-06-11 21:03:35 -04:00
Ivan Epifanov bbdd08e0b2 Build without PIB support by default and add flag to enable it 2021-06-11 13:21:07 -04:00
Ivan Epifanov a4442476df Cleanup dead and duplicate code 2021-06-11 13:21:07 -04:00
Ivan Epifanov c2b8b55634 Older api, not needed 2021-06-11 13:21:07 -04:00
Ivan Epifanov dd2a285825 Remove leftovers 2021-06-11 13:21:07 -04:00
Ozkan Sezer 2f248a2a31 SDL_cocoaevents.m: fix build against SDK < 10.12 after commit 0dd7024d. 2021-06-11 04:00:32 +03:00
Dimitriy Ryazantcev f5122377c9 Move SDL_IsXInputDevice check above actual joystick allocation 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev 766d81ec86 Rewrite SDL_DINPUT_JoystickPresent method to avoid costly IDirectInput8_CreateDevice calls 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev a6da2fbf73 Rename haptic methods to avoid confusion with joystick:
`SDL_DINPUT_MaybeAddDevice`->`SDL_DINPUT_HapticMaybeAddDevice`
`SDL_DINPUT_MaybeRemoveDevice`->`SDL_DINPUT_HapticMaybeRemoveDevice`
`SDL_XINPUT_MaybeAddDevice`->`SDL_XINPUT_HapticMaybeAddDevice`
`SDL_XINPUT_MaybeRemoveDevice`->`SDL_XINPUT_HapticMaybeRemoveDevice`
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev 73dc68a7ae Simplify and cleanup DirectInput joystick backend code:
- Do not call IDirectInputDevice8_QueryInterface(device, &IID_IDirectInputDevice8,...) on DIRECTINPUTDEVICE8 device
- Get joystick VendorID and ProductID via IDirectInputDevice8_GetProperty(.., DIPROP_VIDPID, ..) call instead of messing with DIDEVICEINSTANCE.guidProduct
- Normalize HID device interface path to upper case for stable operation of XInput check
- Remove useless RawInput calls in SDL_IsXInputDevice() - just check for "IG_" string in HID device interface path that we already have

There shouldn't be any observable behavior changes.
2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev f2f759dca3 Remove not used DirectInput ignored_devices list 2021-06-10 16:41:09 -07:00
Dimitriy Ryazantcev adc2d362ba Remove outdated and not used WIN_IsXInputDevice code 2021-06-10 16:41:09 -07:00
Sam Lantinga 0e62926ec5 Fixed crash if vendor or product strings are empty 2021-06-10 16:28:32 -07:00
Ryan C. Gordon e65a658320
x11: Add a hint to force override-redirect.
Fixes #3776.
2021-06-09 22:10:20 -04:00
Sam Lantinga cb5e86353b Fixed crash after reinitializing libusb HID support 2021-06-08 13:15:24 -07:00
Eric Wasylishen c33e3c15fb testwm2: draw various debug logging into the window itself
Renderer output size, window position/size, display bounds, etc.
Uses new SDLTest_CommonDrawWindowInfo function in test_common.
2021-06-08 05:29:29 +03:00
Cameron Gutman e13b43ac21 Don't skip sending wakeups for the current thread
We can be in a situation where we receive a win32 hook callback on the same
thread that is currently waiting. In that case, we do still need to trigger
a wakeup when an event is pushed because the hook itself won't necessarily
do that (depending on what we return from the hook).
2021-06-05 14:35:21 -07:00
Cameron Gutman b992b915e5 Optimize SDL_WaitEventTimeout() for the SDL_PollEvent() case
There's no sense in doing all the setup for waiting if we're just polling.
2021-06-05 14:35:21 -07:00
Cameron Gutman 85b51e6c92 Fall back to polling normally if not operating the win32 message loop
In this condition, we cannot safely wait/wake on events.
2021-06-05 14:35:21 -07:00
Cameron Gutman e13d5df00b Call SDL_SendWakeupEvent() directly from SDL_PeepEvent()
SDL_PeepEvent() is a documented public API, so we must properly support
waking a waiting thread in SDL_WaitEventTimeout() with SDL_PeepEvent().
2021-06-05 14:35:21 -07:00
Ethan Lee d956636c85 wayland: Implement FlashWindow 2021-06-04 16:26:03 -07:00
Jupeyy 64724db0a1 Implement bare minimum for SDL_FlashWindow 2021-06-04 15:07:55 -07:00
Francesco Abbate 0dd7024d55 Modifies WaitEvent and WaitEventTimeout to actually wait instead of polling
When possible use native os functions to make a blocking call waiting for
an incoming event. Previous behavior was to continuously poll the event
queue with a small delay between each poll.

The blocking call uses a new optional video driver event,
WaitEventTimeout, if available. It is called only if an window
already shown is available. If present the window is designated
using the variable wakeup_window to receive a wakeup event if
needed.

The WaitEventTimeout function accept a timeout parameter. If
positive the call will wait for an event or return if the timeout
expired without any event. If the timeout is zero it will
implement a polling behavior. If the timeout is negative the
function will block indefinetely waiting for an event.

To let the main thread sees events sent form a different thread
a "wake-up" signal is sent to the main thread if the main thread
is in a blocking state. The wake-up event is sent to the designated
wakeup_window if present.

The wake-up event is sent only if the PushEvent call is coming
from a different thread. Before sending the wake-up event
the ID of the thread making the blocking call is saved using the
variable blocking_thread_id and it is compared to the current
thread's id to decide if the wake-up event should be sent.

Two new optional video device methods are introduced:

WaitEventTimeout
SendWakeupEvent

in addition the mutex

wakeup_lock

which is defined and initialized but only for the drivers supporting the
methods above.

If the methods are not present the system behaves as previously
performing a periodic polling of the events queue.

The blocking call is disabled if a joystick or sensor is detected
and falls back to previous behavior.
2021-06-04 13:50:50 -07:00
Sam Lantinga 40e5ce7fe5 This delay is no longer needed on Steam Link hardware 2021-06-04 13:23:54 -07:00
Andrew Murray cd67f42d8f
add Linux mapping for brook fighting board (#4416)
* added controller mapping for Brook fighting board

* fixed formatting on Brook Universal Fighting Board controller mapping entry
2021-06-04 09:20:47 -07:00
Sjoerd Simons 89fd9821de Add controller mapping for Atari vcs controllers
This add controller mappings for the Atari vcs (modern) controller as
well as the classic controller, for both bluetooth and USB connectivity.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2021-06-03 11:43:41 -07:00
Sjoerd Simons de4ba6ebc0 Ignore the device version for Atari vcs controllers
At least on bluetooth the guid user the version reported by the
bluetooth device. Which for Atari vcs controllers is the firmware
version. However the mapping will stay the same regardless of firmware
version, so ignore the version entirely to avoid needing a new mapping
entry for each firmware version.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2021-06-03 11:43:41 -07:00
Sam Lantinga 6de33c0945 Clarify why we're skipping Game Controller framework supported devices in hid.c 2021-06-03 09:05:33 -07:00
Patrick Hogan 28da6c5ddb Have HIDAPI skip MFI supported HID devices on macOS to avoid duplicate devices. 2021-06-03 09:03:11 -07:00
Ethan Lee 2af3f64ecf wayland: Activate the window on first ShowWindow, if possible 2021-06-02 12:59:07 -07:00
Ethan Lee 151f953815 wayland: Implement RaiseWindow with xdg-activation 2021-06-02 12:59:07 -07:00
Ozkan Sezer f498c281e1 fixed build with SDL_JOYSTICK_RAWINPUT enabled after commit b81969d46f
See: https://github.com/libsdl-org/SDL/pull/4388#issuecomment-852713792
2021-06-02 14:10:50 +03:00
Kyle Schaefer 4522cb1df9 Changing variable from float to int, this way we can check it's value without having to do an unnecessary conversion. Then do explicit conversions later on if we need. 2021-06-01 16:53:39 -07:00
Kyle Schaefer c289bad900 In x11, GetDisplayDPI can give incorrect or unusable DPI information. Using XGetDefaults to get the Xft DPI if it's available and returning that. This could allow you to figure out DPI scale. 2021-06-01 16:53:39 -07:00
Ethan Lee d32440359a wayland: Add support for maximized/restored events 2021-06-01 15:33:45 -07:00
Anthony Pesch fc508eabe2 kmsdrm: remove redundant modeset_pending flag
this variable was added in commit 2067a7db8e and
ultimately tracks if this is a surface's first present. checking if the current
bo is NULL provides the same functionality and cuts down on a redundant piece
of state potentially getting out of sync in the future
2021-06-01 15:32:02 -07:00
Anthony Pesch 4c965b7a8d kmsdrm: fix SetDisplayMode binding the the wrong surface / context
SetDisplayMode needs to recreate the EGL surfaces, which then need to be
bound along with the correct context in each rendering thread

commit 3a1d7d9c9a removed this behavior which
has broken using SetDisplayMode when rendering with multiple contexts

the commit message was rather vague, but if the surfaces do need to be
created immediately, this process probably needs to be split such that
surface is created immediately, but the binding is deferred
2021-06-01 15:32:02 -07:00
Anthony Pesch 0219928dd5 kmsdrm: honor mode previously set by SDL_SetWindowDisplayMode when enabling fullscreen
and remove duplicate SDL_WINDOWEVENT_RESIZED event

commit 2067a7db8e made SDL_SetWindowSize and
SDL_SetWindowFullscreen modify the display mode previously set by a call to
SDL_SetWindowDisplayMode

as far as I understand the SDL API, calling SDL_SetWindowDisplayMode followed
by calling SDL_SetWindowFullscreen(..., SDL_WINDOW_FULLSCREEN) is the correct
way to mode set / switch to fullscreen

this change restores that functionaliy when switching to SDL_WINDOW_FULLSCREEN,
but other cases are still modifying the display mode set by the user. rather
than modifying the display mode set by the user, it seems this logic inside of
KMSDRM_ReconfigureWindow should be pushed further down into KMSDRM_CreateSurfaces
(as it was originally) to only modify the final mode that's set (based on the
fullscreen flags), but not override the mode requested by the user
2021-06-01 15:32:02 -07:00
Anthony Pesch fd5de93a02 kmsdrm: fix gbm surface dimensions not matching the mode being set
commit 2067a7db8e introduced new surface_w and surface_h
variables which were passed to gbm_surface_create rather than the dimensions from the
drmModeModeInfo structure. commit 5105ecf8b1 further
refactored this code and no longer synchronized these variables inside
KMSDRM_SetDisplayMode, breaking it

this change removes the variables since they're seemingly redundant to begin with
2021-06-01 15:32:02 -07:00
Timo Gurr b63cb822bf Added T500RS to known wheel list 2021-06-01 09:54:58 -07:00
Dimitriy Ryazantcev b81969d46f Be more explicit about Xbox 360/One device ids.
When Xbox One/Series Controllers are connected via USB on Windows they all are using `XBOXGIP` driver and produce a special ProductID `0x02FF` (GIP software PID) for any connected controller.

On the other hand `Xbox 360 Wireless Controller Reciever` (PID 0x0719) is using `XUSB` driver and produces special ProductID `0x02A1` (XUSB software PID) for each connected Xbox 360 Wireless Controller.

Also fixed Xbox One Series X Controller comment.
2021-06-01 09:54:13 -07:00
Per Nyblom 86ee383fdd Removed duplicate SDL_AtomicGet() 2021-05-28 12:29:54 -04:00
Ryan C. Gordon fed8465085
loadbmp: Attempt to handle small palettes better.
Only adjust the biClrUsed field if it is set to zero in the bitmap, and make
some effort to make sure we don't overflow a buffer in any case.

This was triggering an issue with the sailboat bmp used for testpalette.c in
SDL 1.2, which is an 8-bit paletted image with 66 palette entries instead of
256. See discussion at https://github.com/libsdl-org/sdl12-compat/issues/63

This change might be a problem, but there's no indication this code, which
originally landed in SDL_image 17 years ago with a large rewrite, is actually
fixing a specific issue. I'm also not sure we should actually make an effort
to accept a bmp that has a biClrUsed field that is both non-zero and _also_
incorrect.
2021-05-27 10:49:25 -04:00
Sam Lantinga db146e66c6 Fixed warnings building with Visual Studio 2021-05-25 10:34:04 -07:00
Sam Lantinga 3fcaf5b4b3 Fixed incorrect axis scaling for Nintendo Switch controllers 2021-05-25 10:33:30 -07:00
Sam Lantinga 157c3f8097 [SDL] Minimize number of system calls when handling WM_INPUT raw input messages.
Details:
Currently doing 4 system calls per WM_INPUT message, which can cause the thread handling the message loop to be swapped out several times:
* GetProp - to get window data from the window handle
* GetRawInputData - to retrieve the raw input data
* 2 calls to GetMessageExtraInfo - to ignore synthetic mouse events generated for touchscreens

In this change:
* Replaced GetProp by iterating the list of windows maintained by SDL (with a fallback to GetProp). Note that this will affect all messages and not just WM_INPUT
* only calling GetMessageExtraInfo if a touchscreen has been detected

Fix for https://jira.valve.org/browse/CSGO-4855
@saml
2021-05-21 09:45:08 -07:00
Cacodemon345 dbbc725f5e Remove WSCONS mouse scaling 2021-05-19 21:09:19 -04:00
Cacodemon345 2aa14b3806 Add missing key to WSCONS-to-SDL conversion table 2021-05-19 21:09:19 -04:00
Sam Lantinga 333c8e75f1 The PS5 driver supports Joystick LED 2021-05-17 11:54:05 -07:00
Ethan Lee be5356af93 winrt: Fix support for multiple simultaneous mouse button presses 2021-05-14 13:33:59 -07:00
Sylvain 62a562dea2
X11: use x11sym loaded functions (see bug #3978) 2021-05-12 23:37:18 +02:00
Sylvain 531d83bf6a
X11: allow using touchscreen, while pointer is grabbed (see bug #3978) 2021-05-12 23:13:48 +02:00
Kimplul 9e1d7baef1 Added T300RS to known wheel list 2021-05-12 09:25:57 -07:00
Ryan C. Gordon e1db4b82ec
egl: Don't crash if we failed halfway through SDL_CreateWindow. 2021-05-11 14:08:17 -04:00
Ethan Lee f2f451a59d wayland: Call SetWindowBordered at the end of ShowWindow 2021-05-10 11:11:38 -07:00
Fredrick Brennan c5dd9964c1 Copied X11 error handler code from SDL_x11opengl.c
Avoids needing to malloc to hold the error string.
2021-05-10 13:31:39 -04:00
Fredrick Brennan b3b4677e32 (X11) Set _NET_WM_NAME properly, fixes Unicode window titles
Removes deprecated code meant to support extremely ancient, pre-UTF-8
versions of Xorg. Uses new xlib API's for doing this same thing.

Closes #4288.
2021-05-10 13:31:39 -04:00
Ryan C. Gordon f4ab1c94f9
gamecontrollerdb: Add entry for the 8BitDo Receiver for Linux.
Fixes #3048.
2021-05-10 13:08:34 -04:00
Ryan C. Gordon bedc509afc
gamecontrollerdb: added entry for PowerA XBox One Controller for Linux.
Fixes #3910.
2021-05-10 13:04:59 -04:00
Ethan Lee efbb6ff9d7 wayland: Create the server decorations after the toplevel has been configured 2021-05-10 12:49:26 -04:00
Ryan C. Gordon 9dc97afa71 cocoa: Report an error if SDL_SetClipboardText() isn't using UTF-8 encoding.
Fixes #4110.
2021-05-08 12:39:50 -04:00
Sam Lantinga 9231f1f1cf Added support for the PS5 controller on iOS and tvOS 2021-05-07 12:29:03 -07:00
Henk Kalkwater 889cebb7c2 Wayland touch inputs send normalized coords
Resolves #4361
2021-05-05 15:20:42 -07:00
Nicolas Caramelli 31637ddeea Generic check for desktop GL and EGL on Linux systems 2021-05-05 15:19:55 -07:00
Ozkan Sezer 58884e4c1b SDL_audiocvt.c: fixed MSVC double->float conversion warnings. 2021-05-04 00:23:40 +03:00
Ethan Lee c69fde348f wayland: Maximize/Restore should set the relevant window flags.
Also, Maximize should be ignored for fixed-size windows.
2021-05-02 19:03:32 -04:00
Christian Rauch 006378b921 fix NULL frame_callback access 2021-05-02 14:07:40 -04:00
Christian Rauch 424bbaec06 wayland: destroy frame callback when window is destroyed 2021-05-01 14:19:25 -04:00
Ethan Lee 2092855035 wayland: Guard surface_frame_listener for OpenGL, document why it exists 2021-05-01 13:27:12 -04:00
Ethan Lee 3d47ddc422 wayland: Use refresh_rate to calculate max_wait in SwapWindow 2021-05-01 13:27:12 -04:00
Sylvain 7b284dbb34
EglChooseConfig: choose an accelerated configuration
- especially because we can be promoted to true color 888
  make sure we don't select a potentially software implementation

- hopefully fix bug #1482 (EGL ChooseConfig selects software renderer on Android)
2021-04-30 22:01:48 +02:00
Ethan Lee 9161f95166 egl: Reject attempts to set negative swap intervals 2021-04-30 13:24:01 -04:00
Ryan C. Gordon c54c16d353
wayland: don't hang in SDL_GL_SwapBuffers if the compositor is ghosting us.
If you hide a window on Mutter, for example, the compositor never requests
new frames, which will cause Mesa to block forever in eglSwapBuffers to
satisfy the swap interval.

We now always set the swap interval to 0 and manage this ourselves, handing
the frame to Wayland when it requests a new one, and timing out at 10fps just
to keep apps moving if the compositor wants no frames at all.

My understanding is that other protocols are coming that might improve upon
this solution, but for now it solves the total hang.

Fixes #4335.
2021-04-30 13:20:35 -04:00
Ozkan Sezer 227021b647 SDL_windowsmessagebox.c (MessageBoxDialogProc): fix calling convention. 2021-04-30 11:25:20 +03:00
Sylvain a74f888ff9
Fixed bug #4337 - compilation of 'SDL_vulkan_utils' fails with 'VK_ERROR_INCOMPATIBLE_VERSION_KHR' undeclared 2021-04-29 22:25:00 +02:00
Sylvain 8ac0fb52cb
OpenSLES: CloseDevice() is called at higher level, if OpenDevice() fails
- explicit initialization of static variables
2021-04-29 09:29:02 +02:00
Sylvain 1f3df900f9
Error missing 'flags' initialization (see bug #2881) 2021-04-28 23:40:26 +02:00
Sylvain fcbf19b764
AAudio: make sure stream is not null to prevent crash in RequestStop (see #3710) 2021-04-28 21:04:47 +02:00
Sylvain c93e3b3607
Fixed bug #2881 - SDL_RLEsurface may encode RGB888 if it has no color key (Thanks Simon Hug)
To encode with BLEND mode, it needs a valid alpha channel
2021-04-28 10:43:28 +02:00
Sylvain b626429745
Merge remote-tracking branch 'refs/remotes/origin/main' 2021-04-27 11:10:41 +02:00
Sylvain f869518533
Audio: normalize conversion Stereo to 5.1, Quad to 7.1, 5.1 to 7.1 (bug #4104) 2021-04-27 11:07:51 +02:00
Sylvain 21349901ea
Audio: convert 5.1 to 7.1, use right-surround for r-front and r-back (see #4104) 2021-04-27 10:57:48 +02:00
Ryan C. Gordon 8527c583f4 cocoa: Fix recreated windows that are both borderless and resizable.
These would accidentally get a titlebar because the "borderless" style mask
is zero but the resizable attribute adds a bit. I assume this happens because
you used to need window decoration to resize a window in macOS, but this
changed in later releases.

This only caused problems when recreating a window (you had an
SDL_WINDOW_OPENGL window and tried to create a Metal SDL_Renderer on it, etc).

Fixes #4324.
2021-04-27 01:36:23 -04:00
Ethan Lee 40210f8945 winrt: Always use a thread for joystick support 2021-04-26 21:29:56 -04:00
Ryan C. Gordon 2fdbae22cb cocoa: Remove mouse event tap.
It doesn't appear to work anymore, and was disabled by default anyhow, since
the needed APIs are forbidden on the Mac App Store.

A better solution to lock the mouse to the window on macOS would still be
welcome. CGAssociateMouseAndMouseCursorPosition() works fine for relative
mouse mode, this was just a question of SDL_SetWindowGrab(). As it stands
now, a grabbed mouse can briefly break out of the window, causing varying
degrees of chaos.
2021-04-26 18:43:28 -04:00
Sylvain 9727655b89
SDL_test_common: add other window flags: --shown, --hidden, --input-focus, --mouse-focus 2021-04-26 14:22:19 +02:00
Sylvain d62ebec260
SDL_test_common: replace 'resize' by 'resizable' 2021-04-26 14:10:39 +02:00
Ryan C. Gordon 1f482174b5
x11: Mark backing_store as NotUseful when creating windows.
This can give some performance boost, and save some resources, as there's no
reason to keep a copy of an SDL window's contents on the server: most SDL
apps are redrawing completely every frame, and the API allows for expose
events to tell an app a redraw is needed anyhow.

(And compositors are free to ignore this setting if it makes sense to do so,
according to the Xlib docs.)

Reference Issue #3776.
2021-04-25 12:44:35 -04:00
Ryan C. Gordon 9c063468d6
x11: call XSync before XSetInputFocus during SDL_ShowWindow.
This only happens when using a non-NET_WM window manager, as we might try to
set the focus before the window is mapped.

Fixes #3949.
2021-04-24 19:55:41 -04:00
Ivan Epifanov ca969eb2be Remove gles2 vita render 2021-04-24 14:13:09 -07:00
Ivan Epifanov 058bbe0286 Set volume on device open 2021-04-24 14:13:09 -07:00
Ivan Epifanov e3ea5b6468 Migrate to lightweight mutexes 2021-04-24 14:13:09 -07:00
Steven Noonan f1ad942a11 SDL_windows_main: use HeapAlloc/HeapFree for command line arguments
If a developer uses SDL_SetMemoryFunctions, we can't rely on SDL_free()
working when SDL_main() returns.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 17:26:13 -07:00
Steven Noonan 17d8479d98 hidapi/libusb: maintain in-memory cache of vendor/product strings
The get_usb_string call is rather expensive on some USB devices, so we
cache the vendor/product strings for future lookups (e.g. when
hid_enumerate is invoked again later).

This way, we only need to ask libusb for strings for devices we haven't
seen since before we started.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:40:23 -07:00
Steven Noonan 4535d65491 HIDAPI_UpdateDiscovery: only treat "add" and "remove" events as relevant
I have a buggy system which reports a udev "change" event for an empty
USB-C port every 0.14 seconds, which causes annoying frame hitches
because SDL decides that means it needs to do a libusb hid_enumerate,
which is slow (~25ms!) because of the get_usb_string() calls in there.

We only need to re-enumerate if we've seen a device added or removed, so
let's filter out the change event first.

Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:40:16 -07:00
Steven Noonan b15bbd4e3f SDL_udev: check for NULL return value from udev_device_get_action
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
Signed-off-by: Sam Lantinga <slouken@libsdl.org>
2021-04-22 16:39:22 -07:00
Sylvain cf05a5eb0c
eglChooseConfig: only add EGL_DEPTH_SIZE if non 0
and fix static / shadowed variables warnings for dump configs
2021-04-22 21:40:57 +02:00
Sylvain 98a966d1c2
Android: don't need to set the SurfaceHolder format from java code
It's already set with ANativeWindow_setGeometry, and eventually set/changed also by eglCreateWindowSurface.
 - avoid issues with older device where SurfaceView cycle create/changed/destroy appears broken:
   calling create/changed/changed, and leading to "deuqueBuffer failed at server side, error: -19", with black screen.
 - re-read the format after egl window surface is created, to report the correct one (sometimes, changed from RGBA8888 to RGB24)
2021-04-22 18:06:17 +02:00
Ethan Lee 8e3ec34d34 wayland: Refactor toplevel mapping, implement HideWindow 2021-04-21 13:11:47 -04:00
Cacodemon345 0838f53d5a Implement SDL_SetWindowAlwaysOnTop for X11 2021-04-21 13:09:10 -04:00
Mathieu Eyraud a5825576fb Fix error handling of wayland message box
Zenity return a small integer on success which may be the same as EXIT_FAILURE. Use a bigger integer for error reporting from child process.
2021-04-21 09:53:39 -04:00
Mathieu Eyraud 12dd412b0b Fix icon of wayland message box
Also add some comments and silence a warning.

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
2021-04-21 09:53:39 -04:00
meyraud705 d0cf3b7555 Return correct button id 2021-04-21 09:53:39 -04:00
meyraud705 1fd95c53b6 Disable pango markup in wayland massage box
Zenity support pango markup, add --no-markup to disable it.
2021-04-21 09:53:39 -04:00
meyraud705 0cd0e9ba98 Reimplement wayland message box function with execvp.
Previous version used 'popen' which required to sanitize user provided text. Not
sanitizing text could cause failure if user provided text included a " or command
injection with `cmd`.
2021-04-21 09:53:39 -04:00
Cacodemon345 99ef03b96e KMSDRM: Only use OpenBSD-specific defines on pre-6.9 releases 2021-04-20 19:44:55 -07:00
Joseph Lyncheski a0a5da5d91 Add SDL_SetWindowAlwaysOnTop() 2021-04-20 08:45:28 -07:00
Sylvain 6be9c00970
Android: prevent error EGL_BAD_DISPLAY while getting egl version without display
There is an error "E libEGL  : validate_display:91 error 3008 (EGL_BAD_DISPLAY)"
that occurs when calling "eglQueryString(display, EGL_VERSION)", with EGL_NO_DISPLAY.

Khronos says "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS."
but this was added in SDL with "EGL 1.5 allows querying for client version"
( 56363ebf61 )

In fact:
- it actually doesn't work on Android that has 1.5 egl client
- it works on desktop X11 (using SDL_VIDEO_X11_FORCE_EGL=1)

The commit moves the version call where it's used, eg inside the "if (platform) {"
and checks that "eglGetPlatformDisplay" has been correctly loaded.
2021-04-20 13:46:25 +02:00
Ryan C. Gordon 03503423e9
filesystem: Better OpenBSD support for SDL_GetBasePath().
Fixes #3752.
2021-04-19 23:32:45 -04:00
ReNoM de6d290266 Fix keymap updating for X11 backend 2021-04-19 15:54:09 -04:00
Ethan Lee 509228c423 wayland: Implement GetDisplayDPI 2021-04-19 00:14:15 -04:00
Ethan Lee fcbfe33ce5 wayland: Implement SetWindowModalFor 2021-04-19 00:14:15 -04:00
Ethan Lee 213bfc194e wayland: Implement RestoreWindow for xdg/zxdg 2021-04-19 00:14:15 -04:00
Ethan Lee 0f51800229 wayland: Removed unused GetDisplayModes/SetDisplayMode functions 2021-04-19 00:14:15 -04:00
Ethan Lee 46df195b2a wayland: Implement GetDisplayBounds 2021-04-19 00:14:15 -04:00
Ethan Lee ed24c3452a wayland: Implement basic window move events via wl_surface_listener.
This unearthed an unspeakably large amount of bugs in the wl_output enumerator,
notably the fact that the wl_output user pointer was to temporary memory!
This was "fixed" in e862856, and was then pointed out as a leak in 4183211,
which was undone in d9ba204. The busted fix was correct that the malloc was an
issue, but wrong about _why_; SDL_AddVideoDisplay copies by value and does not
reuse the pointer, so generally you want your VideoDisplay to be on the stack,
but of course the callbacks don't allow that, so a malloc was a workaround. But
we can do better and just host our temporary display inside WaylandOutputData
because that will be persistent while also not leaking.

Wait, wasn't I talking about move events? Right, that: wl_surface_listener does
at least give us the ability to know what monitor we're on, even though we have
no idea where we are on the monitor. All we need to do is check the wl_output
against the display list and then push a move event that both indicates the
correct display while also not being _too_ much of a lie (but enough of a lie
to where our event doesn't get discarded as "undefined" or whatever). The index
check for the video display is what spawned the great nightmare you see before
you; aside from the bugfix this is actually a really basic patch.
2021-04-16 21:12:02 -07:00
Sylvain b4f89c56c6
AAudio: add aaudio pause/resume function to android events loop 2021-04-15 21:16:10 +02:00
Sylvain f1fab24e35
AAudio: add bootstrap in SDL_audio.c 2021-04-15 21:00:00 +02:00
Sylvain 04b2f5f6ec
Android: add AAudio back-end, with playback and capture (see #3710)
https://developer.android.com/ndk/guides/audio/aaudio/aaudio
2021-04-15 20:54:58 +02:00
Sylvain 4118fe62fe
Android: OpenSLES, explicitly initialise the global variable 'bqPlayerPlay',
it may be read even if OpenSLES back-end hasn't been intialized
2021-04-15 20:52:43 +02:00
Sam Lantinga 499d31e9cd Cleanup Linux joystick code 2021-04-13 17:00:24 -07:00
Luis Cáceres 5c78df9c23
Support key composing (i.e. dead keys) in Wayland driver (#4296)
Based on an old patch by chw from the old Bugzilla issue tracker.

Authored-by: chw

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2021-04-13 16:56:50 -07:00
Sam Lantinga b04136e75e Fixed Xbox controller when using the default Linux gamepad mapping
Tested with the Xbox Series X controller and the xow driver
2021-04-13 16:29:48 -07:00
Sam Lantinga 1aaafc2bd8 Show the real name of the Xbox controller when using the generic mapping on Linux 2021-04-13 16:29:46 -07:00
Paul Cercueil 1542300a89 joystick: linux: Avoid checking for gamepad mapping each frame
The information whether a specific joystick can be used as a gamepad is
not going to change every frame, so we can cache the result into a
variable.

This dramatically reduces the performance impact of SDL2 on small
embedded devices, since the code path that is now avoided was quite
heavy.

Fixes #4229.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-04-13 16:07:35 -07:00
Ethan Lee f88d91d596 wayland: Minor whitespace fix 2021-04-13 16:02:53 -07:00
Ethan Lee d785dab5fd wayland: Add unscaled resolutions to the display mode list 2021-04-13 16:02:53 -07:00
Cacodemon345 b0178fe518 KMSDRM: Report correct window position to the application 2021-04-13 16:01:44 -07:00
Ethan Lee dfcd5fbcad wayland: Set the keymap in keyboard_handle_modifiers 2021-04-13 13:30:50 -07:00
Sylvain e87c7940f5
Fixed bug 3829 - Don't FOURCC format for target textures
FOURCC isn't supported by renderer back-ends for target access
So use a correct format and fallback to with native/yuv path
2021-04-13 14:42:38 +02:00
Sam Lantinga 9ef0b97c6d Changes to macOS event handler to better interact with the running app
- Only focus a new window when one closes if the window that was closed was an SDL window

- If the application already has a key window set that is not an SDL window, don't replace it when the application is activated

- Only register the URL event handler when SDLAppDelegate is going to be set as the applications app delegate. This is to
   be consistent with previous behavior that would only register the handler in -[SDLAppDelegate applicationDidFinishLaunching:]
   and allows the running app to opt out of the behavior by setting its own app delegate.

- The URL event handler is now removed if it was set on SDLAppDelegate dealloc
2021-04-12 11:25:44 -07:00
Sam Lantinga 2a20cc0f1d SDL: let through a SetLED command every 5sec to deall with situations where the controller loses power when a computer is suspended
CR: SamL
2021-04-12 11:25:42 -07:00
Ethan Lee c59d4dcd38 wayland: Dramatically lower the timeout when reading/writing pipes 2021-04-09 22:30:08 -07:00
Ethan Lee cf12496311 wayland: Fall back to clipboard source data if offer came up empty 2021-04-09 22:30:08 -07:00
Ethan Lee 282c052479 wayland: Another strlen->SDL_strlen 2021-04-09 22:30:08 -07:00
Ethan Lee bec133d77b wayland: Use SDL_strlen instead of strlen 2021-04-09 22:30:08 -07:00
Ethan Lee e28d978509 wayland: Minor whitespace cleanup in clipboard.c 2021-04-09 22:30:08 -07:00
Ethan Lee 875f839df4 wayland: A bunch of clipboard safety fixes.
Also removed Wayland_get_data_device because it was a pointless getter function.
2021-04-09 22:30:08 -07:00
Ethan Lee 7510245af9 wayland: Create the data_device only after both device_manager and input exist.
There is no guarantee on what order the Wayland interfaces will come in, but the
callbacks were assuming that wl_data_device_manager would could before wl_seat.
This would cause certain desktops to not have any data_device to work with,
meaning certain features like the clipboard would silently no-op.
2021-04-09 22:30:08 -07:00
Dean Herbert 89b6209313 Fix race condition that can lead to ENTER/LEAVE window events never firing
On windows, when toggling the state of RelativeMode rapidly, there is a
high chance that SDL_WINDOWEVENT_ENTER / SDL_WINDOWEVENT_LEAVE events
will stop firing indefinitely.

This aims to resolve that shortcoming by ensuring mouse focus state is
correctly updated via WM_MOUSELEAVE events arriving via the windows
event hook.
2021-04-07 14:02:43 -07:00
David Edmundson 6fd37194bc wayland: Fix leaked zxdg_decoration_manager 2021-04-07 13:56:48 -07:00
David Edmundson f6a09ef1a9 wayland: Drop support for kwin specific decoration management
KWin has supported the shared and formalised zxdg_decoration since
Plasma 5.16 which came out mid 2019.

Whilst it made sense to support them both for a while, it should not be
needed for future SDL releases.
2021-04-07 13:54:07 -07:00
Ethan Lee a92cca1ab8 wayland: Use the window's display to get wl_output rather than fullscreen_mode.
Because Wayland only supports FULLSCREEN_DESKTOP, fullscreen_mode never gets
assigned at all, meaning driverdata is always NULL! Depending on what the
compositor does this can lead to dramatically different results. GNOME was fine
without this, but Plasma would trip an event that unintentionally unset the
fullscreen mode and caused the game to fire a configure event _every frame_,
and of course the configure would send the fullscreen_mode output which was
still empty. The fix is to just use the SDL_VideoDisplay directly, which will
always have a valid wl_output.
2021-04-07 13:53:15 -07:00
Ethan Lee c7e29a9e95 wayland: Fix toggling fullscreen with fixed-size windows 2021-04-07 13:53:15 -07:00
Ryan C. Gordon 0f4aba7bcd
audio: Fixed assertion failure if trying to use dummy backend. 2021-04-06 18:35:20 -04:00
Ryan C. Gordon 64853b7378
audio: Changed a disk and dummy backends to use _this instead of this. 2021-04-06 18:35:20 -04:00
Ozkan Sezer e97cfe4ad1 KMSDRM_Vulkan_CreateSurface(): fixed pointer-cast warning on 32 bit
Closes: https://github.com/libsdl-org/SDL/issues/4284
2021-04-06 23:56:10 +03:00
okuoku 8fa2ce5601 WinRT: Rename Interface ID symbols
Rename locally-defined Interface ID symbols to avoid conflict with
locally linked dxgi library. Prefixed with `SDL_` to match with
other references in render_d3d11 or wasapi.
2021-04-04 09:19:16 -04:00
Nicholas "LB" Braden 3dbc4cf233 Fix compilation error for Windows SDK 8.1+
https://docs.microsoft.com/en-us/windows/win32/api/shellscalingapi/ne-shellscalingapi-monitor_dpi_type
2021-04-04 08:39:12 -04:00
meyraud705 413a2306bc NULL passed to strcmp in Wayland_ShowMessageBox 2021-04-04 08:15:33 -04:00
Ryan C. Gordon 4914199665
ibus: make sure we don't pass a NULL path string over D-Bus.
Fixes #2941.
2021-04-04 00:29:26 -04:00
Ryan C. Gordon 354cabd4a7
egl: favor truecolor configurations.
If app requested <= 16 color depth and there is a 24-bit config available,
favor that. This fixes things that quietly expect to get truecolor output
but don't request it (...like SDL's render api...) and things that are
probably requesting 16-bit color as a fallback but expecting reasonable
systems to give them full depth.

Specifically, this fixes Life is Strange on Wayland, which uses the latter
approach, and anything using SDL_Render on Wayland, which uses the former.

Fixes #4056.
Fixes #4132.
2021-04-03 18:48:54 -04:00
Ryan C. Gordon 4abe34461f
SDL_EGL_ChooseConfig: cleanups and minor optimizations.
- Move an immutable condition out of a for loop.
- Add a break statement to that loop when we find what we're looking for.
- Add an assert to make sure we don't overflow a buffer.
- Wrap a single-statement if block in braces.
- Adjust some whitespace.
2021-04-03 10:10:58 -04:00
Ryan C. Gordon 7d02248cf5
tls: wrap reference to a mutex into an #if !SDL_THREADS_DISABLED test. 2021-04-02 14:36:53 -04:00
Ryan C. Gordon dbdbae44c5
linux: (de)initialize d-bus at init and quit.
Previously we had different subsystems quitting it, in conflict, and risked
multiple threads racing to init it at the same time.

Fixes #3643.
2021-04-02 14:35:11 -04:00
Ryan C. Gordon 57c2a4566f
render: draw when hidden, except on iOS and Android.
Fixes #2979.
2021-04-02 14:01:41 -04:00
Vanfanel fa81883418 [KMSDRM] Fake refresh rate precision on Vulkan display mode creation. 2021-03-31 15:32:17 -04:00
Vanfanel 942aa7bd07 [KMSDRM] No need to use an SDL_VideoDisplay pointer to access display index. 2021-03-31 15:32:17 -04:00
Learath 033c0abb58 Use dispatch_async for -[NSOpenGLContext update]. Fixes #3680 2021-03-31 10:46:31 -04:00
Ethan Lee eeee730833 wayland: Implement IME support.
Note that this is purely to make it possible to enter text that requires
composition - for example, before this commit Kanji input didn't work at all.

The big problem this still has is that we need the window position, and this is
still not implemented. Once we have this information we can do the equivalent
of XTranslateCoordinates to put the rectangle where we want it.
2021-03-29 15:54:36 -07:00
vanfanel 733b3278de [KMSDRM] Minor Vulkan code adjustments regarding pointers and display index. 2021-03-29 11:07:36 -07:00
Ethan Lee 9d294f1fca audio: Allow AudioStreamGet to return 0 in RunAudio.
While we should normally expect _something_ from the stream based on the
AudioStreamAvailable check, it's possible for a device change to flush the
stream at an inconvenient time, causing this function to return 0.

Thing is, this is harmless. Either data will be NULL and the result won't matter
anyway, or the data buffer will be zeroed out and the output will just be
silence for the brief moment that the device change is occurring. Both scenarios
work themselves out, and testing on Windows shows that this behavior is safe.
2021-03-29 08:58:02 -07:00
Ethan Lee 9b7babf96e wasapi: Remove assert added by 67e8522d 2021-03-29 08:55:13 -07:00
Xing Ji fb283a732a Squashed commit of the following:
commit 6b8f933589aa3925978a23e77a305a7e89c6ae4a
Author: Xing Ji <jixingcn@gmail.com>
Date:   Wed Mar 24 22:31:29 2021 +0800

    update the dynapi by `gendynapi.pl`

commit ebd1790c19983b652713f40ab1e139e485e1a2b7
Author: Xing Ji <jixingcn@gmail.com>
Date:   Wed Mar 24 22:17:48 2021 +0800

    revert the change in src/dynapi

commit 734b5f85c1613070081e39238e84198128971b53
Merge: 5a56e5a8 5ac6bd54
Author: Xing Ji <jixingcn@gmail.com>
Date:   Wed Mar 24 22:14:40 2021 +0800

    Merge remote-tracking branch 'libsdl/main' into jixingcn

commit 5a56e5a8227d9cff6b497b681c618a76bec1cae1
Author: Xing Ji <jixingcn@gmail.com>
Date:   Mon Mar 22 23:55:10 2021 +0800

    Fix #3596, can call the `SDL_TLSCleanup` to cleanup the TLS data when closing the application
2021-03-29 08:54:41 -07:00
Ethan Lee 5ceb674426 linux: Fix ibus support on Wayland/XWayland 2021-03-29 08:50:56 -07:00
Frank Praznik 5f9effaa7e audio: pipewire: Block while waiting on stream state info
Initializing streams, particularly capture streams, can take many milliseconds, which is a bit much for a busy wait.  Use a blocking wait instead.
2021-03-29 08:49:25 -07:00
Frank Praznik 8deb406300 audio: pipewire: Avoid redundant locking
The pw_thread_loop already locks and unlocks the thread mutex at the start and end of each loop iteration, so these locks are unnecessary.
2021-03-29 08:49:25 -07:00
Frank Praznik 5bb2bbd40c audio: pipewire: Don't use uninitialized variables in callbacks
Some of the SDL_AudioDevice struct members aren't initialized until after returning from the OpenDevice function.  Since Pipewire uses it's own processing threads, the callbacks can be entered before all members of SDL_AudioDevice are initialized, such as work_buffer, callbackspec and the processing stream, which creates a race condition.  Don't use these members when in the paused state to avoid potentially using uninitialized values and memory.
2021-03-29 08:49:25 -07:00
Vanfanel 9de7eaf9ac [KMSDRM] Change error message. 2021-03-28 16:38:06 -07:00
Vanfanel 1ec60a38eb [KMSDRM] Remove unnecessary space. 2021-03-28 16:38:06 -07:00
Vanfanel c13c3c37bd [KMSDRM] For Vulkan, use a mode with the same exact size as the window, if possible, or create a new one. 2021-03-28 16:38:06 -07:00
Ethan Lee 07ba13b7a9 wayland: Pass --no-wrap to Zenity.
There seems to be a bug where it can wrap the text based on the minimum possible
window size, which can be worked around with --no-wrap. This technically uncaps
the width entirely, but this isn't wildly different from what other backends do.
2021-03-27 02:57:39 -04:00
Ethan Lee 54719a9d3d wayland: Assign output_len in ShowMessageBox 2021-03-27 02:57:39 -04:00
Sam Lantinga 4a07c73b80 Added mapping for the Amazon Luna controller on Linux 2021-03-26 13:53:58 -07:00
Sam Lantinga 07af9baa86 Use the correct name for the Amazon Luna Gamepad 2021-03-26 13:05:38 -07:00
Sam Lantinga ef36355563 Added mapping for the Amazon Luna controller on macOS 2021-03-26 13:03:29 -07:00
Sam Lantinga 3377861ab1 Added support for the Amazon Game Controller to the HIDAPI driver 2021-03-26 11:57:19 -07:00
Ethan Lee 27b74d3334 Implement Wayland_ShowMessageBox using Zenity 2021-03-25 23:37:14 -04:00
Ozkan Sezer 5262b52ddd SDL_kmsdrmvideo.c: define EGL_PLATFORM_GBM_MESA if it's missing.
Fixes:		https://github.com/libsdl-org/SDL/issues/4232
2021-03-25 23:56:56 +03:00
vanfanel 5ac6bd5483 [KMSDRM] Ask for videomode on the correct display when creating a window. 2021-03-23 21:51:36 -07:00
Fabrice Fontaine b55b11af88 src/thread/pthread/SDL_systhread.c: drop include of SDL_platform.h
Drop include of SDL_platform.h as SDL_plaform.h is already included by
SDL_internal.h -> SDL_config.h -> SDL_platform.h

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2021-03-23 11:33:00 +03:00
Sam Lantinga 0bdf4f95bf Disable system gestures on MFi controllers while they're open, so we get access to the back button, etc. 2021-03-22 19:19:01 -07:00
Sam Lantinga 1133ea0349 Fixed crash on macOS when AirPods are connected 2021-03-22 19:18:57 -07:00
Paul Cercueil c12f46b100 [KMSDRM] Fix segmentation fault
Deference the windata pointer *after* checking that it's non-NULL.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2021-03-22 22:20:01 +03:00
vanfanel 100166d7d7 [KMSDRM] Improve cursor management. 2021-03-22 10:48:02 -07:00
vanfanel cf7eef37b0 [KMSDRM] Better error handling: no more segfaults on window creation failure. 2021-03-20 11:03:52 -07:00
Vanfanel 4acd1dcad4 [KMSDRM] Improve the way to test if last window is being destroyed. 2021-03-18 11:04:28 -07:00
Vanfanel 8638674a87 [KMSDRM] Correct comment typo. 2021-03-18 11:04:28 -07:00
vanfanel 82ff6045fa [KMSDRM] Unload GL/EGL libs and destroy GBM only when we are destroying the last window. 2021-03-18 11:04:28 -07:00
vanfanel c35e71892e [KMSDRM] All non-vulkan windows have to be marked as OPENGL, not only the first created one. 2021-03-18 11:04:28 -07:00
vanfanel 281a7bdbb3 [KMSDRM] Make the gbm_init flag a viddata member to avoid GBM re-init when several displays are connected. 2021-03-18 11:04:28 -07:00
Vanfanel 7d1b9c9f15 [KMSDRM] Remove unneeded function calls and improve comments for future reference. 2021-03-17 11:29:13 -07:00
Ryan C. Gordon e7e519a466
dsp: Refuse to initialize if there aren't any Open Sound System devices.
This prevents the dsp target from stealing the audio subsystem but not
being able to produce sound, so other audio targets further down the list
can make an attempt instead.

Thanks to Frank Praznik who did a lot of the research on this problem!
2021-03-17 13:04:05 -04:00
Ankith 559be8aab4 fix invalid out of bounds UTF8 handling 2021-03-16 18:51:28 -07:00
Ankith 07fc1bb883 Fix invalid UTF-8 handling of extra bytes 2021-03-16 18:51:28 -07:00
Vanfanel e14fb54e3f [KMSDRM] Undo SDL_CreateRenderer() modifications aimed at create opengles2 when KMSDRM is in use because it's a harmful solution. 2021-03-16 11:07:54 -07:00
Vanfanel 108bb5aabe [KMSDRM] Modify SDL_CreateRenderer() to create an opengles2 renderer when the KMSDRM backend is being used and no renderer name has been specified. 2021-03-15 18:47:22 -07:00
Ryan C. Gordon b98b5adcae
wasapi: Don't use the system's resampler. 2021-03-15 10:21:36 -04:00
Haelwenn (lanodan) Monnier 9996cecc72 Set ALT_OGL to libOpenGL.so.0 instead of libOpenGL.so.1 2021-03-15 10:10:38 +03:00
Cacodemon345 5f7eb88ae0 Load libOpenGL.so.1 if libGL.so.1 is not found 2021-03-14 17:37:55 -07:00
Ozkan Sezer 1957ffd21a fixed a typo in SDL_ceilf() 2021-03-14 11:04:28 +03:00
Cacodemon345 dacf6cfbaa Fix compilation with iconv on FreeBSD 2021-03-13 18:39:42 -08:00
nia a5f3ea1448 netbsdaudio: Handle ioctls failing
A user reported that the mpv video player hangs after attempting to
set an unsupported number of channels with the SDL audio output,
because it thinks it's successfully opened the device. This makes
the failure graceful.
2021-03-13 18:37:21 -08:00
Frank Praznik 4fbd60b817 audio: pipewire: Remove the nickname portion of sink/source names
Removes the node nickname from sink/source nodes as it doesn't provide any useful information and names now match those used in Pulseaudio, so any stored configuration data will be compatible between the two audio backends.
2021-03-13 18:36:47 -08:00
kenmays 72bcf546f9 SDL: Updated patches for HAIKU 2021-03-13 18:36:01 -08:00
Sylvain Becker 3d22731d94
Merge pull request #4175 from 1bsyl/br_blit_rgb555_to_rb1555
Fixed bug 3727 - Blit from RGB555 to ARGB1555
2021-03-11 20:10:07 +01:00
Sylvain 51345623e8
Fixed bug 3727 - Blit from RGB555 to ARGB1555 2021-03-11 20:06:09 +01:00
Ivan Epifanov 33127271e5 Fix typecasting 2021-03-09 12:10:40 +03:00
Ivan Epifanov a4ddb175f1 Formatting 2021-03-08 09:07:12 -08:00
Ivan Epifanov 4f9fde8766 Fix types 2021-03-08 09:07:12 -08:00
Ivan Epifanov e58a955e68 Deprecate dolcesdk 2021-03-08 09:07:12 -08:00
Ivan Epifanov e1d9cbf65c Split mouse/kb grab 2021-03-08 09:07:12 -08:00
uyjulian 29153a1c63 SDL_vitamessagebox: rearrange if/else
Set messageboxdata and buttonid as unused variables
2021-03-08 09:07:12 -08:00
uyjulian 70a19fd5ab SDL_vitamessagebox: if/else wrap preprocessor condition instead of two if conditions 2021-03-08 09:07:12 -08:00
uyjulian abcfb22b7d Add support for Vita file API in SDL_rwops 2021-03-08 09:07:12 -08:00
uyjulian c8abc88cd0 Add support for message box 2021-03-08 09:07:12 -08:00
José Cadete 91fe2b67f5 Allow larger texture sizes 2021-03-08 09:07:12 -08:00
Ivan Epifanov e5cbe7cf7a Add l2/r2 axes, l3/r3 buttons. rumble and ledbar support for ds4 2021-03-08 09:07:12 -08:00
Ivan Epifanov 7c4d20cf04 Fix for dolcesdk 2021-03-08 09:07:12 -08:00
Ivan Epifanov 3c1fe9cea6 WTF 2021-03-08 09:07:12 -08:00
Ivan Epifanov 6fab3323c3 Typo 2021-03-08 09:07:12 -08:00
José Cadete 739f4e1eb2 Only call sceGxmFinish when vsync is on
Also fix oversight with supported textures
2021-03-08 09:07:12 -08:00
uyjulian b52e9459ba Add support for open URL 2021-03-08 09:07:12 -08:00
Ivan Epifanov 189d3c16f5 FIFO is default (and not defined in vitasdk, ugh) 2021-03-08 09:07:12 -08:00
Ivan Epifanov 87a118b6b6 Use native mutexes 2021-03-08 09:07:12 -08:00
Ivan Epifanov 7423ae1ac7 Formatting 2021-03-08 09:07:12 -08:00
José Cadete ddfe7200e2 Rendering improvements
- Improve performance for unbatched rendering
- Support direct texture access
2021-03-08 09:07:12 -08:00
Ivan Epifanov 23db5381a3 Fix defines 2021-03-08 09:07:12 -08:00
Ivan Epifanov c7cec2c792 Add more texture formats 2021-03-08 09:07:12 -08:00
Ivan Epifanov e56c44512a Disable native framebuffer support 2021-03-08 09:07:12 -08:00
Ivan Epifanov 5e30d84b69 Fix display mode 2021-03-08 09:07:12 -08:00
Ivan Epifanov 10038228f9 Properly cleanup framebuffer 2021-03-08 09:07:12 -08:00
Ivan Epifanov 953101defd Oops. Fix default framebuffer color 2021-03-08 09:07:12 -08:00
Ivan Epifanov 1e2eed1a01 Native framebuffer for software renderer 2021-03-08 09:07:12 -08:00
Ivan Epifanov a7269a9ad3 Update video api to 2.0.14 2021-03-08 09:07:12 -08:00
Ivan Epifanov 7b0b1a12fa Update thread api to 2.0.14 2021-03-08 09:07:12 -08:00
Ivan Epifanov a05f92da1c Update joystick api to 2.0.14 2021-03-08 09:07:12 -08:00
Ivan Epifanov ca5e5d6154 VITASDK compatibility 2021-03-08 09:07:12 -08:00
Ivan Epifanov 7d89f09f74 ISO C90 fixes 2021-03-08 09:07:12 -08:00
Ivan Epifanov 0da35d3daf IME support with gxm backend 2021-03-08 09:07:12 -08:00
Ivan Epifanov 47c6270ece Fix a bug in vitagles2 renderer 2021-03-08 09:07:12 -08:00
Ivan Epifanov 639323ea0d Fixed gxm render flags 2021-03-08 09:07:12 -08:00
Ivan Epifanov 3ac2242e65 Fix PerformanceCounter 2021-03-08 09:07:12 -08:00
Ivan Epifanov 943053a922 Clean up touch a little more 2021-03-08 09:07:12 -08:00
Ivan Epifanov f61b9e7653 Cleanup touch. Fix back touchscreen 2021-03-08 09:07:12 -08:00
Ivan Epifanov d9b2bde2f6 Fallback to app0: 2021-03-08 09:07:12 -08:00
Ivan Epifanov 6f7c7c557a sensors corrections 2021-03-08 09:07:12 -08:00
Ivan Epifanov 6d85637786 Fix sensors 2021-03-08 09:07:12 -08:00
Ivan Epifanov e7edb06e7a Audio fix 2021-03-08 09:07:12 -08:00
Ivan Epifanov 05e5a7cb05 Oops 2021-03-08 09:07:12 -08:00
Ivan Epifanov a86ba3916e Add SDL_RenderReadPixels 2021-03-08 09:07:12 -08:00
Ivan Epifanov f623211eea remove sceGxmFinish on render swap 2021-03-08 09:07:12 -08:00
Ivan Epifanov 0b45529e24 Add viewport support 2021-03-08 09:07:12 -08:00
Ivan Epifanov 2209b71789 Refactor render state 2021-03-08 09:07:12 -08:00
Ivan Epifanov 333d5e11e1 Add drawstate cache 2021-03-08 09:07:12 -08:00
Ivan Epifanov 56bde0f633 Rename memory functions to avoid clash with vita2d 2021-03-08 09:07:12 -08:00
Ivan Epifanov 94d7737bef Texture render target 2021-03-08 09:07:12 -08:00
Ivan Epifanov 63e223fa50 Set initial blend mode 2021-03-08 09:07:12 -08:00
Ivan Epifanov 6c3bf56503 Unified build with both renderers 2021-03-08 09:07:12 -08:00
Ivan Epifanov a1adc8a9d6 Add sensor support 2021-03-08 09:07:12 -08:00
Ivan Epifanov bd14aa633f Autobuild 2021-03-08 09:07:12 -08:00
Ivan Epifanov 0131105408 Fix render name 2021-03-08 09:07:12 -08:00
Ivan Epifanov 6ba8497518 Remove vita2d render, add raw gxm render 2021-03-08 09:07:12 -08:00
Ivan Epifanov ef0bbfd6c6 Include anf fix vita2d renderer 2021-03-08 09:07:12 -08:00
Ivan Epifanov dbb730d395 Separate vita piglet renderer. Add proper render initialization and window re-creation. 2021-03-08 09:07:12 -08:00
Ivan Epifanov d75ea51ac0 Fix texture shaders 2021-03-08 09:07:12 -08:00
Ivan Epifanov 194c813893 Fix filesystem 2021-03-08 09:07:12 -08:00
Ivan Epifanov 73b545ed28 Fix joystick support 2021-03-08 09:07:12 -08:00
Ivan Epifanov 41d6c80b07 Filesystem module 2021-03-08 09:07:12 -08:00
Ivan Epifanov 2e3dd0a668 Remove debug log 2021-03-08 09:07:12 -08:00
Ivan Epifanov 8003623061 Cg shaders for vita gles2 2021-03-08 09:07:12 -08:00
Ivan Epifanov 2d64e37e41 Initial rebase of xerpi's port 2021-03-08 09:07:12 -08:00
Sylvain b6b0c908bd
Dynapi: fix 'gendynapi.pl' script for array parameters 2021-03-08 13:56:26 +01:00
Cameron Cawley 391bb80bb9 Replace duplicate functions and lstrlen/lstrcat with SDL string functions 2021-03-05 12:03:58 -08:00
Ethan Lee 67e8522d31 Add SDL_GetAudioDeviceSpec.
This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
2021-03-05 12:03:07 -08:00
Ozkan Sezer 686935542e dos2unix SDL_dynapi_*.h 2021-03-04 23:50:40 +03:00
Ozkan Sezer dd5aff308a SDL_fillrect.c: updated SSE_BEGIN macro for windows clang-cl
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:27:56 +03:00
Ozkan Sezer 0ed1713128 update SDL_COMPOSE_ERROR macro for windows clang-cl
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:27:47 +03:00
Ozkan Sezer c1c4f274c3 cpuinfo: updated xgetbv call for windows clang-cl.
from a patchset by Vladislav Dmitrievich Turbanov:
https://github.com/libsdl-org/SDL/pull/4062
2021-03-04 18:27:32 +03:00
Sylvain e88d78462e Update SDL_blit_auto.c 2021-03-04 14:36:33 +01:00
Sylvain ab0cf42a4b
Software nearest scaling: start at the middle of pixel
so that it matches opengl GL_NEAREST mode most of the time
2021-03-04 14:33:56 +01:00
Ozkan Sezer ac8a3fda8f fix prepare_audiospec() possibly missing a bad SDL_AUDIO_CHANNELS env. 2021-03-03 20:33:20 +03:00
Nicolas Noble 6158621610 Update cpuid code for clang-cl
The clang-cl compiler defines `__llvm__` but not `__GNUC__`. The `__cpuid` intrinsic doesn't seem to exist with clang-cl, so the code won't link properly. The `__GNUC__` versions of these functions will work properly on Windows with clang-cl.
2021-03-03 15:37:21 +03:00
Frank Praznik 4de0c74aa7 audio: pipewire: Add the application name to the stream properties 2021-03-02 12:59:04 -08:00
Frank Praznik 9ed01da701 audio: pipewire: Constify and clarify period size calculations
Constify the min/max period variables, use a #define for the base clock rate used in the calculations and note that changing the upper limit can have dire side effects as it's a hard limit in Pipewire.
2021-03-02 12:59:04 -08:00
Frank Praznik d7ca855c2b audio: pipewire: Add missing static qualifiers to globals 2021-03-02 12:59:04 -08:00
Oschowa 84c44e01d3 audio: pipewire: fix uninitialized variable warnings 2021-03-01 09:34:04 -08:00
Frank Praznik 7001b531c6 audio: pipewire: Add vim format lines to files and fix indentation
Increase indentation spacing from 2 to 4 to comply with style standards.
2021-02-28 19:40:09 -08:00
Frank Praznik 2fcba50ec9 audio: pipewire: Code and comment cleanups
Replace "magic numbers" with #defines, explain the requirements when using the userdata pointer in the node_object struct and a few other minor code and comment cleanups.
2021-02-28 19:40:09 -08:00
Frank Praznik 4eadd147cd audio: pipewire: Fix outdated comment 2021-02-28 19:40:09 -08:00
Frank Praznik cd56f1b346 audio: pipewire: Use "rear" designation for rear channels
Use the 'R' (rear) prefixed designations for the rear audio channels instead of 'S' (surround).  Surround designated channels are only used in the 8 channel configuration.
2021-02-28 19:40:09 -08:00
Frank Praznik adc0a931dd audio: Move Pipewire bootstrap after Jack
Move the Pipewire audio driver below others in the list so it won't be mistakenly initialized when it's not the system mixer.
2021-02-28 19:40:09 -08:00
Frank Praznik 21adec93b9 audio: pipewire: Make enumeration structure and function names more descriptive
Rename the add/remove/clear list functions and rename connected_device to io_node, as a sink/source node isn't necessarily a device.
2021-02-28 19:40:09 -08:00
Frank Praznik a07f543436 audio: pipewire: Report default devices first
Further refactor the device enumeration code to retrieve the default sink/source node IDs from the metadata node.  Use the retrieved IDs to sort the device list so that the default devices are at the beginning and thus are the first reported to SDL.
2021-02-28 19:40:09 -08:00
Frank Praznik 9afd7570d6 audio: pipewire: Always buffer source audio
The latency of source nodes can change depending on the overall latency of the processing graph. Incoming audio must therefore always be buffered to ensure uninterrupted delivery.

The SDL_AudioStream path was removed in the input callback as the only thing it was used for was buffering audio outside of Pipewire's min/max period sizes, and that case is now handled by the omnipresent buffer.
2021-02-28 19:40:09 -08:00
Frank Praznik 106dc009ac audio: pipewire: Pass proper parameter to user audio callback
The audio callbacks should pass the callbackspec.userdata parameter to the callback, not spec.userdata

Co-authored-by: Oschowa <Oschowa@web.de>
2021-02-28 19:40:09 -08:00
Frank Praznik f3ebbc06d3 audio: pipewire: Retrieve the channel count and default sample rate for sinks/sources
Extend device enumeration to retrieve the channel count and default sample rate for sink and source nodes.  This required a fairly significant rework of the enumeration procedure as multiple callbacks are involved now.  Sink/source nodes are tracked in a separate list during the enumeration process so they can be cleaned up if a device is removed before completion.  These changes also simplify any future efforts that may be needed to retrieve additional configuration information from the nodes.
2021-02-28 19:40:09 -08:00
Frank Praznik 2f0b99a774 audio: Add Pipewire playback/capture sink 2021-02-28 19:40:09 -08:00
Ethan Lee 57a927e8d7 wayland: Explicitly set min/max size for xdg-shell 2021-02-28 19:37:31 -08:00
Cacodemon345 33598563b3 Fix coding style 2021-02-26 09:32:04 -08:00
Cacodemon345 69a600b00e Implement requested changes 2021-02-26 09:32:04 -08:00
Cacodemon345 0e35f0be1f Fix KMSDRM-related warnings 2021-02-26 09:32:04 -08:00
Cameron Gutman dfa64eadd3 KMSDRM: Add hint to enable the backend without DRM master
In some cases, it can be useful to have the KMSDRM backend even if it cannot
be used for rendering. An app may want to use SDL for input processing while
using another rendering API (such as an MMAL overlay on Raspberry Pi) or
using its own code to render to DRM overlays that SDL doesn't support.

This also moves the check for DRM master to an earlier point where we can fail
initialization of the backend, rather than allowing the backend to initialize
then failing the creation of a window later.
2021-02-25 18:48:36 -08:00
Cameron Gutman 8c5b7af2d2 Wayland: Fix mouse pointer hiding on Plasma Wayland
Unlike Mutter and Sway, KWin actually checks the serial passed in
wl_pointer_set_cursor(). The serial provided is supposed to be the
serial of the pointer enter event, but We were always passing 0.
This caused KWin to drop our requests to hide the cursor.

Thanks to the KDE folks for spotting this in my debug logs.

Fixes #3576
2021-02-25 18:47:12 -08:00
Cacodemon345 d2d834b990 KMSDRM: Add gamma support 2021-02-25 11:39:10 -08:00
Ozkan Sezer 72f7a10cef disable pixman ARM blitters for __aarch64__ | _M_ARM64
Closes:  https://github.com/libsdl-org/SDL/issues/4095
2021-02-25 11:38:14 -08:00
Ozkan Sezer e561ce3a75 SDL_cpuinfo.c: replaced gcc i386 checks with __i386__ . 2021-02-25 01:40:02 +03:00
JibbSmart c287087fcc Only change joystick->nbuttons for Joy-Cons, since they're the only ones that have these "paddles" 2021-02-22 17:54:32 -08:00
JibbSmart ee52624f95 Switch Joy-Con SL and SR buttons are now mapped to matching paddle positions so that all buttons can be accessed when using SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS 2021-02-22 17:54:32 -08:00
Mathieu Eyraud 7a2b6f331b Guard Inotify stuff with macro
This fix implicit declaration of close and unused variable warning.
2021-02-22 09:07:07 -08:00
Mathieu Eyraud 8481229ff7 Fix error handling in KMSDRM_AddDisplay
Add missing `goto cleanup` and check that `dispdata` is not NULL before dereferencing it.
2021-02-22 09:01:36 -08:00
Mathieu Eyraud 2df9c15e96 Fix memory leak in KMSDRM_Vulkan_CreateSurface
Variable `device_props` is never freed.
2021-02-22 09:00:45 -08:00
Mathieu Eyraud 844d5e3ed3 Fix memory leak in ConnectSensor
'name' is leaked in case of error.
2021-02-21 16:46:20 -08:00
Vanfanel 11cb53d2a5 [KMSDRM] Add missing break and modify comments. 2021-02-21 15:27:12 -08:00
Vanfanel 9172e413ad [KMSDRM] Fix intermitent bug in Vulkan initialization on Raspberry Pi 4. 2021-02-21 15:27:12 -08:00
Sam Lantinga 1a17ab30e1 Added mappings for popular controllers on Chromebooks 2021-02-21 11:03:26 -08:00
David Gow db58166e9b joystick: hidapi: Properly include <unistd.h> when inotify not available
In the extremely unlikely event that inotify is not available (and,
therefore, HAVE_INOTIFY is not #defined), SDL will no-longer build.

This is because <unistd.h> is only included when HAVE_INOTIFY is
defined, and PR #4098 adds a call to access(…, F_OK), which requires
<unistd.h>.

(Note that the F_OK symbol is the only one which actually prevented
SDL from compiling, but both access() and close() fell back to implicit
definitions, which is a bit concerning.)

Fixes: 8d43f45a7b ("Don't use udev for joystick enumeration if running in a container")
2021-02-21 12:55:01 +03:00
Amir 360740ac76 correct dynapi 2021-02-20 23:05:09 -08:00
Amir 1a924bc0bb add SDL_AndroidShowToast for https://developer.android.com/reference/android/widget/Toast 2021-02-20 23:05:09 -08:00
Ludovico de Nittis 8d43f45a7b Don't use udev for joystick enumeration if running in a container
If we are running in a container, like Flatpak[1] or pressure-vessel[2],
it's likely that we are using user namespaces,
therefore udev event notification via netlink won't work reliably.
Use their filesystem API to detect them and automatically fallback to
the inotify-based enumeration.

[1] <https://flatpak.org/>
[2]
<https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2021-02-20 23:01:38 -08:00
Ludovico de Nittis 2c3269152a Use inotify for HIDAPI joystick enumeration if not using udev
This improves SDL's ability to detect HIDAPI joystick hotplug in a
container environment because we cannot reliably receive events from
udev in a container.

For a more detailed explanation of why this issue happens with
containers, please check the previous commit
"joystick: Use inotify to detect joystick unplug if not using udev"
(b0eba1c5).

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2021-02-20 23:01:38 -08:00
Ludovico de Nittis b17242bf98 Allow libudev for HIDAPI joystick to be disabled at runtime
As already explained in the previous commit "joystick: Allow libudev to
be disabled at runtime" (13e7d1a9), libudev can fail in a container.

To make it easier to experiment with, we add a new environment variable
"SDL_HIDAPI_JOYSTICK_DISABLE_UDEV" that disables udev and let it
fallback to the device enumeration using polling.

Signed-off-by: Ludovico de Nittis <ludovico.denittis@collabora.com>
2021-02-20 23:01:38 -08:00
Jay 0052339b66 Move handleURLEvent setEventHandler to init 2021-02-20 22:59:11 -08:00
Sam Lantinga 42607909a0 Remove devices from the list after they've been disconnected due to read errors.
This fixes problems with controllers not being re-detected when a computer goes to sleep and a controller is removed and plugged back in while it's asleep.
2021-02-20 22:51:57 -08:00
Oschowa 08547adb52 pulseaudio: Add "zerocopy" playback path 2021-02-20 12:50:36 -05:00
Romain Roffé ef85ed9352 pulseaudio: Initialize fragsize to fix mic recording
fragsize wasn't initialized, and it is used for recording.
If the value was 0 or -1, pulseaudio configures it itself. But sometimes
we can get a random (and large) value that makes pulseaudio give us
large sample at a very low frequency.

https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/master/src/pulse/def.h#L453
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/blob/v13.0/src/pulsecore/protocol-native.c#L409
2021-02-18 09:51:35 -05:00
Vanfanel e4a81a98a0 [KMSDRM] Correct indentation. 2021-02-17 17:03:42 +03:00
Cameron Cawley 98bf79cff1 Minor improvements for CPU detection on ARM 2021-02-17 11:10:02 +03:00
Matt Borgerson 4aa2e74844 Add Xbox Controller S entry to gamecontrollerdb 2021-02-16 10:15:44 -08:00
Ozkan Sezer f2a2d0c696 SDL_render_d3d.c: fix build with SDL_LEAN_AND_MEAN 2021-02-15 22:56:20 +03:00
Alex Szpakowski 09231c42ea Fix flags check in test code 2021-02-15 08:43:53 -08:00
Alex Szpakowski 9b9d0d484d mac/iOS: allow Metal in windows created without an explicit backend
Fixes SDL_CreateWindowAndRenderer (and similar situations) not choosing a Metal backend. See #3991.

Passing an explicit backend into CreateWindow, eg SDL_WINDOW_OPENGL or SDL_WINDOW_METAL, will still prevent the window from being used with other backend types.
2021-02-15 08:43:53 -08:00
Ozkan Sezer a2fbc452ca replace i386 checks with __i386__ 2021-02-15 03:02:32 +03:00
Cacodemon345 cf15faae68 Change "memset" to "SDL_zero" 2021-02-14 13:54:08 -05:00
Cacodemon345 c5f9e061b5 Disable FreeBSD console mouse when initializing evdev input
Enable it again after quitting evdev input.
2021-02-14 13:54:08 -05:00
Misa 3da58b47f6 Fix errors with fallback impls of SDL_isxdigit() and SDL_ispunct()
SDL_isxdigit() should only accept A-Fa-f, not A-Za-z (it shouldn't use
SDL_isalpha()).

SDL_ispunct() shouldn't accept spaces (it should use SDL_isgraph()
instead).
2021-02-13 19:30:24 -05:00
Misa dfe219ec71 Add all missing "is characteristic" stdlib functions
SDL has been missing a bunch of these 'isX' functions for some time,
where X is some characteristic of a given character.

This commit adds the rest of them to the SDL stdlib, so now we have:
- SDL_isalpha()
- SDL_isalnum()
- SDL_isblank()
- SDL_iscntrl()
- SDL_isxdigit()
- SDL_ispunct()
- SDL_isprint()
- SDL_isgraph()
2021-02-13 11:42:13 -08:00
Charlie Birks 1a48ca666f emscripten: Create directory recursively in GetPrefPath 2021-02-13 11:56:01 -05:00
Stephan Vedder fa367cdd5c emscripten: Fix alt key being a nav key 2021-02-13 11:56:01 -05:00
Alon Zakai 20be1d634b emscripten: Automatically resume audio contexts
This uses the mechanism added in emscripten-core/emscripten#10843
which was applied to SDL1 and OpenAL. This adds the same for SDL2.

This also reverts commit 865eaddffed50dbd13e6564c3f73902472cf74e8
which did something similar, but the new mechanism is more effective.
2021-02-13 11:56:01 -05:00
Charlie Birks edaf3f9c9c emscripten: Extend the "nav key" blacklist
Add the F keys and Ctrl/Alt+*. Consistent with other naviagtion
disabling. Also, none of these generate keypress events anyway.
2021-02-13 11:56:01 -05:00
Ethan Lee a99eec7751 wayland: Minor whitespace fix 2021-02-13 02:41:29 +03:00
Ryan C. Gordon 65fbf36c9e Cleaned up a few more Bugzilla mentions. 2021-02-12 14:46:49 -05:00
Ryan C. Gordon 4ff51d29c3 Deprecate SDL_GetRevisionNumber and update things for git instead of hg.
Fixes #4063
2021-02-12 14:31:38 -05:00
soredake 39153f81b9 add Linux mapping for Ipega PG-9087S, closes #3783 2021-02-12 08:00:41 -08:00
Jay Petacat f443a6fc7a Fix format string warnings for width-based integers
The DJGPP compiler emits many warnings for conflicts between print
format specifiers and argument types. To fix the warnings, I added
`SDL_PRIx32` macros for use with `Sint32` and `Uint32` types. The macros
alias those found in <inttypes.h> or fallback to a reasonable default.

As an alternative, print arguments could be cast to plain old integers.
I opted slightly for the current solution as it felt more technically correct,
despite making the format strings more verbose.
2021-02-11 19:41:41 -08:00
Sam Lantinga 5427f4861b Added support for trigger rumble for all Microsoft Xbox One controllers 2021-02-11 17:28:07 -08:00
Sam Lantinga 1f7ec3fa4e Added support for the PowerA Xbox One Series X Wired Controller 2021-02-11 17:27:22 -08:00
Ethan Lee cad67082f3 wayland: Check for both _WAYLAND_CLIENT_H and WAYLAND_CLIENT_H 2021-02-11 14:27:08 -08:00
Sam Lantinga 629334f283 Fixed bug 5543 - Wayland: Fix waylandvideo.h warnings
wahil1976

This patch fixes the warnings seen when compiling the Wayland backend. This will also be required in the future to avoid issues with compilation.
2021-02-10 10:22:20 -05:00
Cameron Gutman f70e197363 Fix waiting on condition variables with the SRW lock implmentation
When SleepConditionVariableSRW() releases the SRW lock internally, it causes
our SDL_mutex_srw state to become inconsistent. The lock is unowned yet inside,
the owner is still the sleeping thread and more importantly the owner count is
still 1.

The next time someone acquires the lock, they will bump the owner count from 1
to 2. At that point, the lock is hosed. From the internal lock state, it looks
to us like that owner has acquired the lock recursively, even though they have
not. When they call SDL_UnlockMutex(), it will see the owner count > 0 and not
call ReleaseSRWLockExclusive().

Now when someone calls SDL_CondSignal(), SleepConditionVariableSRW() will start
the wakeup process by attempting to re-acquire the SRW lock. This will deadlock
because the lock was never released after the other thread had used it. The
thread waiting on the condition variable will never be able to wake up, even if
the SDL_CondWaitTimeout() function is used and the timeout expires.
2021-02-10 10:22:20 -05:00
Sam Lantinga d9ba20442e Backed out changeset 852a7bdbdf4b
This causes a use-after-free memory error
2021-02-10 10:22:20 -05:00
Christian Rauch 4183211a54 free the 'display' after it was added to global list 2021-02-10 10:22:20 -05:00
Manuel Alfayate Corchete 005e2c59a7 [KMS/DRM] Bugfix number #5535: Improve reliability, by wahil1976. 2021-02-10 10:22:20 -05:00
Ozkan Sezer dc45a228b9 avoid some pedantic warnings in array initializers 2021-02-10 10:22:20 -05:00
Sam Lantinga 9c3aa7f055 SDL: fix packet handling for original version of Stadia FW 2021-02-10 10:22:20 -05:00
Ozkan Sezer bb9e049d1d minor updates to libc function checks 2021-02-10 10:22:19 -05:00
Manuel Alfayate Corchete 19fa85d8af [KMS/DRM] Fix build warning. 2021-02-10 10:22:19 -05:00
Manuel Alfayate Corchete 6ee53258cd [KMS/DRM] Replace indent tabs with spaces, as intended. 2021-02-10 10:22:19 -05:00
Manuel Alfayate Corchete 59cd46c24a [KMS/DRM] Merge patch for bug #5532: No need to correct cursor position now that all windows are fullscreen. Link: https://bugzilla.libsdl.org/show_bug.cgi?id=5519. 2021-02-10 10:22:19 -05:00
Manuel Alfayate Corchete 538f7ad6b7 [KMS/DRM] Remove redundant SDL_SendWindowEvent() call. 2021-02-10 10:22:19 -05:00
Manuel Alfayate Corchete 7beba05013 [KMS/DRM] Restore all-windows-are-fullscreen functionality, since there is no window manager in KMSDRM. 2021-02-10 10:22:19 -05:00
Cameron Gutman f4d58689e0 Fix Xbox Series X controller on macOS
There were two different implementations of IsBluetoothXboxOneController(), one
in SDL_hidapi_xbox360.c and one in SDL_hidapi_xboxone.c. The latter had been
updated to include USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH while the former had
not.

This mismatch led to the Xbox Series X failing on macOS only. We have special
code for handling the 360Controller driver for macOS which requires us to use
the Xbox 360 driver for wired Xbox One controllers, and the SDL_hidapi_xbox360
version of IsBluetoothXboxOneController() was used to determine which devices
were wired.

In addition to adding the missing USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH, this
change moves IsBluetoothXboxOneController() into a single shared function which
will ensure this bug won't happen again.
2021-02-10 10:22:19 -05:00
Sam Lantinga ff297753db Fixed compiler warning 2021-02-10 10:22:19 -05:00
Sam Lantinga a60af1e4d0 Backed out changeset 1cde3dd0f44d - this breaks windows which are created and then set to FULLSCREEN_DESKTOP 2021-02-10 10:22:19 -05:00
Sam Lantinga e404b525f1 KMSDRM doesn't have a window manager, so all windows are fullscreen 2021-02-10 10:22:19 -05:00
Sylvain Becker 549bc13362 SDL_vulkan_utils: minor code clean-up 2021-02-10 10:22:19 -05:00
Sylvain Becker c0166a29b7 SDL_ConvertColorkeyToAlpha: remove and clarify a FIXME
This function doesn't handle bpp 1 or 3 case, because those formats never have an alpha channel
2021-02-10 10:22:19 -05:00
Sam Lantinga 85235985fb Fixed detecting the paddles on the Xbox Elite Series 1 controller 2021-02-10 10:22:19 -05:00
Sam Lantinga 69e9b2acee Fixed bug 5471 - Creating a fullscreen desktop window goes windowed temporarily
This is caused by the Metal renderer recreating the window because by default we create an OpenGL window on macOS.

It turns out that at least on macOS 10.15, a window that has been initialized for OpenGL can also be used with Metal. So we'll skip recreating the window in that case.
2021-02-10 10:22:19 -05:00
Sam Lantinga ef2f13e125 Added test command line options to force different window types 2021-02-10 10:22:19 -05:00
Sam Lantinga 2426949a18 Removed support for clock_gettime_nsec_np()
SDL_GetTicks() was broken and it's not adding any real value here.
2021-02-10 10:22:19 -05:00
Sam Lantinga fadfa51022 Don't uncorrelate while rumble is active and stay correlated longer in case raw input messages are lagging a bit. 2021-02-10 10:22:19 -05:00
Sebastian Krzyszkowiak e862856e6f wayland: Don't crash when the properties of already existing wl_output change 2021-02-10 10:22:18 -05:00
Sam Lantinga cef198c9cb Fixed bug 5524 - Pass NSString to NSLog()
Hiroyuki Iwatsuki

If you pass the C string directly to NSLog(), it will be garbled with Japanese and probably other language strings, or no log will be output at all.

NSLog("Hello, World!"); // => "Hello, World!"
NSLog("こんにちは、世界!"); // => No output...

Therefore, you need to convert the string to an NSString before passing it to NSLog().

NSString *str = [NSString stringWithUTF8String:"こんにちは、世界!"];
NSLog(@"%@", str); // => "こんにちは、世界!"

Thank you.
2021-02-10 10:22:18 -05:00
Christian Rauch 0ed16ceddb free 'outputs' in 'Wayland_DestroyWindow' 2021-02-10 10:22:18 -05:00
Christian Rauch a44678465f free the 'data_device_manager' 2021-02-10 10:22:18 -05:00
Sebastian Krzyszkowiak 3ae2ec34fa wayland: Fix transform and scale handling when setting display mode 2021-02-10 10:22:18 -05:00
Manuel Alfayate Corchete 2c76433151 [KMS/DRM] Merge patch for bug 5522#: Implement KMSDRM_GetWindowWMInfo(). 2021-02-10 10:22:18 -05:00
Manuel Alfayate Corchete bfa51c3845 [KMS/DRM] Fix for bug #5518: only do async pageflips when hardware supports them. 2021-02-10 10:22:18 -05:00
Cameron Gutman 79cd8cab08 Add default handler for Alt+Tab while keyboard grab is enabled
By default, we will minimize the window when we receive Alt+Tab with a
full-screen keyboard grabbed window to allow the user to escape the
full-screen application.

Some applications like remote desktop clients may want to handle Alt+Tab
themselves, so provide an opt-out via SDL_HINT_ALLOW_ALT_TAB_WHILE_GRABBED=0.
2021-02-10 10:22:18 -05:00
Sylvain Becker 9d70711342 Revert checks on destination scaling size (see bug #5510) 2021-02-10 10:22:18 -05:00
Manuel Alfayate Corchete 088fb52579 [KMS/DRM] Correct small omission on bugfix #5513: y-coord correction has to be done on WarpMouseGlobal, too. 2021-02-10 10:22:18 -05:00
Sam Lantinga 2cc70ca39e Fixed crash if the GameCube controller hasn't been opened yet 2021-02-10 10:22:18 -05:00
Sylvain Becker d6a6662fa1 Remove checks on destination scaling size (see bug #5510) 2021-02-10 10:22:18 -05:00
Manuel Alfayate Corchete 8d95aba174 [KMS/DRM] Remove unused KMSDRM_SetWindowGrab prototype in header file. 2021-02-10 10:22:18 -05:00
Manuel Alfayate Corchete b17c49509b [KMS/DRM] Patch for bug #5513. KMSDRM backend can now manage and use several displays. 2021-02-10 10:22:18 -05:00
Cameron Gutman a78bce9e38 Properly handle keys already down when the hook is installed
For keys that are already down when we install the keyboard hook, we need to
allow the WM_KEYUP/WM_SYSKEYUP message to be processed normally. This ensures
that other applications see the key up, which prevents the key from being stuck
down from the perspective of other apps when our grab is released.
2021-02-10 10:22:18 -05:00
Sylvain Becker dc0ec827aa Remove old YUV fixme 2021-02-10 10:22:18 -05:00
Sylvain Becker ebb814310a Add checks for maximun scaling size (see bug #5510) 2021-02-10 10:22:18 -05:00
Sam Lantinga 7f710e93f0 Make sure we don't create a game controller mapping for HID devices that aren't supported by HIDAPI 2021-02-10 10:22:18 -05:00
Sam Lantinga 7e19c634c1 Note that the Logitech G29 (PS4) is a racing wheel 2021-02-10 10:22:18 -05:00
Sylvain Becker d59f8dafe4 Fixed bug 5510 - simplify the scaling functions blit auto (generated file) 2021-02-10 10:22:17 -05:00
Sylvain Becker 0b338bffe6 Fixed bug 5510 - simplify the scaling functions 2021-02-10 10:22:17 -05:00
Sylvain Becker dd6e02df63 SDL_stretch: remove un-used vars, same notation as blit functions 2021-02-10 10:22:17 -05:00
Sam Lantinga 1dc9180fb6 Fixed compiler warnings 2021-02-10 10:22:17 -05:00
Sam Lantinga d59a926837 Fixed build warning 2021-02-10 10:22:17 -05:00
Sam Lantinga eb83da0234 Fixed PS4 controllers over Bluetooth on Windows 7 2021-02-10 10:22:17 -05:00
Sam Lantinga d95a9eaedc Added WIN_IsWindows8OrGreater() for internal use 2021-02-10 10:22:17 -05:00
Cameron Gutman 808249a5ca X11: Ungrab the keyboard when the mouse leaves the window
GNOME Mutter requires keyboard grab for certain important functionality like
window resizing, interaction with the application context menu, and opening the
Activites view. To allow Mutter to grab the keyboard as needed, we'll ungrab
when the mouse leaves our window.

To be safe, we'll do this for all WMs since forks of Mutter and Matacity (and
possibly others) may have the same behavior, and we don't want to have to keep
track of those.
2021-02-10 10:22:17 -05:00
Ozkan Sezer 87f0900701 SDL_LowerSoftStretchLinear: assign result from scale_mat() to ret.
otherwise it would always return -1 when SSE and NEON instrinsics
are absent.
2021-02-10 10:22:17 -05:00
Sam Lantinga 24d6fda2c3 Fixed bug 3816 - asm code in video/SDL_stretch.c
Sylvain

I propose this new version for SDL_stretch.c that drops mprotect and asm

Code is similar to the StretchLinear, but the steps computation are kept similar to the nearest.
so that:
- it's pixel perfect with nearest
- as fast as asm I think
- no asm, nor mprotect
- benefit for all archicture
2021-02-10 10:22:17 -05:00
Sam Lantinga d81eaf8da5 Added explicit case from Uint8 to int before subtracting offset 2021-02-10 10:22:17 -05:00
Sam Lantinga bec9d740ec Fixed compile warning 2021-02-10 10:22:17 -05:00
Sam Lantinga a4db44fa71 The Sharkoon Skiller SGH2 headset hangs in DirectInput enumeration, so avoid it here just in case.
See bug 5485 for details.
2021-02-10 10:22:17 -05:00
Sam Lantinga 06ad887f44 Fixed bug 3816 - asm code in video/SDL_stretch.c
Ozkan Sezer

- adds MSVC __declspec(align(x)) support,
- disables asm if PAGE_ALIGNED no macro is defined,
- still disables asm for gcc < 4.6, need more info,
- drops Watcom support.
2021-02-10 10:22:17 -05:00
Sam Lantinga 1e5f0073c6 Fixed building with mingw64 2021-02-10 10:22:17 -05:00
Sylvain Becker 70b353d1a5 SDL_Update{YUV,NV}Texture: also intersect rect with texture dimension 2021-02-10 10:22:17 -05:00
Sylvain Becker 13626c3681 SDL_UpdateTexture: intersect update rect with texture dimension
- fix crash with software renderer
- fix non texture update with opengl/gles2
2021-02-10 10:22:17 -05:00
Sylvain Becker 5e3cf0d1f4 SDL_SoftStretch: disable asm path if mprotect isn't available (see bug #3816) 2021-02-10 10:22:17 -05:00
Cameron Gutman 6b057c6783 Expose separate keyboard and mouse grab support
This adds SDL_SetWindowKeyboardGrab(), SDL_GetWindowKeyboardGrab(),
SDL_SetWindowMouseGrab(), SDL_GetWindowMouseGrab(), and new
SDL_WINDOW_KEYBOARD_GRABBED flag. It also updates the test harness to exercise
this functionality and makes a minor fix to X11 that I missed in
https://hg.libsdl.org/SDL/rev/02a2d609369b

To fit in with this new support, SDL_WINDOW_INPUT_CAPTURE has been renamed to
SDL_WINDOW_MOUSE_CAPTURE with the old name remaining as an alias for backwards
compatibility with older code.
2021-02-10 10:22:17 -05:00
Sylvain Becker ff827fc767 SDL_SoftStretch: re-enable USE_ASM_STRETCH path for gcc >= 4.6 2021-02-10 10:22:17 -05:00
Cameron Gutman a1d288bea1 DirectFB: Split input grab handling into keyboard and mouse parts
The grabbed_window field is superfluous now since SDL added the
SDL_GetGrabbedWindow() function, so it can be removed.

DirectFB_SetWindowMouseGrab() is also simplified because SDL handles ungrabbing
any previously grabbed window prior to calling SetWindowMouseGrab() now.

Compile-tested only.
2021-02-10 10:22:16 -05:00
Sam Lantinga de85d61256 Fixed bug 5497 - SDL_COMPOSE_ERROR is wrong
UMU

#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str

I think SDL_STRINGIFY_ARG should be removed.

#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str

(verified with Visual Studio 2019)
2021-02-10 10:22:16 -05:00
Sam Lantinga ac72a2ba8e Fixed bug 5493 - Hint to let the user opt out of having Switch controllers' Home button lit when opened
jibb

New hint to let the user opt out of having Switch controllers' Home button lit when opened.

This is more consistent with the Switch itself (which doesn't light the button normally) and may be preferred by users who may disconnect their controller without letting the application close it.

I think this warrants a Switch-specific hint because the default behaviour is unusual (inconsistent with using a Switch controller on a Switch itself or with some other programs on PC), and because of that it's distinct from other lights (the player number on Switch controllers and the player colour on PlayStation controllers).
2021-02-10 10:22:16 -05:00
Sam Lantinga f23022ef97 Removed non-functional window grab implementations 2021-02-10 10:22:16 -05:00
Cameron Gutman a0d3c6c63c Rename SetWindowGrab() to SetWindowMouseGrab() 2021-02-10 10:22:16 -05:00
Cameron Gutman d133a5f6f7 wayland: cancel key repeat when keyboard focus is lost
SDL_SetKeyboardFocus(NULL) will lift any keys still pressed when keyboard focus
leaves the window, but then key repeat comes behind our backs and presses the
key down again. This results in an infinite stream of SDL_KEYDOWN events when
focus leaves the window with a key down (particularly noticeable with Alt+Tab).
2021-02-10 10:22:16 -05:00
Cameron Gutman 2793c9cfb0 Fix grabbing Alt+Tab and Alt+Esc on Windows 7 2021-02-10 10:22:16 -05:00
Cameron Gutman e1f73e642b Refactor keyboard grab to be managed by the video core
This gives us flexibility to add others hints to control keyboard grab behavior
without having to touch all of the backends. It also allows us to possibly
expose keyboard grab separately from mouse grab for applications that want to
manage those independently.
2021-02-10 10:22:16 -05:00
Sylvain Becker f40551c5f6 GLES2 SDL_Renderer: remove old ZUNE_HD defines and simplify shader cache 2021-02-10 10:22:16 -05:00
Ozkan Sezer b852590ba5 minor clean-up in SDL_os2audio.c 2021-02-10 10:22:16 -05:00
Brandon DeRosier 141f441633 fix build failure due to -Werror=declaration-after-statement (bug #5500) 2021-02-10 10:22:16 -05:00
Manuel Alfayate Corchete 8e1005f8b0 [KMS/DRM] Bugfix for #5489: Non-FULLSCREEN windows incorrecty use videomode changing to look fullscreen. 2021-01-24 00:51:26 -05:00
Ethan Lee e787282ba8 Implement Wayland_SetWindowResizable 2021-01-24 00:51:26 -05:00
Simon McVittie c16cfc0e92 waylandtouch: Don't export interface structs
These are explicitly written in C code rather than generated at build
time, so they weren't affected by changing how we invoke
wayland-scanner.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2021-01-24 00:51:26 -05:00
Sam Lantinga c857b5e0c9 Minor cleanup 2021-01-24 00:51:26 -05:00
Sam Lantinga 1981d23f4b Fixed bug 5466 - Add haptic support for Stadia Controller
Dimitriy Ryazantcev

Consider adding support for Stadia Controller haptics.

Here is example code how to deal with it:
99314be815/device/gamepad/hid_haptic_gamepad.cc (L45)
2021-01-24 00:51:26 -05:00
Sam Lantinga 96cfb81232 Fixed bug 5467 - SDL sys timer Mac OS update proposal
David Carlier

Change of api from 2016 which reduce code complexity a bit.
2021-01-24 00:51:25 -05:00
JibbSmart 0f57864c9e Hint SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS added so we can recognise a Joy-Con as half a Pro Controller, so we can read its analog input and read its sensors just like we do a Pro Controller. 2021-01-24 00:51:25 -05:00
Cameron Gutman bd553ea868 Implement support for inhibiting the screensaver on Wayland
We support both the org.freedesktop.ScreenSaver D-Bus API (same as the X11
backend) and the Wayland idle_inhibit_unstable_v1 protocol.

Some Wayland compositors only support one or the other, so we need both to
for broad compatibility.
2021-01-24 00:51:25 -05:00
Cameron Gutman 7ff3832e4d Fix continuous scrolling speed on Wayland
Wayland compositors seem to have standardized on 10 units per "wheel tick" for
continuous scroll events, so we need to convert these axis values to ticks by
dividing by 10 before reporting them in SDL_MOUSEWHEEL events.
2021-01-24 00:51:25 -05:00
Cameron Gutman 8c921d8201 Implement keyboard grab support for Windows
This is implemented via a low-level keyboard hook. Unfortunately, this is
rather invasive, but it's how Microsoft recommends that it be done [0].
We want to do as little as possible in the hook, so we only intercept a few
crucial modifier keys there, while leaving other keys to the normal event
processing flow.

We will only install this hook if SDL_HINT_GRAB_KEYBOARD=1, which is not
the default. This will reduce any compatibility concerns to just the SDL
applications that explicitly ask for this behavior.

We also remove the hook when the grab is terminated to ensure that we're
not unnecessarily staying involved in key event processing when it's not
required anymore.

[0]: https://docs.microsoft.com/en-us/windows/win32/dxtecharts/disabling-shortcut-keys-in-games
2021-01-24 00:51:25 -05:00
Ozkan Sezer fd65aaa9a8 move outdated winmm and psp joystick codes to struct _SDL_JoystickDriver
build-tested only. (bug #5472.)
2021-01-24 00:51:25 -05:00
Ozkan Sezer 8f1025899a os2audio: changed backend name from MMOS2 to DART (like SDL-1.2) 2021-01-24 00:51:25 -05:00
Ozkan Sezer 2376458841 renamed SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H to SDL_HAVE_MACHINE_JOYSTICK_H 2021-01-24 00:51:25 -05:00
Sam Lantinga f68b36df75 Added support for the EVORETRO GameCube Adapter in PC mode 2021-01-24 00:51:25 -05:00
Sam Lantinga 9c88eac856 ControllerList: fix typo 2021-01-24 00:51:25 -05:00
Ozkan Sezer 11fce32162 SDL_dinputjoystick.c: fixes to dfDIJoystick2[] array from Wine git.
Fix V/A/FSlider dwOfs values in c_dfDIJoystick2
af2f419426

Add missing ASPECT flags for c_dfDIJoystick2
e2e100272f

Closes bug #5474.
2021-01-24 00:51:25 -05:00
Ozkan Sezer 4a776557af old os2 analogue joystick code ported from SDL-1.2. disabled by default,
build-tested only.
2021-01-24 00:51:25 -05:00
Ozkan Sezer e91f83c1e0 hidapi.h: adjust so that it gives a smaller diff against mainstream 2021-01-24 00:51:25 -05:00
Sam Lantinga d4794028bb Fixed build 2021-01-24 00:51:25 -05:00
Sam Lantinga 9e45372a2f Fixed build on Android and iOS 2021-01-24 00:51:25 -05:00
Cameron Gutman 19236b462a Implement support for minimizing windows on Wayland
This required a bit of extra code to deal with the transition from minimized
back to fullscreen
2021-01-24 00:51:25 -05:00
Cameron Gutman cf84ec441f Improve reliability of cursor hiding on GNOME Wayland
Hiding the cursor doesn't appear to work reliably on GNOME when another window
steals mouse focus right as we call SDL_ShowCursor(SDL_DISABLE). This can happen
when the keyboard shortcut inhibition permission prompt appears in response to a
call to SDL_SetRelativeMouseMode() with SDL_HINT_GRAB_KEYBOARD=1. The result is
that the default cursor is stuck locked in position and visible on screen
indefinitely.

By redrawing the cursor on pointer focus enter, the cursor now disappears upon
the first mouse motion event. It's not perfect but it's way better than the
current behavior.
2021-01-24 00:51:25 -05:00
Sam Lantinga bf53651d73 Make sure we only do GameCube adapter initialization if we were able to load libusb 2021-01-24 00:51:24 -05:00
Sam Lantinga 3527b49459 Fixed initializing the Nyko and EVORETRO GameCube adaptors
This requires root on most Linux distributions, as we have to directly send USB messages to the devices to enable input reports.
2021-01-24 00:51:24 -05:00
Ozkan Sezer b6ae9a7cba renamed my_gradd.h to SDL_gradd.h 2021-01-24 00:51:24 -05:00
Sam Lantinga 178ae70a29 Don't add paddle mappings for the Xbox One Elite Series 1 controller, since they can't be unmapped and read directly on that controller. 2021-01-24 00:51:24 -05:00
Cameron Gutman d789ba8332 Implement keyboard grab support for Wayland
Use zwp_keyboard_shortcuts_inhibit_manager_v1 to allow SDL applications
to capture system keyboard shortcuts like Alt+Tab when keyboard grab is
enabled via SDL_HINT_GRAB_KEYBOARD.
2021-01-24 00:51:24 -05:00
Cameron Gutman 6e97170e96 Use PS4 rumble hint as the default for the PS5 rumble hint
Existing SDL applications may not know about the need to set a specific
hint to enable rumble on PS5 controllers, even though they may already
set the equivalent SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE hint for PS4
controller rumble support.

Rather than requiring those developers update their apps, let's use the
SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE value as an indication of the behavior
they are expected for all PlayStation controllers.
2021-01-24 00:51:24 -05:00
Ozkan Sezer 07f83cd5a6 hidapi/libusb/hid.c: fix race condition on device close (bug #5484)
From hidapi mainstream git: https://github.com/libusb/hidapi/issues/142
d2c3a9862e

Read callback may fire itself on its own even after its been requested
to stop and exactly before the calling code waits for its completion in
indefinite loop.  Explicitly preventing re-fireing the submission loop
fixes the issue.
2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete ee93f0edee [KMS/DRM] Revert unaproved fix for bug #5465. 2021-01-24 00:51:24 -05:00
Ozkan Sezer 6393d14de5 SDL_virtualjoystick.c: remove wrong #endif comment. 2021-01-24 00:51:24 -05:00
Ozkan Sezer 327ea97436 hidapi/libusb/hid.c: whitespace tidy-up. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete e1d932f8b6 [KMS/DRM] Fix for bug #5468: corruption on dynamic cursor changing caused by wrong buffer size. 2021-01-24 00:51:24 -05:00
Manuel Alfayate Corchete 99facb1df3 [KMS/DRM] Fix for bug #5470: ratio correction for fullscreen windows with no matching resolution. Correct bracket position in else statements so they follow the coding style. 2021-01-24 00:51:24 -05:00
Sam Lantinga c265e73f3b Fixed bug 5473 - Add WSCONS support for NetBSD
wahil1976

This patch adds WSCONS support for NetBSD.
2021-01-24 00:51:24 -05:00
Ozkan Sezer f3835702d3 fix build with --disable-directx 2021-01-24 00:51:24 -05:00
Sam Lantinga 2ea393bd83 Fixed the screenshot button mapping on third party Bluetooth Nintendo Switch Pro controllers 2021-01-24 00:51:23 -05:00
Manuel Alfayate Corchete 03665004d0 [KMS/DRM] Small fix to KMSDRM_Waitpageflip(). More comments on how it works. 2021-01-24 00:51:23 -05:00
Ozkan Sezer bdb3e6b84f SDL_hidapi_switch.c: fix build with older compilers 2021-01-15 12:40:00 +03:00
Sam Lantinga e3dbae5010 Get the serial number for the Nintendo Switch Pro controller 2021-01-14 23:49:41 -08:00
Sam Lantinga 5fc743c4fd Phantom Nintendo Switch Pro Controller initialization problem 2021-01-14 23:49:37 -08:00
Sam Lantinga 92742306a6 Fixed rumble reset failing for Switch Pro controllers in USB mode 2021-01-14 23:49:33 -08:00
Sam Lantinga d0b87fede6 Added HIDAPI rumble debug info 2021-01-14 23:49:27 -08:00
Sam Lantinga e2f46ed8ef Always lock the HIDAPI device when closing, in case rumble is pending 2021-01-14 23:49:20 -08:00
Sam Lantinga 907b8eebc3 Make sure the HIDAPI device is locked when closing it, in case there is rumble pending that didn't complete 2021-01-14 23:49:16 -08:00
Sam Lantinga b3848c5120 Fixed bug 5445 - Incorrect Switch Pro Controller face buttons when SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS disabled
jibb

I'm testing with DualShock 4, DualSense, Switch Pro Controller, and PowerA Switch Controller.

I'm using the standard mapping file from here:
https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt

With SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS turned off (set to "0") I expect the button positions to be the same on all devices, based on Xbox controller button naming (eg SDL_GameControllerGetButton(g, SDL_CONTROLLER_BUTTON_Y) gives me whether the North face button is pressed).

However, the Switch Pro Controller layout is wrong (matching labels rather than positions, so X and Y are swapped and A and B are swapped). And with the PowerA controller the East and West buttons are correct, but the North and South buttons are swapped instead.

Mathias Kaerlev

Also seeing this on 2.0.14. This is most likely a regression, since we weren't seeing this on an earlier SDL version.

I suspect it might be caused by this commit:
a569b21188 (diff-da9344d94c66b8c702a45e7649f412039f08bba83bd82de33f5c80ea9c8c39d5)

It seems like both the HIDAPI driver and SDL_gamecontroller.c will try to swap the buttons if the hint is set to 0, causing the button remap to cancel out.
2021-01-14 15:15:57 -08:00
Sam Lantinga bdc6e4ffc5 Fixed bug 5195 - Replugging in "mixed" controller types crashes on macOS
RustyM

This is related to Bug 5034, but crashes under a somewhat different condition.

In the latest tip (changeset 13914) or with the SDL 2.0.12 source + David?s 5034 patch, unplugging and then replugging in certain controller types on macOS will crash. A mix of new controllers like Switch Pro, PS4 and Xbox One all work without issue. But if a controller without a rumble function, like many SNES retro USB gamepads, is mixed with a PS4 or Switch Pro controller it will crash.

File: joystick/darwin/SDL_sysjoystick.c
Function: static recDevice *FreeDevice(recDevice *removeDevice)
On line 159: while (device->pNext != removeDevice) {
Causes: Thread 1: EXC_BAD_ACCESS (code=1, address=0x188)

This can be reproduced in testgamecontroller" by starting the test program with both a ?retro? controller plugged in and a ?modern rumble? controller (Switch Pro/PS4). This may crash on launch, but it depends on which controller ends up as device 0. If it doesn?t crash, unplug the ?modern rumble? controller and plug it back in.

Some of the "retro" controllers I?ve seen this crash with:
- iBuffalo SNES Controller
- 8Bitdo SN30 Gamepad (in MacOS mode)
- Retrolink NES Controller
- HuiJia SNES Controller Adaptor

The issue appears macOS specific. Seen on 10.12.6 and 10.14.6. Not seen on Windows 10.

The while loop in FreeDevice() assumes that every device is not NULL.

    recDevice *device = gpDeviceList;
    while (device->pNext != removeDevice) {
        device = device->pNext;
    }
    device->pNext = pDeviceNext;

So maybe we should check for NULL here? Or instead prevent adding NULL devices to the list in the first place? Checking device for NULL before entering the loop appears to work.

    recDevice *device = gpDeviceList;
    if (!device) {
        while (device->pNext != removeDevice) {
            device = device->pNext;
        }
    }
    device->pNext = pDeviceNext;
2021-01-14 15:03:11 -08:00
Sam Lantinga 6a342954e8 Fixed bug 5451 - Can't create EGLSurface in Wayland from SDLWindow (no EGLNativeWindow pointer)
sashikknox

In some cases, need create EGLWindow with SDLWindow. In X11 i can get pointer to NativeWindow from **struct SDL_SysWMinfo wmInfo**
```C++
struct SDL_SysWMinfo wmInfo;
SDL_GetWindowWMInfo(ptSDLWindow, &wmInfo)
#if defined(__unix__) && defined(SDL_VIDEO_DRIVER_X11)
nativeWindow=(EGLNativeWindowType)wmInfo.info.x11.window;
nativeDisplay=(EGLNativeDisplayType)wmInfo.info.x11.display;
#endif
```
than i can create EGLSurface
```
eglCreateWindowSurface(nativeDisplay, EGL_CONFIG, nativeWindow, SURFACE_ATTRIBUTES);
```
in Wayland i can do it with same way, just need pointer to **EGLWindow**, we already have pointer to **wl_display** from **SDL_sysWMInfo**, need add to **wl** struct in SDL_SysWMInfo another pointer to **struct wl_egl_window *egl_window;**. And in wayland backend, in function **Wayland_GetWindowWMInfo** return pointer to **egl_window** from **SDL_WindowData**
Now i use patched statically built SDL2 in port of Quake 2 GLES2 for SailfishOS (it use QtWayland):
link to SDL2 commit and changed string for patch:
- 6858a618cd
- b1e29e87b9/SDL2/src/video/wayland/SDL_waylandwindow.c (L463)

link to use in Quake2 port:
1. here i get pointer to EGLNativeWindowType:  6d94fedb1b/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c (L319)
2. then use it for create EGLSurface: 6d94fedb1b/Engine/Sources/Compatibility/OpenGLES/EGLWrapper.c (L391)
2021-01-14 14:42:53 -08:00
Sam Lantinga 82aafa9aa8 Fixed bug 5461 - Add rewritten WSCONS driver for OpenBSD
wahil1976

This patch adds a written-from-scratch WSCONS driver for OpenBSD. It does not have hardcoded keymaps, and it features mouse support when wsmux is available.

For this to work, it needs access to the /dev/wskbd* devices which are not available to non-root users by default. Access to those can be granted by changing /etc/fbtab to give the logging user the ownership of those devices.
2021-01-14 14:32:11 -08:00
Manuel Alfayate Corchete 1adadc7702 [KMS/DRM] Adjust come return values. Improve comments. 2021-01-14 10:18:40 +01:00
Manuel Alfayate Corchete 57661e42c3 [KMS/DRM] Remove unused header. 2021-01-13 20:17:50 +01:00
Manuel Alfayate Corchete ead3c406a2 [KMS/DRM] Refactor, improve and re-comment async pageflips code. 2021-01-13 20:11:01 +01:00
Sam Lantinga fbd7c718b6 Don't blink the Xbox 360 LED when setting the player slot, it's probably already been set by a driver 2021-01-13 11:02:07 -08:00
Sam Lantinga d757ec7f5c Only select the gamepad interfaces on the Xbox 360 wireless adapter 2021-01-13 11:02:01 -08:00
Manuel Alfayate Corchete aac74db685 [KMS/DRM] Enable async pageflips. 2021-01-13 15:54:26 +01:00
Manuel Alfayate Corchete 9384e59561 [KMS/DRM] Add warning comentary to avoid future experiments with scaling. 2021-01-12 20:15:37 +01:00
Ryan C. Gordon b99543b682 opengl: More work on making line drawing match software renderer. 2021-01-11 20:40:11 -05:00
Manuel Alfayate Corchete 8442754912 [KMS/DRM] Refactor KMSDR_CreateSurface to group all non-Vulkan stuff in a block. 2021-01-12 00:22:58 +01:00
Manuel Alfayate Corchete 87eb734c4e [KMS/DRM] Don't ask SDL to scale image when in Vulkan mode. 2021-01-11 23:59:40 +01:00
JibbSmart e9887045a2 Gyro and Accel sensor support for Switch Pro Controller.
Note that axes are changed to match the axes we're using with PlayStation controllers, since users will appreciate consistent behaviour across devices.
2021-01-11 15:36:40 +08:00
Manuel Alfayate Corchete 85e8adf78d [KMS/DRM] Unused code cleaning. 2021-01-11 22:28:27 +01:00
Manuel Alfayate Corchete 5105ecf8b1 [KMS/DRM] Move surface size info to window driverdata, for coherency. 2021-01-11 21:02:07 +01:00
Manuel Alfayate Corchete 2067a7db8e [KMS/DRM] Fix fullscreen to windowed transition. Fix aspect ratio correction without using planes. 2021-01-11 20:29:09 +01:00
Sylvain Becker 958e5d5b34 SDL_UpdateNVTexture: fixed pitch/bpp for GLES2 (bug #5430) 2021-01-11 10:01:24 +01:00
Sylvain Becker 68815b6c06 Fixed bug 5465 - Invalid memcpy inside SDL_GestureDelTouch (Thanks dmikushin and Yuki Okumura) 2021-01-10 22:21:12 +01:00
Sylvain Becker b94718e0a7 SDL_UpdateNVTexture: for D3D11, same notation as SDL_UpdateTexture (bug #5430) 2021-01-09 21:22:21 +01:00
Manuel Alfayate Corchete 850d9c8c0d [KMS/DRM] Cleanup remainings from plane/scaling usage. 2021-01-09 02:25:13 +01:00
Manuel Alfayate Corchete 2aeb317743 [KMS/DRM] Fix vkQuake3 in OpenGL mode. 2021-01-08 22:00:28 +01:00
Sam Lantinga 8746788fea KMSDRM_LEGACY is no longer legacy 2021-01-08 11:08:23 -08:00
Sam Lantinga 50ea3b77f1 Fixed bug 5080 - SDL_netbsdaudio: Always use the device's preferred frequency
Nia Alarie

The NetBSD kernel's audio resampling code is much simpler and lower quality than libsamplerate.

Presumably, if SDL always performs I/O on the audio device in its native frequency, we can avoid resampling audio in the kernel and let SDL do it with libsamplerate instead.
2021-01-08 10:09:37 -08:00
Sam Lantinga 2f72535c62 Fixed joysticks generating SDL mouse events 2021-01-08 09:54:55 -08:00
Sam Lantinga a5dba7d3ab Fixed Xbox One Series X share button incorrectly triggering on newer firmware 2021-01-08 09:54:52 -08:00
Manuel Alfayate Corchete b24494734b [KMS/DRM] Go back to the LEGACY interface only because using planes breaks compatibility with HW, so no advantage on using ATOMIC. 2021-01-08 18:57:12 +01:00
Manuel Alfayate Corchete 940e1b8dd9 [KMS/DRM] Small readability changes. 2021-01-08 16:33:50 +01:00
Manuel Alfayate Corchete e5bf1850f5 [KMS/DRM] Fix cpmpilation warnings. Thanks to Ozkan Sezer for pointing this out! 2021-01-08 15:39:05 +01:00
Manuel Alfayate Corchete cef1bd0639 [KMS/DRM] Prevent creating another default cursor everytime a window is created. Other fixes and cleanups. 2021-01-08 13:14:42 +01:00
Sam Lantinga e778881ada Fixed bug 5449 - SDL_DROPFILE update mouse location of drop in Cocoa
Dominik Reichardt

Exult (http://exult.info) has an editor app that uses GTK+2. Up to now we were using X's drag'n'drop to allow dropping of assets from the editor onto Exult.
There is now an experimental branch that makes use of SDL_DROPFILE. That works under X, dropping in Exult's SDL2 window puts the asset right at the spot you dropped at.
On macOS with native Exult and Quartz GTK+2 this doesn't work, the location of the drop is where the mouse was last tracked before you left the window (usually one of the edges, unless you tabbed out).
All we tried out pointed to the fact that the location update needs to be done by the dropfile event in SDL2, not by our own (which always only worked after the Exult window getting focus).

This patch adds this to SDL_cocoawindow.m and it works perfectly, passing the correct coordinates to our code (SDL_GetMouseState()).
2021-01-07 11:49:28 -08:00
Sam Lantinga c8a64ad90c Fixed building when SDL_LIBUSB_DYNAMIC is defined 2021-01-07 10:23:55 -08:00
Manuel Alfayate Corchete d079130c24 [KMS/DRM] Don't use primary plane for scaling because that's unsupported on most LEGACY-only HW. 2021-01-07 18:44:34 +01:00
Manuel Alfayate Corchete e168d1138c [KMS/DRM] Correct drmModeSetCursor() dimensions. 2021-01-07 14:40:24 +01:00
Manuel Alfayate Corchete 335d78ff86 [KMS/DRM] Add the missing files for Vulkan support to the KMSDRM_LEGACY backend, had forgotted to do -hg add-. 2021-01-07 11:30:33 +01:00
Manuel Alfayate Corchete 661bacfe27 [KMS/DRM] Add Vulkan suport to the KMSDRM_LEGACY backend.Minor text spacing tweaks for better readability. Comment out unused function. 2021-01-07 00:47:21 +01:00
Ozkan Sezer dfb0afe36a fix build after commit 5730b2005da1 2021-01-07 00:41:32 +03:00
Manuel Alfayate Corchete 67e0b1dd4e [KMS/DRM] Rewrite KMSDRM_LEGACY backend to accomodate Vulkan compatibility. Fix several bugs on that backend. 2021-01-06 22:15:26 +01:00
Sylvain Becker 57a5c45372 Fix D3D11 UpdateTextureNV in non fullscreen (bug #5430) 2021-01-05 22:06:51 +01:00
Sylvain Becker fc61ecb25c Fix software UpdateNVTexture non fullscreen (bug #5430) 2021-01-05 21:54:03 +01:00
Sylvain Becker 204ef3b509 Fix D3D11 UpdateNVTexture (bug #5430) 2021-01-05 20:38:31 +01:00
Sylvain Becker c0df40e003 Add more SDL_HAVE_YUV defines 2021-01-05 17:39:48 +01:00
Ozkan Sezer 76295cecf3 video/windows: ANSI/UNICODE updates (cf. bug 5435):
- explicitly use UNICODE versions of DrawText, EnumDisplaySettings,
  EnumDisplayDevices, and CreateDC: the underlying structures have
  WCHAR strings.
- change WIN_UpdateDisplayMode and WIN_GetDisplayMode() to accept
  LPCWSTR instead of LPCTSTR for the same reason.
- change WIN_StringToUTF8 and WIN_UTF8ToString to the explicit 'W'
  versions where appropriate.
2021-01-05 15:50:10 +03:00
Ozkan Sezer 265a1cc97a use WIN_StringToUTF8W instead of WIN_StringToUTF8 where needed (#2)
cf. bug #5435.
- SDL_wasapi_win32.c (GetWasapiDeviceName): pwszVal is WCHAR*
- windows/SDL_sysfilesystem.c (SDL_GetBasePath, SDL_GetPrefPath)
- windows/SDL_sysurl.c (SDL_SYS_OpenURL): wurl is WCHAR*
- SDL_windowssensor.c (ConnectSensor): bstr_name is WCHAR*
- windows/SDL_systhread.c (SDL_SYS_SetupThread): strw is WCHAR*
2021-01-05 15:50:02 +03:00
Ozkan Sezer 516042b4d6 ran gendynapi.pl after SDL_UpdateNVTexture addition 2021-01-05 15:15:50 +03:00
Ozkan Sezer 31751bdcce wmmsg.h: constified wmtab 2021-01-05 15:15:37 +03:00
Sylvain Becker b032504162 Fix unused variable warning on METAL (see bug #5430) 2021-01-05 12:36:34 +01:00
Sylvain Becker c1eb9ecf99 Add SDL_UpdateNVTexture for META (bug #5430)
(not tested)
2021-01-05 12:29:43 +01:00
Sylvain Becker 73d93dbc38 Fix compilation on Window10 (see bug #5430) 2021-01-05 12:20:02 +01:00
Sylvain Becker df6b813108 Fix compilation (implicit declaration of function) (see bug #5430) 2021-01-05 12:16:32 +01:00
Sylvain Becker d1f031c8ee Add SDL_UpdateNVTexture for d3d11 (bug #5430)
(not tested)
2021-01-05 12:08:16 +01:00
Sylvain Becker f5eba2ccd6 Fixed invalid read in yuv_rgb_sse() (see bug #5430) 2021-01-05 12:00:54 +01:00
Sylvain Becker be4cfd51c3 Add SDL_UpdateNVTexture() to update NV12/21 Texture (bug #5430)
for renderer software, opengl, and opengles2
2021-01-05 11:56:22 +01:00
Sam Lantinga d72dbd9883 Fixed detection of the Wooting Two keyboard, which shows up as an Xbox 360 controller 2021-01-04 17:30:28 -08:00
Sam Lantinga b2a0c712cb Allow setting the player index to -1, which turns off the player LED for PS5 controllers 2021-01-04 12:24:44 -08:00
Sam Lantinga bf754b52bf Valve contributed code is under the Zlib license 2021-01-04 12:17:24 -08:00
Ozkan Sezer 8cb421b26d SDL_windows_main.c: use new WIN_StringToUTF8W macro 2021-01-04 10:20:10 +03:00
Ozkan Sezer a594b85031 use WIN_StringToUTF8W macro instead of WIN_StringToUTF8, where needed:
i.e. where the string is known guaranteed to be WCHAR*, in:
- SDL_dinputjoystick.c (WIN_IsXInputDevice): VARIANT->var is BSTR (WCHAR*)
- SDL_rawinputjoystick.c (RAWINPUT_AddDevice): string is WCHAR*
- SDL_windows_gaming_input.c (IEventHandler_CRawGameControllerVtbl_InvokeAdded):
  string is WCHAR*

There should be more of these..
2021-01-04 10:00:30 +03:00
Ozkan Sezer 5b14bbff5f make ANSI/UNICODE versions of WIN??UTF8 macros individually available. 2021-01-04 10:00:10 +03:00
Ozkan Sezer f2bd861cd7 move SDL_tcsstr definition to core/windows/SDL_windows.h 2021-01-04 08:50:00 +03:00
Ozkan Sezer ae18109a92 SDL_windowsjoystick.c (SDL_CreateDeviceNotification): use L, not TEXT()
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer 390fd14f54 SDL_windowswindow.c (SDL_HelperWindowCreate): adjust for ANSI/UNICODE:
change SDL_HelperWindowClassName and SDL_HelperWindowName from WCHAR *
to be const TCHAR*

cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer 398d2764c7 RAWINPUT_InitWindowsGamingInput: change pNamespace from LPTSTR to PCWSTR
because WindowsCreateStringReference specifically accepts const WCHAR *
- WGI_JoystickInit(): ditto.

cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer f09e0af7aa SDL_dinputjoystick.c (IsXInputDevice): adjust to be ANSI/UNICODE-agnostic
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer ed39f2f3f9 SDL_wasapi_win32.c (WASAPI_PlatformThreadInit): use L instead of TEXT()
because AvSetMmThreadCharacteristicsW specifically accepts WCHAR* input
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Ozkan Sezer 01a2f27679 consistently use TEXT() macro with LoadLibrary() and GetModuleHandle()
cf. bug #5435.
2021-01-04 01:23:50 +03:00
Cameron Gutman 014f507c40 Use specific acquire and release variants of InterlockedExchange on ARM
_InterlockedExchange_rel() is required for correctness on ARM because
the _ReadWriteBarrier() macro is only a compiler memory barrier, not a
hardware memory barrier. Due to ARM's relaxed memory model, this means
the '*lock = 0' write may be observed before the operations inside the
lock, causing possible corruption of data protected by the lock.

_InterlockedExchange_acq() is more efficient on ARM because it avoids an
expensive full memory barrier that _InterlockedExchange() does.
2021-01-03 12:13:40 -06:00
Sam Lantinga 393c8c1f16 Fixed bug 5440 - MacCatalyst build failures
C.W. Betts

I tested building commit http://hg.libsdl.org/SDL/rev/7adf3fdc19f3 on Mac Catalyst and found some issues:

* MTLFeatureSet_iOS_* enums aren't available under Mac Catalyst.
* OpenGL ES is unavailable under Mac Catalyst.
* Some Metal features are available under Catalyst but not iOS, such as displaySyncEnabled.
* Set Metal as the default renderer on Mac Catalyst

Attaching a patch that will make SDL2 build for Mac Catalyst.
2021-01-03 10:32:55 -08:00
Cameron Gutman 6cbd4417f0 Add a hint for D3D9Ex to avoid having to choose at compile-time 2021-01-02 14:45:15 -06:00
Cameron Gutman 59594a7891 Implement PAUSE_INSTRUCTION() for Windows ARM platforms 2021-01-02 13:43:04 -06:00
Sylvain Becker fea49a3e2f SDL_stretch.c: compilation NEON on Windows 10 2021-01-03 15:24:47 +01:00
Sylvain Becker acccc71f27 Fixed bug 5436 - MSVC 2019 ARM64 build fails to compile SDL_stretch.c 2021-01-02 22:31:44 +01:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Cameron Gutman 414ddc32c5 Do not wait in GetOverlappedResult() in hid_read_timeout()
This is unsafe because the event is auto-reset, therefore the call to
WaitForSingleObject() resets the event which GetOverlappedResult() will
try to wait on.

Even though the overlapped operation is guaranteed to be completed at
the point we call GetOverlappedResult(), it will still wait on the event
handle for a short time to trigger the reset for auto-reset events. This
amounts to roughly a 100 ms sleep each time GetOverlappedResult() is called
for a completed I/O with a non-signalled event.

In the context of HIDAPI, this extra sleep means that callers that loop
on hid_read_timeout() with timeout=0 will loop forever, since the 100 ms
sleep each iteration ensures ReadFile() will always have new data.
2021-01-01 17:34:07 -06:00
Sam Lantinga 963c9495d3 Fixed bug 5431 - SDL_Metal_GetDrawableSize is inaccurate for high dpi displays if a Metal view has not already been created
Caleb Cornett

For a window created with SDL_WINDOW_ALLOW_HIGHDPI, SDL_GL_GetDrawableSize will return the high-dpi drawable size even before any GL context creation happens. But SDL_Metal_GetDrawableSize will return the size of the window if the Metal view has not been created. This is confusing and inconsistent behavior.

An easy way to test this is to build testgl2 and testvulkan on macOS with the SDL_WINDOW_ALLOW_HIGHDPI flag enabled during window creation. The GL2 program will report a drawable size of 2x window width and 2x window height, while the Vulkan program will report the window size.

This patch addresses the issue by falling back to using the content view dimensions if no Metal view exists in the window. (The code for this was taken directly from Cocoa_GL_GetDrawableSize.) With this change, the testvulkan behavior matches that of testgl2.

Note that I haven't tested for this issue on UIKit. It's possible a similar change will need to be made there too.
2021-01-02 10:11:08 -08:00
Sam Lantinga d25eff6505 Fixed bug 5429 - spinlock implements PAUSE_INSTRUCTION for PPC platforms
David Carlier

This form of 'or' provides a hint that performance
will probably be improved if shared resources dedicated
to the executing processor are released for use by other
processors
2021-01-02 10:06:22 -08:00
Sam Lantinga f0b6c78733 Fixed Windows XP compatibility with recent hidapi commit 2021-01-02 09:58:08 -08:00
Sylvain Becker 3edf337d66 Simplify RenderGetViewportSize 2021-01-02 17:29:34 +01:00
Sylvain Becker 2af765da11 SDL_RenderGetViewportF: only need the size of viewport (see bug #5424) 2021-01-02 17:18:13 +01:00
Sylvain Becker 41597249e8 SDL_RenderGetViewportF: remove debug messages 2021-01-02 16:15:22 +01:00
Sylvain Becker 8c48c4238a Add SDL_RenderGetViewportF: fix lost of precision while scaling (see bug #5424) 2021-01-02 16:12:30 +01:00
Sylvain Becker c005267fb1 SDL_BlitScaled: better and safer fix clipping bug #2687
And re-use SDL_round(), since it's been re-added
(remove in https://hg.libsdl.org/SDL/rev/34043108b7e4 )
2021-01-02 09:38:19 +01:00
Sylvain Becker 2127ed2574 SDL_SoftStretch: add a check for input pixel format
and function re-naming
2021-01-02 09:28:16 +01:00
Sam Lantinga ab55ec4850 Fix use-after-free SBH corruption due to overlapped ReadFile in hidapi not being canceled for all threads before device close
- hidapi already called CancelIo on hid_close but that only cancels pending IO for the current thread. Controller read/writes originate from multiple
  threads (serialized, but on a different thread nonetheless) but device destruction was always done on the main device thread which left any
  pending overlapped reads still running after hidapi's internal read buffer is deallocated leading to intermittent free list corruption.
2021-01-01 11:12:41 -08:00
Sam Lantinga 480c1f9fef Make sure we're not starving report reads when there's lots of rumble 2021-01-01 11:12:36 -08:00
Sam Lantinga 223af86c62 Added SDL_RenderGetD3D11Device() to get access to the device associated with the D3D11 renderer 2021-01-01 11:12:30 -08:00
Sam Lantinga 5f0b2a7f54 Fixed resource leak with D3D11 NV12 textures 2021-01-01 11:12:22 -08:00
Manuel Alfayate Corchete 21003b7db2 [KMS/DRM] Small refactoring on the SwapWindow function. 2020-12-31 14:31:29 +01:00
Manuel Alfayate Corchete e1fb969b76 [KMS/DRM] Correct comments about last bugfix. 2020-12-31 01:40:15 +01:00
Manuel Alfayate Corchete e34caa9779 [KMS/DRM] Correct EGL/GL library loading on window creation, thus saving window re-creation. 2020-12-31 01:31:57 +01:00
Sylvain Becker d81fe9239f SDL_BlitScaled: remove un needed -1 +1 offset in calculation 2020-12-30 22:03:32 +01:00
Ozkan Sezer 8476df3e31 SDL_mixer.c: remove calls to non-existing m68k asm code. 2020-12-30 23:55:10 +03:00
Sylvain Becker 590a5469ed Fixed bug 5424 - Renderer doesn't use entirely the viewport when scaling is used
Viewport/Clip dimensions are calculated usingg SDL_ceil whereas all renders use SDL_floor
2020-12-30 16:12:14 +01:00
Ozkan Sezer 8a32ee24db removed MSVC strtok_s use from SDL_strtokr().
no other ??_s are used elsewhere in SDL_stdinc. besides, C11 has a
strtok_s with a different signature.
2020-12-30 01:00:24 +03:00
Sam Lantinga 0684572ccc Added a hint to control whether the player LEDs should be lit to indicate which player is associated with a PS5 controller. 2020-12-29 12:13:10 -08:00
Sylvain Becker 80cf8a8b76 SDL_BlitScaled: also prevent crash if dest width or height is negative 2020-12-29 17:29:31 +01:00
Sylvain Becker f08b9a5b6b SDL_BlitScaled: prevent crash if dest width or height is 0 2020-12-29 16:02:52 +01:00
Manuel Alfayate Corchete 427c96ec11 [KMS/DRM] Rework some functions. 2020-12-29 14:24:38 +01:00
Sam Lantinga 67f0b9b86d Fixed bug 5418 - Add system features detection for Elbrus (E2K)
Ivan Kuzmenko

MCST Elbrus 2000 (E2K, https://en.wikipedia.org/wiki/Elbrus_2000) is a russian processor architecture based on VLIW/EPIC instruction set (like Intel Itanium (IA-64) architecture). Architecture has half native / half software support of most Intel/AMD SIMD (e.g. MMX/SSE/SSE2/SSE3/SSSE3/SSE4.1/SSE4.2/AES/AVX/AVX2 & 3DNow!/SSE4a/XOP/FMA4).
It also has built-in x86/x86_64 <-> e2k binary translators  (RTC, http://www.mcst.ru/rtc and Lintel, http://www.mcst.ru/lintel) that can run code for x86/x86_64 architecture (Transmeta did something similiar with their Crusoe series) with SIMD extensions support.
Attached patch allows SDL2 to detect extensions supported by E2K like MMX, 3dNOW!, AVX etc. (test/testplatform log: https://termbin.com/7qs3).
2020-12-28 20:58:47 -08:00
Sam Lantinga 3cb0e840e6 Fixed bug 5422 - KMSDRM_LEGACY: Add OpenBSD support
wahil1976

This patch adds support for OpenBSD to KMSDRM_LEGACY. Note that the patch won't be ported to the atomic KMSDRM backend because OpenBSD does not support atomic KMS properly yet.
2020-12-28 11:47:53 -08:00
Joel Linn 8fc0baad98 Add SDL_cond implementation using Windows Condition Variables
Is automatically used when the SRW SDL_mutex implementation is active.
Otherwise falls back to the generic implementation.

v2: - Rebase onto master fa3ea1051a4b
2020-12-28 11:43:11 -08:00
Joel Linn 2443e51e0e Add optional suffix `_generic` to generic SDL_cond impl
Allows for runtime selectable implementation
2020-12-28 11:42:49 -08:00
Manuel Alfayate Corchete 7539ac8087 [KMS/DRM] Restore hacky code to point to TTY buffer on surface destruction b/c I lack alternatives. 2020-12-28 18:22:07 +01:00
Sylvain Becker 5dabc4d72f Revert changeset 14590 544ac819e8b3 , does not fully fix 2020-12-28 18:17:25 +01:00
Sylvain Becker 9efdafd43d SDL_RenderCopy: scale before doing intersection
this prevents drawing 1 pixel outside the screen, in letterbox mode
2020-12-28 18:07:03 +01:00
Manuel Alfayate Corchete 86b81abea6 [KMS/DRM_LEGACY] Prevent mouse cursor from staying onscreen after window destruction. Patch by Ozkan Sezer. 2020-12-28 16:19:19 +01:00
Manuel Alfayate Corchete 0feaf7d196 [KMS/DRM][Vulkan] Correct non-existing property. Remove hacky surface destruction code (TTY buffer isn't there after a Vulkan window is created). 2020-12-28 14:37:58 +01:00
Sylvain Becker 7186584b8d fix indentation (bug 5313) 2020-12-28 10:41:37 +01:00
Sylvain Becker c2735c0bb9 Better scaling fallbacks for the SW renderer (bug 5313) 2020-12-27 23:53:28 +01:00
Ozkan Sezer a6beb2d264 SDL_PrivateLowerBlitScaled: remove unused local var 'a' 2020-12-28 01:10:02 +03:00
Sylvain Becker 30df2e4e36 Scaling fallbacks for the SW renderer (bug 5313) 2020-12-27 23:00:11 +01:00
Luca Weiss 040bd7a91b Fix udev not detecting ID_INPUT_KEY devices when udev is not running
https://bugzilla.libsdl.org/show_bug.cgi?id=5308

The udev code labels devices that are found by this code with
ID_INPUT_KEY which in turn gets used by SDL to label the devices as
SDL_UDEV_DEVICE_KEYBOARD.

This was missing for the code path when udev is not running and as such
devices such as the power button of a phone was not detected as keyboard
input and no devices were emitted.
2020-12-28 00:55:28 +03:00
Sylvain Becker f9b5f6cc0f Forward scale mode to SW renderer (Bug 5313) 2020-12-27 20:28:24 +01:00
Manuel Alfayate Corchete 46d31d570d [KMS/DRM][Vulkan] Fix segfault when changing fullscren mode and permanent cursor when changing between Vulkan and GL renderers in vkQuake3. Tidy up window destruction code. 2020-12-27 00:43:06 +01:00
Joel Linn e7c479414b Disable WaitOnAddress SDL_sem implementation on Windows Phone
Apps that use the required APIs do not pass certification.
2020-12-25 17:10:02 +03:00
Joel Linn d6afc1c608 thread/windows: Statically link synchronization APIs on WINRT
GetModuleHandleW is not available on those platforms
---
 .../WinPhone81_VS2013/SDL-WinPhone81.vcxproj         |  8 ++++----
 VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj     | 12 ++++++------
 src/thread/windows/SDL_sysmutex.c                    | 12 ++++++++++++
 src/thread/windows/SDL_syssem.c                      | 11 +++++++++++
 4 files changed, 33 insertions(+), 10 deletions(-)
2020-12-25 04:00:20 +03:00
Sam Lantinga ff913a22f4 Fixed compile warnings on platforms without hidapi support 2020-12-23 16:16:55 -08:00
Sam Lantinga 047b20e3b6 Fixed compile warnings on platforms without hidapi support 2020-12-23 16:11:16 -08:00
Sam Lantinga 9838611a8b Fixed compiler crash building for iOS with clang 11.0.3 2020-12-23 15:52:12 -08:00
Sylvain Becker 4aebad77bd SDL_SoftStretchLowerLinear: try to make xcode buildbot compile (Bug 5313) 2020-12-23 22:50:50 +01:00
Sam Lantinga 93ccdee8c1 Fixed bug 5404 - stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf
Cameron Cawley

stdlib: Added SDL_round, SDL_roundf, SDL_lround and SDL_lroundf

The default implementation is based on the one used in the Windows RT video driver.
2020-12-23 13:47:49 -08:00
Joel Linn d0b8295c0d Add SDL_sem implementation using Atomics and WaitOnAddress API.
Keep Semaphore Kernel Object impl for Windows 7 and older - choose at runtime

v2: - Fix mixed int/LONG types
    - Reorder definitions
    - Add missing include

v3: - Use `GetModuleHandle()` to load the API Set
2020-12-23 13:36:46 -08:00
Joel Linn 548cb90893 Add SDL_mutex implementation using Windows Slim Reader/Writer Locks Keep Critical Section impl for Windows XP/Vista - choose at runtime
v2: - Add SRW definitions as suggested by Ozkan Sezer
      Allows building against older platform headers.
    - Rename "hidden" function parameter `mutex_` to `_mutex`

v3: - Use GetModuleHandle instead of LoadLibrary
    - Fix typo in comment
2020-12-23 13:33:36 -08:00
Sylvain Becker 8e20376f1a SDL_SoftStretchLinear: use SDL_INLINE (bug 5313) 2020-12-23 22:09:01 +01:00
Sylvain Becker 7b8d5b7dc3 SDL_SoftStretchLinear: fix implicit conversion (bug 5313) 2020-12-23 22:02:28 +01:00
Ozkan Sezer 15fea33915 ran gendynapi.pl after addition of SDL_SoftStretchLinear 2020-12-23 23:47:10 +03:00
Sylvain Becker ae8a270f61 Add SDL_SoftStretchLowerLinear() (Bug 5313) 2020-12-23 21:37:40 +01:00
Sylvain Becker 050ee9a410 Split SDL_SoftStretch in Lower and Uppler functions (Bug 5313) 2020-12-23 21:32:01 +01:00
Manuel Alfayate Corchete 09fcc9ed17 [KMS/DRM][Vulkan] Fix small warning, thanks to Ozkan Sezer for spotting it. 2020-12-23 16:45:23 +01:00
Manuel Alfayate Corchete a6dc838d52 [KMS/DRM][Vulkan] Only try to create a display mode when no suitable mode is found. 2020-12-23 16:22:46 +01:00
Sam Lantinga 0ed4d92938 Fixed setting player LEDs for PS5 controllers over Bluetooth 2020-12-23 04:53:23 -08:00
Sam Lantinga 6341bb35a5 Fixed controller disconnect detection for PS4 and PS5 controllers over Bluetooth 2020-12-22 21:51:59 -08:00
Sam Lantinga a30adae567 Make it possible to turn on PS4 rumble effects at runtime using the hint 2020-12-22 20:58:32 -08:00
Sam Lantinga c93947a2cb Make it possible to turn on PS5 rumble effects at runtime using the hint 2020-12-22 20:12:03 -08:00
Sam Lantinga 058a0ab47f Set the pad lights on the PS5 controller corresponding to the player index
Also allow setting the player index from testgamecontroller using the number keys
2020-12-22 14:38:32 -08:00
Sam Lantinga 6a57072eef Only add the touchpad and sensors to the PS5 controller if effects are enabled 2020-12-22 14:10:08 -08:00
Sam Lantinga 4ec776c334 Don't switch the PS5 controller out of DirectInput mode by default 2020-12-22 13:29:23 -08:00
Sam Lantinga 350f1b0d16 Updated SDL to version 2.0.15 for development 2020-12-22 10:36:15 -08:00
Ozkan Sezer a19c008a7f use GetModuleHandleW() to retrieve kernel32.dll handle (bug #5390.)
SDL_systhread.c and SDL_syslocale.c used to call LoadLibrary() without
calling FreeLibrary() later.  GetModuleHandleW() should always succeed
because GetModuleHandleW() itself is imported from kernel32.dll and we
don't need to bother releasing it.
2020-12-22 17:10:02 +03:00
Manuel Alfayate Corchete 2fc987c28f [Buildsystem] Add guards for not building with KMSDRM support if EGL is not available. 2020-12-22 14:15:33 +01:00
Sam Lantinga 4cd981609b Fixed whitespace 2020-12-21 09:44:25 -08:00
Manuel Alfayate Corchete 8766d6040b [Video/KMSDRM] Fix potetial access to freed structure and complete errorchecks. 2020-12-21 17:29:24 +01:00
Manuel Alfayate Corchete b06ef3a18c [Video/KMSDRM] Manually re-show the cursor on window creation, if needed. 2020-12-21 01:53:11 +01:00
Ozkan Sezer 4198f0e52c fix uninitialized warnings in KMSDRM_CreateCursor() 2020-12-21 01:20:30 +03:00
Manuel Alfayate Corchete a8dbcab132 [Video/KMSDRM] Don't copy the cursor bitmap to the cursor GBM BO until we're showing it. 2020-12-20 21:48:05 +01:00
Sam Lantinga ee180efda7 Fixed bug 5406 - Upstreaming DragonFlyBSD changes from DeltaPorts (patch from David Carlier) 2020-12-20 12:08:49 -08:00
Manuel Alfayate Corchete 2756b0f337 [Video/KMSDRM] Init and deinit mouse stuff at the same time that GBM stuff. 2020-12-20 14:29:58 +01:00
Ozkan Sezer e91153f278 fix non-ARM h/w on FreeBSD builds (bug #5405, patch from David Carlier.) 2020-12-20 03:03:21 +03:00
Manuel Alfayate Corchete cf71e01734 [Video/KMSDRM] Remove auxiliary AMDGPU compatibility workarounds not needed anymore. 2020-12-19 23:32:09 +01:00
Manuel Alfayate Corchete af1f91cb36 [Video/KMSDRM] Correct typo. 2020-12-19 20:21:07 +01:00
Manuel Alfayate Corchete cf48955680 [Video/KMSDRM] Honor the device index in Vulkan. Add notes about the display index. 2020-12-19 20:15:50 +01:00
Manuel Alfayate Corchete ab3a390e26 [Video/KMSDRM] Better ATOMIC caps testing: patch by Oskan Sezer. 2020-12-19 17:35:04 +01:00
Manuel Alfayate Corchete 436499f3ec [Video/KMSDRM] Comment out some debug info, adjust comments for future work. 2020-12-19 02:08:59 +01:00
Ozkan Sezer 6b81cac420 remove duplicated SDL_SetError after calling check_atomic_modesetting() 2020-12-19 01:25:50 +03:00
Manuel Alfayate Corchete 8952a61324 [Video/KMSDRM] Re-arrange display members setup. 2020-12-18 23:17:42 +01:00
Manuel Alfayate Corchete f60f8d5d84 [Video/KMSDRM]: Add Vulkan support to the KMSDRM backend. 2020-12-18 22:53:51 +01:00
Sam Lantinga cbe13d232d Fixed controller hotplug detection when joystick thread is not enabled 2020-12-18 13:10:36 -08:00
Ozkan Sezer 6ac0b23d3a SDL_DirectFB_video.c: DSPF_ABGR requires directfb >= 1.5.0 -- add guard. 2020-12-18 21:37:20 +03:00
Sam Lantinga f0577bc9ea ControllerList: setup the ps5 default deadzone to match PS4 instead of defaulting to same a XboxOne/Switch 2020-12-18 10:09:06 -08:00
Sam Lantinga 5f7cd1fa88 Added hints to control whether SDL updates joystick and sensor state in the main event loop 2020-12-18 10:08:59 -08:00
Ozkan Sezer 6c4ab48471 SDL_kmsdrmvideo.c: check atomic modesetting in check_modesetting()
.. so that KMSDRM_CreateDevice() can fail and SDL_VideoInit() would
move on to next bootstrap member which is kmsdrm_legacy.  hopefully
fixes bug #5393.
2020-12-18 17:50:02 +03:00
Sam Lantinga 6bd4c717a1 Fixed bug 5402 - ARM support little update proposal
David Carlier

No fix but mostly an update for ARM architecture.
2020-12-17 21:41:23 -08:00
Ozkan Sezer 10625f9d89 SDL_windowsmessagebox.c: go back to hg rev 14458 state.
encountering a NULL caption in AddDialogString() is intended, i.e.
AddDialogStaticIcon() sends it as NULL on purpose.
2020-12-17 23:50:00 +03:00
Ozkan Sezer 4d6eb30523 SDL_windowsmessagebox.c (AddDialogControl): add back NULL caption check.
because AddDialogStaticIcon() sends a NULL caption -- fixes bug #5401.
2020-12-17 23:28:20 +03:00
Ozkan Sezer 90456670b5 more "'for' loop initial declarations are only allowed in C99 mode" fixes 2020-12-17 14:11:00 +03:00
Ozkan Sezer ed4fcb2cfc kmsdrm_legacy build fixes:
- add missing '_LEGACY' to symbol names
- perform missing 2.0.14 portage
- fix 'for' loop initial declarations are only allowed in C99 mode errors
2020-12-16 03:24:10 +03:00
Sam Lantinga f484abbdc8 Added Android mapping for the Xbox One Series X controller over Bluetooth 2020-12-15 14:57:51 -08:00
Sam Lantinga 14f977348d Fixed whitespace 2020-12-15 14:57:47 -08:00
Ozkan Sezer 9940e71088 Import two post-2.0.12 fixes to kmsdrm_legacy:
Fix build breakage without EGL:
https://hg.libsdl.org/SDL/rev/f2606fe53654e305ab9badb821d9d3afb7f92f49

Fix KMSDRM_CreateWindow segfault when starting L?VE2D engine (bug 5199)
https://hg.libsdl.org/SDL/rev/d2e69a78939463d9ff9448a5f4efd1e208bb97b0
2020-12-16 00:10:30 +03:00
Sam Lantinga f8839289b0 Potential fix for bug 5393 - KMSDRM: using atomic mode setting breaks GPU compatibility
Substring

I was trying the KMSDRM video backend with some very simple programs that were working ok on 2.0.12. The same code won?t work on the current dev branch and I get:

DEBUG: check_modesetting: probing ?/dev/dri/card0?
DEBUG: /dev/dri/card0 connector, encoder and CRTC counts are: 4 5 6
DEBUG: check_modesetting: probing ?/dev/dri/card0?
DEBUG: /dev/dri/card0 connector, encoder and CRTC counts are: 4 5 6
DEBUG: KMSDRM_VideoInit()
DEBUG: Opening device /dev/dri/card0
DEBUG: Opened DRM FD (3)
DEBUG: no atomic modesetting support.
DEBUG: Video subsystem has not been initialized
INFO: Using SDL video driver: (null)
DEBUG: Video subsystem has not been initialized

After carefully checking, the radeon driver doesn?t support atomic modesetting. That?s not the only problem : the same happens with the amdgpu driver if we disable Display Core (kernel parameter amdgpu.dc=0, which is required to get analogue outputs working).

This is a major regression in the KMSDRM driver.

Using atomic mode setting is great, but having no fallback to the "standard KMS" is bad.
2020-12-15 12:22:48 -08:00
Ozkan Sezer 637d425e3e whitespace. 2020-12-15 00:11:10 +03:00
Ethan Lee f1c7cc710b winrt: Buildfix for older UWP SDKs 2020-12-14 12:36:04 -05:00
Sam Lantinga e65e4fd3ef Fixed detecting the guide button on Xbox One S controllers over Bluetooth on Linux 2020-12-14 09:48:51 -08:00
Ethan Lee 169cfe5a7c winrt: EffectiveLocation still needs an ifdef, IsApiContractPresent is for runtime 2020-12-14 11:52:09 -05:00
Sam Lantinga bfffa275ef Fixed bug 5397 - Fcitx input is truncated
sowfelicity

Split the long text input event into multiple shorten text input event.
2020-12-14 09:23:53 -08:00
Sam Lantinga 8795ca7067 Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085

I added some printf to verify the math being done.  Of the three joysticks I have, it works correctly for at least two, and seems to work correctly for the third.  I say "seems to" because, for the third joystick, the values never go through the AxisCorrect function, and thus never hit my printf statements, even though they did in the version I wrote my patch against.  I'm not sure what's going on there, but it at least seems to be working correctly in as much as I can tell.

I note this result in particular, for an SNES Gamepad (min=0, max=255):

Joystick value 0 becomes -32768
Joystick value 127 becomes 0
Joystick value 255 becomes 32767

Without the code that forces a zero point, the 127 input value would become -129, so I think you see why I added that code to turn it into zero.  However, I think Kai Krakow has a point about how SDL shouldn't assume that there should be a center.

Obviously in the majority of cases there actually should be a center, and the code that turns that 127 into an actual 0 is creating only a 0.2% error over 0.4% of this joystick's range.  However, what if there is an axis that is some kind of special control, like a 4-position switch, and, for whatever reason, the joystick reports it as an axis with 4 possible values, 0 to 3?  In that case, mutilating the two center values to the same value is much more of an error and and turns that 4-position switch into a 3-position switch.  If any joystick does this with a 2-position switch, then this code would render that control entirely useless as it would report the same value with the switch in either position.  Obviously the code could require that there be at least N possible values, to guess whether something is a proper axis or just some kind of switch, but the choice of N would be arbitrary and that's ugly.

I guess the real problem here is that my gamepad is just kind of broken.  It should be reporting a range of -1 to +1 since that's what it actually does.  Also, as Kai Krakow points out, it's probably not SDL's place to fix broken hardware.  I'll add that, if SDL does fix broken hardware, it should probably actually know that it's broken rather than be merely guessing that it is.

So, to the extent that SDL is able to do stuff like this, perhaps it's something better left for the user to configure in some kind of config file.
2020-12-14 09:15:47 -08:00
Ozkan Sezer 3c2757ff89 windows SDL_LoadObject: fix warning after commit 2ff650230d96 2020-12-13 18:25:02 +03:00
Ozkan Sezer 15cbddf497 linux/SDL_threadprio.c: fix build on older systems:
SCHED_RESET_ON_FORK is in kernel >= 2.6.32.
2020-12-13 18:00:20 +03:00
Ozkan Sezer 3b92933ac6 SDL_LoadObject (windows, os/2): prevent crash if dll name is NULL. 2020-12-13 17:37:50 +03:00
Ozkan Sezer b6e63625c8 fix bug #5395: handle old systems where inotify_init1 is not available 2020-12-13 15:32:24 +03:00
Sam Lantinga ee85a41a32 Fixed compile warning 2020-12-13 02:10:46 -08:00
Sam Lantinga 706f63759c Fixed build for platforms with only libusb hidapi implementations 2020-12-13 01:58:05 -08:00
Sam Lantinga 80e5c689eb Fixed the PS5 controller not disconnecting when powered off 2020-12-13 01:20:38 -08:00
Sam Lantinga db0a2025c3 Fixed bug 5241 - SDL on Linux needs a way to turn deadzones off
pj5085

It occurred to me that my simple patch that comments out a few lines of code does not correctly remove the dead zone since the calculation presumably assumes the dead zone has been cut out of the range.  Then, while looking into how to make it output the correct range of values, I realized SDL wasn't returning the correct range of values to begin with.

This line of code was already present:

printf("Values = { %d, %d, %d, %d, %d }\n", absinfo.value, absinfo.minimum, absinfo.maximum, absinfo.fuzz, absinfo.flat);

For my joystick this yeilds:

Values = { 0, -127, 127, 0, 15 }

Then this code calculates the coefficients:

In SDL1:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
if ( t != 0 ) {
  joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
} else {
  joystick->hwdata->abs_correct[i].coef[2] = 0;
}

In SDL2:
joystick->hwdata->abs_correct[i].coef[0] = (absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = (absinfo.maximum + absinfo.minimum) + 2 * absinfo.flat;
t = ((absinfo.maximum - absinfo.minimum) - 4 * absinfo.flat);
if (t != 0) {
  joystick->hwdata->abs_correct[i].coef[2] = (1 << 28) / t;
} else {
  joystick->hwdata->abs_correct[i].coef[2] = 0;
}

Neither calculates the correct coefficients for the code in the AxisCorrect function.

In SDL1:
if ( value > correct->coef[0] ) {
  if ( value < correct->coef[1] ) {
    return 0;
  }
  value -= correct->coef[1];
} else {
  value -= correct->coef[0];
}
value *= correct->coef[2];
value >>= 14;

In SDL2:
value *= 2;
if (value > correct->coef[0]) {
  if (value < correct->coef[1]) {
    return 0;
  }
  value -= correct->coef[1];
} else {
  value -= correct->coef[0];
}

In SDL1, the calculated coefficients are coef[0]=15, coef[1]=-15 and coef[2]=5534751.  So with a full-scale input of 127, it calculates an output value of 37835, which is considerably out of range.

In SDL2, the calculated coefficients are coef[0]=30, coef[1]=-30, and coef[2]=1383687.  So with a full-scale input of 127, it calculates the same output value of 37835.

I tested it with the 3 joysticks I have, and it produces out-of-range values for all of them.

Anyway, since dead zones are garbage, I just deleted all of that junk and wrote some code that takes the absinfo.minimum and absinfo.maximum values and uses them to scale the axis range to -32767 through +32767.

I also made it detect when a range doesn't have an integer center point, e.g. the center of -128 to + 127 is -0.5.  In such cases, if either value to the side of the center is provided, it zeros it, but it otherwise doesn't implement any kind of dead zone.  This seemed important with my gamepad which provides only the values of 0, 127, and 255, since without this hack it would never be centered.

Also, the previous minimum output value was -32768, but as that creates an output range that has no true center, I changed the minimum value to -32767.

I tested it with the 3 joystick devices I have and it seems to create correct values for all of them.
2020-12-12 23:48:02 -08:00
Sam Lantinga 0ccb3afd37 Fixed polling values after SYN_DROPPED event 2020-12-12 22:33:11 -08:00
Sam Lantinga 9ee0e8886c Whoops, make the hint actually default to false 2020-12-12 22:11:00 -08:00
Sam Lantinga 13a4caf1d7 Fixed bug 4286 - Joystick subsystem causes "not responding" when app is in the background
Added a hint to control whether a separate thread should be used for joystick events.
This is off by default because dispatching messages in other threads appears to cause problems on some versions of Windows.
2020-12-12 22:08:02 -08:00
Ozkan Sezer 5c212cb0c5 remove a few stale NULL message/title checks after commit e2b729b1756a
top-level guarantees non-NULL message / title passed in messageboxdata
2020-12-10 12:24:24 +03:00
Ozkan Sezer f1cab8aea6 fix bug #5253: handle NULL title or message fields in SDL_MessageBoxData
- SDL_video.c (SDL_ShowMessageBox): replace messageboxdata, set title
  or message field to "" if either of them is NULL.
- SDL_video.c (SDL_ShowSimpleMessageBox):  set title or message to ""
  if either of them is NULL for EMSCRIPTEN builds.
- SDL_bmessagebox.cc: add empty string check along with NULL check for
  title and message fields.
- SDL_windowsmessagebox.c (AddDialogString): remove NULL string check
- SDL_windowsmessagebox.c (AddDialogControl):  add empty string check
  along with the NULL check.
- SDL_x11messagebox.c: revert commit 677c4cd68069
- SDL_os2messagebox.c: revert commit 2c2a489d76e7
- test/testmessage.c: Add NULL title and NULL message tests.
2020-12-10 11:20:56 +03:00
Sam Lantinga 797a6910fd Fixed bug 5375 - WGI: Fix HSTRING memory leak.
Joel Linn

TLDR; https://godbolt.org/z/43fd8G

Let's deduce this from C++ reference code:

https://docs.microsoft.com/en-us/cpp/cppcx/wrl/how-to-activate-and-use-a-windows-runtime-component-using-wrl?view=msvc-160
At the bottom of the page there is this snippet:
```
int wmain()
{
    /* ... more code ... */

    // Get the domain part of the URI.
    HString domainName;
    hr = uri->get_Domain(domainName.GetAddressOf());
    if (FAILED(hr))
    {
        return PrintError(__LINE__, hr);
    }

    // Print the domain name and return.
    wprintf_s(L"Domain name: %s\n", domainName.GetRawBuffer(nullptr));

    // All smart pointers and RAII objects go out of scope here.
}
```

`HString` is defined in `corewrappers.h` and the call chain for the destructor is:
`~HString() -> Release() -> ::WindowsDeleteString()`

QED
2020-12-09 20:28:51 -08:00
Sam Lantinga a77a07152a Disabled raw input debug output 2020-12-09 07:50:15 -08:00
Sam Lantinga d46dd103d9 Fixed typo in Vulkan load logic 2020-12-09 07:49:07 -08:00
Sam Lantinga 7fa5e95b62 Fixed bug 5213 - Add support to metal in iOS/tvOS simulator
Vincent Hamm

Xcode11 and ios13 added support for metal simulator.
Here is a quick and dirty patch to enable it. Pretty early and only tested on a few samples for now. Required mostly to enable metal support on correct version of ios, generate simulator compatible shaders and enforce buffer alignments on simulator (same as osx).
2020-12-09 07:23:47 -08:00
Sam Lantinga cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Alistair Leslie-Hughes a69c61fbfd Only assign context and mainloop once we have connected successfully
If we fail to connect to the the pa server, we have an assigned context
and mainloop that isn't connected. So, when PULSEAUDIO_pa_context_disconnect
is called, pa asserts and crashes the application.

Assertion 'pa_atomic_load(&(c)->_ref) >= 1' failed at pulse/context.c:1055, function pa_context_disconnect(). Aborting.
2020-08-14 12:08:58 +10:00
Sam Lantinga 88cb4962cd Fixed bug 5291 - SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture 2020-12-09 06:42:31 -08:00
Sam Lantinga f2fff21762 Fixed bug 5374 - WGI: Use fast-pass strings.
Joel Linn

Eliminate additional heap allocation for short-lived HSTRINGs.
Uses `WindowsCreateStringReference()` to disable reference counting and memory management by the Window Runtime.
2020-12-09 06:24:40 -08:00
Sam Lantinga 50203d58b3 Fixed bug 5329 - SDL_SetWindowGrab(SDL_FALSE) fails to unlock cursor if window is partially offscreen
Ivan Mogilko

With SDL 2.0.12 under MS Windows, if the window is partially offscreen calling SDL_SetWindowGrab(w, SDL_TRUE) works, but subsequent call to SDL_SetWindowGrab(w, SDL_FALSE) does not work.

I tested this in both real program, and a small test app, where unlocking cursor worked perfectly while window is fully in desktop bounds, but did not work if it was at least few pixels outside.

For the reference, following code is enough to reproduce the issue:

#include <windows.h>
#include <SDL.h>

int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nShowCmd)
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* w = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 400, 0);

    bool grabbed = false;
    bool want_quit = false;
    while (!want_quit)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT: want_quit = true; break;
            case SDL_KEYDOWN:
                if (event.key.keysym.scancode == SDL_SCANCODE_SPACE)
                {
                    SDL_SetWindowGrab(w, static_cast<SDL_bool>(!grabbed));
                    grabbed = !grabbed;
                }
            }
        }
    }

    SDL_DestroyWindow(w);
    SDL_Quit();
    return 0;
}
2020-12-08 22:00:06 -08:00
Alice Rowan 3835f2008d Fix Nyko Airflo Ex Windows mapping, add Linux/Mac mappings 2019-03-03 12:38:23 -07:00
Sam Lantinga 43aad96681 Fixed bug 5222 - Crash when running with -DHIDAPI=ON
Mathieu Eyraud

SDL dynamically loads libusb but does not check the return value of 'SDL_LoadFunction'.

Also libusb is loaded and initialized several time because 'SDL_hidapi_wasinit' is never set to true.

I made a patch if you want to test:
  - check that 'hid_init' is called once and only once,
  - check return value of 'hid_init',
  - check return value of 'SDL_LoadFunction',
  - check return value of 'SDL_malloc',
  - add some debug logging.
2020-12-08 19:03:50 -08:00
Sam Lantinga a2098a47b6 Updated SDL to 2.0.14 in preparation for release candidate 2020-12-08 18:56:06 -08:00
Sam Lantinga c9723c407f Fixed potential hang in joystick close if the rumble thread is blocked for some reason
It's still possible to hang when shutting down, if the rumble thread is still hung, but it won't block indefinitely at runtime.
2020-12-07 09:38:21 -08:00
Sam Lantinga 09909d029d Fixed handling of BACK button on newer Xbox One S controllers 2020-12-03 19:44:47 -08:00
Sam Lantinga 54e5136b50 Refactored Xbox One Bluetooth protocol and verified Xbox One S, Xbox Series X, and Xbox One Elite Series 2 controllers 2020-12-03 18:17:04 -08:00
Sam Lantinga 1031231b29 Fixed duplicating a device between XInput and HIDAPI 2020-12-03 18:17:03 -08:00
Sam Lantinga 59f28b7f4b Fixed whitespace 2020-12-03 18:17:01 -08:00
Sam Lantinga f487d63a6b Fixed crash when printing NULL wide character string 2020-12-03 18:16:56 -08:00
Sylvain Becker 754286c61c SDL Renderer: specify the correct flag when recreating the window 2020-12-02 13:45:24 +01:00
Sylvain Becker 035f8f2391 SDL_RecreateWindow: allow clearing VULKAN when recreating the window 2020-12-02 13:37:59 +01:00
Sylvain Becker 93fbab0fac SDL_ReCreateWindow: allow to unload METAL window and switch back to OpenGL.
On older mac, where METAL Renderer METAL fails to create, it allows to switch back to OpenGL SDL_Renderer
by re-creating the window (METAL flags was previously persistent).
2020-12-02 11:04:53 +01:00
Cameron Gutman 9d40a0f317 Fix joystick device add events containing invalid device indexes
This can happen if the application has not yet processed SDL_JOYDEVICEADD when
the same joystick is removed. It may also happen if two joysticks are added
and the second joystick is removed before the first joystick's SDL_JOYDEVICEADD
has been processed by the application.
2020-08-29 16:50:26 -07:00
Sam Lantinga c78ca2d170 Fixed bug 5371 - Rawinput: Fix truncating cast of string length.
Joel Linn

Fixes an implicit truncation of a string length on 64bit systems.
2020-12-01 13:38:42 -08:00
Sam Lantinga a3ccf9adca Fixed bug 5373 - [PATCH] Rawinput: Get correlated XInput battery info
Joel Linn

Currently the rawinput driver always reports a device as "wired". This changes that to "unknown" and updates it once the device is correlated with xinput.
2020-12-01 13:36:41 -08:00
Sam Lantinga e3966e25ca Use the correct internal API for updating the battery level for PS5 controllers 2020-11-30 13:04:30 -08:00
Sam Lantinga f4ed07de06 We don't know whether the PS5 controller is Bluetooth or not when we open it 2020-11-30 13:02:34 -08:00
Sam Lantinga 1f2f536bd2 Fixed XInput correlation for raw input controllers after hotplug events 2020-11-27 18:57:40 -08:00
Sam Lantinga 1c865c460b Load the raw input device list at init time so it's available when DirectInput is doing device detection 2020-11-27 18:57:36 -08:00
Sam Lantinga a0c5bfa3bd Moved raw input event processing from the main thread to the joystick thread
This allows fast joystick event delivery regardless of what the main thread is doing.
2020-11-27 13:08:40 -08:00
Sam Lantinga 4fbefbe20d Sort the raw input axes by usage, so X comes before Y, etc. 2020-11-27 11:33:53 -08:00
Sam Lantinga 4ddac485db Backed out minor optimization that prevented correlation_id from being set 2020-11-27 11:33:51 -08:00
Sam Lantinga 8973a25849 Enable dispatching of WM_INPUT_DEVICE_CHANGE events directly, in case the application hasn't created a window with the normal message loop 2020-11-27 10:44:56 -08:00
Sam Lantinga e8adc64810 Enable dispatching of WM_INPUT events directly, in case the application hasn't created a window with the normal message loop 2020-11-27 10:44:55 -08:00
Sam Lantinga 0252235e82 Recheck devices if another API queries raw input for a new device 2020-11-27 10:44:53 -08:00
Sam Lantinga a7dede7e36 Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons 2020-11-27 10:44:51 -08:00
Sam Lantinga ce77966da8 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers 2020-11-27 10:44:49 -08:00
Sam Lantinga 8a449de20d Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT 2020-11-27 10:44:47 -08:00
Sam Lantinga 37c9e4afa3 Fixed processing WM_INPUT_DEVICE_CHANGE at startup 2020-11-27 06:03:15 -08:00
Sam Lantinga 248fc75bd2 Correlate just based on buttons, joystick axes are not as precise and could potentially cause incorrect uncorrelation.
It's okay if the triggers aren't precise until someone presses a button on their controller.
2020-11-27 05:53:56 -08:00
Sam Lantinga e7e615de26 Removed extraneous windows message pumping
Most of the raw input events are dispatched in the main windows message loop. We only dispatch device change messages separately when we need them to be completely up to date.
2020-11-27 05:53:54 -08:00
Sam Lantinga 2931eccd84 Fixed detecting Bluetooth raw input devices, which have device names longer than 128 characters 2020-11-27 05:53:52 -08:00
Sam Lantinga 849ce80376 Renamed SDL_JOYSTICK_RAWINPUT_GAMING_INPUT to SDL_JOYSTICK_RAWINPUT_WGI 2020-11-27 05:53:50 -08:00
Sam Lantinga 219a28dd8a Fixed D-pad uncorrelating raw input controllers (thanks Jimbly!) 2020-11-27 03:45:05 -08:00
Sylvain Becker 2c079a2f6c SDL_FillRects: prevent empty SDL_surface from raising an error message
It's legitimate to have a surface with 0 width or height (null 'pixels' pointer).
But calling SDL_FillRects would wrongly set the error "You must lock the surface".
2020-11-27 09:42:14 +01:00
Ozkan Sezer 3fbff2a45b SDL_rawinputjoystick.c: fix ambiguous 'else' warning
src/joystick/windows/SDL_rawinputjoystick.c: In function 'RAWINPUT_HandleStatePacket':
src/joystick/windows/SDL_rawinputjoystick.c:1343:9: warning: suggest explicit braces to avoid ambiguous 'else'
2020-11-26 10:47:33 +03:00
Sam Lantinga 845b903324 Implemented trigger rumble for raw input controllers 2020-11-25 16:46:42 -08:00
Sam Lantinga 517be80822 Implemented battery status for Bluetooth Xbox One controllers
Also switched the rumble loop count to 0xEB (one hour) to match Windows driver
2020-11-25 16:05:19 -08:00
Sam Lantinga 6a7f29cdbb Fixed compiling on tvOS 2020-11-25 11:31:17 -08:00
Sam Lantinga 9ec2cf5629 Fixed building with Windows.Gaming.Input enabled 2020-11-25 10:31:59 -08:00
Sam Lantinga 3c07dd12f0 Strip an extra '.' off of the HORI manufacturer name 2020-11-25 10:28:48 -08:00
Sam Lantinga 159d1b3df5 Don't set the serial number after the controller is opened
We'll use the USB value instead so it's available as soon as it's opened.
2020-11-25 01:35:45 -08:00
Sam Lantinga 7d92b14f46 Simplified Xbox One controller initialization state, and don't query for the serial number. 2020-11-25 01:18:18 -08:00
Sam Lantinga 9fc4a4c92c Revamped Xbox One HIDAPI init sequence
Added support for querying the controller serial number on newer firmware
2020-11-24 22:25:26 -08:00
Sam Lantinga 46a844786b Added SDL_wcscasecmp() and SDL_wcsncasecmp() 2020-11-24 12:43:01 -08:00
Sam Lantinga e4b7d9a221 Removed usage of TARGET_OS_OSX for building with older SDKs 2020-11-24 07:56:59 -08:00
Ethan Lee a7d91ebaa5 winrt: Add EffectiveLocation support for newer Win10 releases 2020-11-09 17:05:21 -05:00
Sam Lantinga a5cde4cb0c Fixed trying to use @available() on older SDK 2020-11-24 07:29:55 -08:00
Sam Lantinga 97782e6c64 Don't try to call IOS_SupportedHIDDevice() if it's not defined 2020-11-24 07:11:49 -08:00
Sam Lantinga a063b9fbfb Fixed compiler warning 2020-11-24 07:06:31 -08:00
Sam Lantinga c63bbb06e9 Including SDL_config_iphoneos.h enables MFI controller code 2020-11-24 06:55:33 -08:00
Sam Lantinga 7a05dbf4b9 Fixed building on FreeBSD
Alex S

Looks like we have a collision with https://hg.libsdl.org/SDL/rev/cd774daff9f6. (Again, the headers in the base system are intended for drivers and should not be used for compiling non-base applications. At least that's the policy for now: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240964#c19.)
2020-11-24 06:42:53 -08:00
Sam Lantinga feab9d42c1 5363 - Memory leak of joystick->sensors in SDL_JoystickClose
Mathieu Eyraud

Joystick->sensors is never freed.
2020-11-24 06:40:13 -08:00
Sam Lantinga 34bea84a54 Fixed bug 5335 - Patch: enable joystick/haptic/evdev support by default on FreeBSD
Alex S

Ah, that's not quite enough. You need to:
  1. rename src/joystick/bsd/SDL_sysjoystick.c to something;
  2. regenerate configure.
2020-11-23 23:03:55 -08:00
Sam Lantinga 1e943e2ad2 Fixed building with an older SDK and macOS target 2020-11-23 22:59:22 -08:00
Sam Lantinga 4121ab6200 Fixed bug 5354 - DirectFB: Add Vulkan support
Nicolas Caramelli

This patch adds Vulkan support for the DirectFB video driver.
A screenshot with SDL tests running on DirectFB is available on the HiGFXback project:

https://github.com/caramelli/higfxback/wiki/DirectFB#sdl
2020-11-23 21:25:07 -08:00
Sam Lantinga e44bf8a080 Fixed bug 5359 - Incorrect sensor data from DualShock4
multiply gyro values by sensitivity

When the hardware calibration fails, values read from sensors need to be multiplied by default sensitivity (16 for gyro, 1 for accelerometer).
2020-11-23 21:18:37 -08:00
Sam Lantinga c8c818d7a4 Fixed bug 5360 - non-libudev joystick detection doesn't see controllers that were already connected
Simon McVittie

When watching for hotplug events we can poll the inotify fd, but we
still need to scan /dev/input once per process, otherwise we'll fail
to detect devices that were already connected.
2020-11-23 21:14:37 -08:00
Simon McVittie 8e2746cfb6 joystick: Don't use udev in Flatpak or pressure-vessel container
Flatpak[1] and pressure-vessel[2] are known to use user namespaces,
therefore udev event notification via netlink won't work reliably.
Both frameworks provide a filesystem API that libraries can use to
detect them. Do that, and automatically fall back from udev-based
device discovery to the inotify-based fallback introduced in Bug #5337.

[1] <https://flatpak.org/>
[2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-23 21:10:48 -08:00
Sam Lantinga e9869e07bf Fixed bug 5335 - enable joystick/haptic/evdev support by default on FreeBSD
Alex S

Evdev headers aren't actually included in the base system (well, it has a private copy), they are available through the devel/evdev-proto port instead. We also have devel/libinotify and devel/libudev-devd shims, I didn't verify whether they work with SDL.
2020-11-23 21:08:19 -08:00
Sam Lantinga 62e39b5fa7 Fixed building with an older SDK and macOS target 2020-11-23 20:57:14 -08:00
Sam Lantinga 268aa45645 Fixed compiling with SDL_JOYSTICK_RAWINPUT disabled 2020-11-23 20:26:28 -08:00
Ryan C. Gordon eaa53a1979 joystick: On Linux, don't try to close an invalid inotify file descriptor. 2020-11-23 22:16:07 -05:00
Ryan C. Gordon 5c9577476f joystick: Fix up Linux joystick code to (mostly) compile on FreeBSD. 2020-11-23 22:14:22 -05:00
Sam Lantinga 179bd66581 Don't enable PS5 controller support if DS4Windows is running - they conflict. 2020-11-23 18:27:43 -08:00
Sam Lantinga 5b3616c325 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices
This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
2020-11-23 18:24:05 -08:00
Ryan C. Gordon 0ff5d55a07 x11: Don't try to grab the pointer on an unmapped window (thanks, Lee!)
Fixes Bugzilla #5352.
2020-11-23 21:07:28 -05:00
Sam Lantinga fd89446782 Fixed building on Mac OS X on the command line and with an older macOS SDK 2020-11-21 14:13:26 -08:00
Sam Lantinga 1df593fb16 Fixed bug 5355 - Add GameController Framework support to macOS
C.W. Betts

This patch adds support to the GameController framework on macOS Big Sur and later, adding support for MFi controllers as well as rumble support for PS4 and Xbox One. There is some code to make sure that the IOKit joystick handler doesn't include two controllers at once.

While the GameController framework is present in earlier versions of macOS, there was no public, approved way of checking if a specific IOHIDDevice is a controller that GameController could handle. This was changed in Big Sur.
2020-11-21 13:15:33 -08:00
Sam Lantinga 870841c414 Reset the LED state after Bluetooth connection has completed on the PS5 controller 2020-11-21 11:59:01 -08:00
Sam Lantinga a94fe009c6 Moved comment with the code it covers 2020-11-21 18:40:27 -08:00
Sam Lantinga 49f7be6d0d Fixed compile warning C4127: conditional expression is constant 2020-11-21 18:37:56 -08:00
Sam Lantinga 63b52e8e67 Remove SDL dependency in Windows code 2020-11-21 18:34:32 -08:00
Sam Lantinga d4954eb090 Removed debug code 2020-11-21 18:26:43 -08:00
Sam Lantinga b442e617e9 Fixed adding an extra zero byte for feature reports
At least with PS4 and PS5 controllers DeviceIoControl() returns the correct value
2020-11-21 18:15:55 -08:00
Sam Lantinga 2e8e3854b8 Fixed compile warning 2020-11-21 17:59:15 -08:00
Sam Lantinga 6b56b98fc3 Fixed is_BLE() return value 2020-11-21 09:26:11 -08:00
Sam Lantinga 65c9f1d2cc Fixed upstream bug: FD 0 is a valid file descriptor
https://github.com/libusb/hidapi/issues/199
2020-11-21 09:06:48 -08:00
Sam Lantinga 549010f2a0 It takes 2 packets to stop audio haptics and start emulated rumble on the PS5 controller 2020-11-20 13:24:49 -08:00
Ozkan Sezer 082558db33 SDL_os2messagebox.c (_makeDlg): fix crash if title and/or message is NULL.
c.f.: bug #5253.
2020-11-20 12:20:02 +03:00
Sam Lantinga bf7d198d48 The HORI Fighting Commander should only show up as an XInput Switch Controller on Windows 2020-11-19 19:09:42 -08:00
Sam Lantinga 6cb7f9e39a Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for Nintendo Switch Pro controllers using the HIDAPI driver 2020-11-19 19:09:40 -08:00
Sam Lantinga 9980766533 Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for the Nintendo Switch Pro controller on Linux 2020-11-19 19:09:38 -08:00
Sam Lantinga 7366693f3b Added support for a few more controllers on Linux 2020-11-19 19:09:36 -08:00
Sam Lantinga ffb4d960b2 Disabled Xbox protocol debugging 2020-11-19 19:09:34 -08:00
Sam Lantinga c9b097e659 Clarify the meaning of the rumble enable bits for the PS5 controller 2020-11-19 13:31:16 -08:00
Sam Lantinga c85623d790 Re-enable haptic audio after rumble on PS5 controller
Also make sure we don't set any other state when we're not intending to, and added more interesting effects which are currently not exposed via API
2020-11-19 13:10:14 -08:00
Sam Lantinga b0b76a61c7 Fixed rumble on PS5 controllers connected to Windows over Bluetooth 2020-11-19 07:12:53 -08:00
Sam Lantinga 8c3196da60 Fixed some compiler warnings 2020-11-18 21:33:11 -08:00
Sam Lantinga 45f1437549 Experimenting with requesting the serial number on an Xbox One controller 2020-11-18 20:34:12 -08:00
Sam Lantinga 963d8b3f40 Fixed bits in the initial Xbox One protocol ack 2020-11-18 20:34:10 -08:00
Sam Lantinga cd51a51f00 Updated with a better understanding of the Xbox One controller protocol 2020-11-18 20:34:08 -08:00
Ryan C. Gordon 335cfa107b x11: Don't crash if a messagebox has a NULL title string.
Fixes Bugzilla #5253.
2020-11-18 11:24:08 -05:00
Sam Lantinga 51ea6a6d44 Don't send controller gyro and accelerometer updates if the values haven't changed.
This keeps SDL_PollEvent() from returning data continuously when polling controller state.
2020-11-17 22:09:52 -08:00
Sam Lantinga 463d84a860 Added support for the PS5 controller gyro and accelerometer 2020-11-17 10:56:56 -08:00
Sam Lantinga fcb21aa883 Added API for sensors on game controllers
Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers

Also fixed an issue with the accelerometer on iOS having inverted axes
2020-11-17 10:30:20 -08:00
Sam Lantinga d140d88744 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial() 2020-11-16 17:36:47 -08:00
Ryan C. Gordon 55e59a4f33 crc32: Fixed include path. 2020-11-16 18:48:13 -05:00
Sam Lantinga 7bbea0bb94 Fixed build warning 2020-11-16 15:10:02 -08:00
Sam Lantinga 71e32f5e1b Added SDL_crc32() 2020-11-16 15:00:15 -08:00
Sam Lantinga 3d48fc05c3 Added notes about the pad lights on the PS5 controller 2020-11-16 13:21:02 -08:00
Sam Lantinga 4514ad573e Fixed updating LED state when starting application with Bluetooth PS5 controller connected 2020-11-16 13:07:11 -08:00
Sam Lantinga a37e3ae218 Implemented PS5 effects over Bluetooth 2020-11-16 11:21:58 -08:00
Sam Lantinga c6c116e847 Implemented setting the LED color on the PS5 controller 2020-11-16 10:51:13 -08:00
Sam Lantinga aa7c3eae19 Fixed size of rumble packet 2020-11-16 09:16:01 -08:00
Sam Lantinga f28c01a4fb Fixed rumble order on PS5 2020-11-16 09:11:15 -08:00
Sam Lantinga eb94c19a63 SDL: fix iOS build 2020-11-16 08:09:15 -08:00
Sam Lantinga 8243bd1dc6 SDL: Plumb PS5 rumble to output report 2020-11-16 08:09:13 -08:00
Ozkan Sezer c0f7325b85 SDL_PrivateJoystickForceRecentering: fix wrong loop counter usage.
The typo seems to have been added by commit c7782fd6142b
2020-11-15 17:10:15 +03:00
Sam Lantinga 5c34c973e6 Clarify that we're using button indices, not using gamepad button names 2020-11-13 19:40:25 -08:00
Sam Lantinga 9f51fad361 Added support for the touchpad on PS4 and PS5 controllers 2020-11-13 18:01:29 -08:00
Sam Lantinga 78422fa3c8 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth 2020-11-13 13:17:07 -08:00
Sam Lantinga 30371f2d4d Fixed doubled report ID for Bluetooth Classic devices on Linux 2020-11-13 13:17:04 -08:00
Sam Lantinga 8cd4f364db Mapped the touchpad click as SDL_CONTROLLER_BUTTON_MISC1 on the PS5 controller 2020-11-12 20:02:31 -08:00
Sam Lantinga 8e312a6a59 Fixed detecting Bluetooth XInput controllers on Windows 2020-11-12 15:56:33 -08:00
Sam Lantinga 8b29aaddbd Fixed warning when building on Windows 2020-11-12 14:34:11 -08:00
Sam Lantinga e0018d0869 Fixed Windows build 2020-11-12 14:23:56 -08:00
Sam Lantinga 0500c04468 Fix SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL also applying to HIGH priorities
As the name suggests, the hint should only apply to SDL_THREAD_PRIORITY_TIME_CRITICAL

The resulting priorities for my current distro result in these values:

     | High         | Time Critical
Hint |--------------|-----------------
 0   |  P=10 N=-10  | P=5   N=-15
 1   |  P=10 N=-10  | P=-21 N=0
2020-11-12 07:53:05 -08:00
Sam Lantinga 5b0d432942 Implemented trigger rumble in the HIDAPI Xbox One driver 2020-11-12 07:53:03 -08:00
Ozkan Sezer c122e9b9ce linux/SDL_sysjoystick.c (MaybeRemoveDevice): remove SDL_USE_LIBUDEV guards
fixes bug #5349.
2020-11-12 14:11:50 +03:00
Sam Lantinga 83b653d55d Fixed build warning 2020-11-11 20:09:56 -08:00
Sam Lantinga 76bd6cd2d9 Fixed bug 5326 - Logitech Extreme 3D joystick is listed as gamepad in linux section of SDL_gamecontrollerdb.h
Spooky

For some reason the Logitech Extreme 3D joystick was added to SDL_gamecontrollerdb.h  in the linux section only.

This breaks the joystick in linux as it is not a gamepad.  I am unable to correctly use or map the Logitech Exteme 3D joystick in games that use SDL2 in linux.

Please remove Logitech Extreme 3D from SDL_gamecontrollerdb.h  Linux section.  It is a joystick not a gamepad.
2020-11-11 19:45:56 -08:00
Sam Lantinga 3160c7d66f Fixed bug 5327 - When direct input fails to load, but a controlller is plugged in through another api, an access violation happens.
Bart van der Werf

When directinput fails to load, but a controlller is plugged in, an access violation happens.
This is due to IEventHandler_CRawGameControllerVtbl_InvokeAdded calling SDL_DINPUT_JoystickPresent which does not check if dinput is assigned signalling initialization of directinput.
2020-11-11 19:43:02 -08:00
Sam Lantinga 502cfe314a Fixed bug 5332 - WGI: Fix wrong level of indirection and implicit truncating cast.
Joel Linn

This fixes two types of MSVC compiler warnings.

- One parameter in the function signatures of two WGI event handlers had one level of indirection too much (and did not match Windows SDK headers). The indirection was cast away so it still worked.
- size_t was implicitly cast to UINT32 for a number of (constant) string lengths.
2020-11-11 19:39:46 -08:00
Sam Lantinga 1822f97e5f Fixed bug 5346 - Add FreeBSD evdev KBIO keyboard input driver
wahil1976

This patch adds the KBIO text input driver for FreeBSD, which allows text input to fully work without text spilling out into the console. It also supports accented input, AltGr keys and Alt Lock combinations.

Tested with US accent keys layout and various AltGr layouts.
2020-11-11 19:37:47 -08:00
Sam Lantinga 320a7587d7 Fixed compiler warnings 2020-11-11 19:26:59 -08:00
Simon McVittie b0eba1c55d joystick: Use inotify to detect joystick unplug if not using udev
This improves SDL's ability to detect joystick hotplug in a container
environment.

We cannot reliably receive events from udev in a container, because they
are delivered as netlink events, which are authenticated by their uid
being 0. However, in a user namespace created by an unprivileged user
(for example bubblewrap, as used by Flatpak and Steam's
pressure-vessel-wrap), the kernel does not allow us to map uid 0, and
the netlink events appear to be from the kernel's overflowuid (typically
65534/nobody), meaning libudev cannot distinguish between genuine uevents
from udevd and an attack by a malicious local user.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:15:32 -08:00
Simon McVittie aae53d5972 evdev: Detect whether input devices are accelerometers
Anything with X, Y and Z axes but no buttons is probably an
accelerometer (this is the assumption made in udev).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:15:09 -08:00
Simon McVittie fdd945f2af joystick: Use a better heuristic to guess what is a joystick
Previously we only checked for at least one button or key and at least
the X and Y absolute axes, but this has both false positives and false
negatives.

Graphics tablets, trackpads and touchscreens all have buttons and
absolute X and Y axes, but we don't want to detect those as joysticks.
On normal Linux systems ordinary users do not have access to these
device nodes, but members of the 'input' group do.

Conversely, some game controllers only have digital buttons and no
analogue axes (the Nintendo Wiimote is an example), and some have axes
and no buttons (steering wheels or flight simulator rudders might not
have buttons).

Use the more elaborate heuristic factored out from SDL's udev code path
to handle these cases.

In an ideal world we could use exactly the same heuristic as udev's
input_id builtin, but that isn't under a suitable license for inclusion
in SDL, so we have to use a parallel implementation of something
vaguely similar.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:52 -08:00
Simon McVittie 8db3171b98 udev: Factor out SDL_EVDEV_GuessDeviceClass
This works on capability bitfields that can either come from udev or
from ioctls, so it is equally applicable to both udev and non-udev
input device detection.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:34 -08:00
Simon McVittie 13e7d1a958 joystick: Allow libudev to be disabled at runtime
Device enumeration via libudev can fail in a container for two reasons:

* the netlink protocol between udevd and libudev is considered private,
  so there is no API guarantee that the version of libudev in a container
  will understand netlink messages from a dissimilar version of udevd
  on the host system;
* the netlink protocol between udevd and libudev relies for security on
  being able to check the uid of each message, but in a container with
  a user namespace where host uid 0 is not mapped, the libudev client
  cannot distinguish between messages from host uid 0 and messages from
  a different, malicious user on the host

To make this easier to experiment with, always compile the fallback
code path even if libudev is disabled. libudev remains the default if
enabled at compile time, but the fallback code path can be forced.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:11 -08:00
Cameron Gutman 72379ba510 windows: Fix handling of swapped mouse buttons
GetAsyncKeyState() and GetRawInputData() report the state of the physical
buttons without applying the user's primary/secondary mouse button swap
preference. Swap the buttons returned from these functions, so we expose a
consistent view of the buttons to SDL callers. This new behavior also matches
the behavior of macOS and X11 backends.

See the Remarks section of the GetAsyncKeyState() function on MSDN.
2020-08-25 21:22:00 -07:00
Cameron Gutman 771732ed32 windows: Fix numpad arrow key scancodes with numlock off
We should only perform the VK_LEFT, VK_UP, etc. mapping if none of the other
special mappings apply. This allows the scancode normalization for the number
pad to take place as intended.
2020-08-27 17:54:52 -07:00
Sam Lantinga 1e2caac58b Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers() 2020-11-11 18:57:37 -08:00
John "Nielk1" Klein 067630aef3 Fix hidapi for unhandled DS4 headset microphone data corrupting controller state 2020-11-11 03:47:08 -06:00
Sam Lantinga b6238c87e4 Don't try to build the RAWINPUT driver if HIDAPI is disabled 2020-11-11 14:48:23 -08:00
Sam Lantinga d1e10c313e Removed debug output 2020-11-11 14:38:14 -08:00
Sam Lantinga 07eae7d670 Fix process randomly getting killed when SDL_THREAD_PRIORITY_HIGH/TIME_CRITICAL is set
When we request realtime priority from rtkit, we have a rttime limit. If we exceed
that limit, the kernel will send SIGKILL to the process to terminate it.

This isn't something that most high priority processes will want, only processes
that selectively opt into SCHED_RR/FIFO through SDL_HINT_THREAD_PRIORITY_POLICY
should be subject to this level of scrutiny.

This change:
  * Switches non-apple posix OSs to use SCHED_OTHER instead of SCHED_RR
for SDL_THREAD_PRIORITY_HIGH/SDL_THREAD_PRIORITY_TIME_CRITICAL.
  * Fixes using a hardcoded RLIMIT_RTTIME, instead queries it from rtkit
  * Only sets RLIMIT_RTTIME for MakeRealtime rtkit requests
  * Adds a note regarding the possible SIGKILL with SDL_HINT_THREAD_PRIORITY_POLICY
  * Introduces SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow apps to acquire realtime scheduling policies on Linux
2020-11-11 08:47:18 -08:00
Ozkan Sezer 59795822d0 make SDL_SensorGetDeviceNonPortableType match its prototype. 2020-11-11 12:33:55 +03:00
Ozkan Sezer 53b166797d SIZE_MAX need not be defined in limits.h
it can be in limits.h (windows) or stdint.h.
2020-11-11 12:33:55 +03:00
Sam Lantinga e12457d8bf Added support for the Xbox Series X controller to the HIDAPI driver 2020-11-10 12:26:30 -08:00
Ryan C. Gordon 7b5a0a9f97 uikit: Don't implement main() twice for iOS static libs.
I think this was a leftover from before the two Xcode projects were merged.
2020-11-10 13:12:10 -05:00
Ryan C. Gordon 940419b0a6 uikit: Fixed a typo in a comment. 2020-11-10 13:09:59 -05:00
Sam Lantinga c3dea23120 Added support for reading the paddles on a Xbox Elite Series 2 controller in Bluetooth mode 2020-11-09 22:39:33 -08:00
Dylan Fan 02de820008 Add Zhaoxin processor support
CPU Vendor ID "Shanghai" and "CentaurHauls" belongs to Zhaoxin.

Background:
Shanghai Zhaoxin Semiconductor Co., Ltd ("Zhaoxin") , established in 2013,
headquartered in Zhangjiang, Shanghai, China. Zhaoxin aims at providing
general-purpose x86 processors.

Related Zhaoxin Linux Kernel patch can be found at
https://lore.kernel.org/lkml/01042674b2f741b2aed1f797359bdffb@zhaoxin.com
Best regards.
2020-11-09 20:36:35 -08:00
Sam Lantinga fb4a406af2 Don't put 'm' in the GUID for Xbox and PS4 controllers on iOS 2020-11-09 18:45:22 -08:00
Sam Lantinga f8b8bd0ba1 ControllerList: recategorize controller as swtich pro and not switch input-only controller 2020-11-09 10:12:02 -08:00
Sam Lantinga f76ca05729 ControllerList: add unknown xbox controller from minidumps 2020-11-09 10:11:59 -08:00
Sam Lantinga 94924f012b Fix failing to set high priority for threads on Linux desktop.
Debugging inside rtkit showed we were failing the RLIMIT_RTTIME check, now that we're asking for realtime and not just high-priority due to a change in SDL.

Between that and the DBus code in SDL being wrong in previous changelist I'm not sure how this could have ever worked.
2020-11-09 10:11:55 -08:00
Sam Lantinga abf9dfd5c2 Fix MakeThreadRealtime DBus method call on Linux, type mismatch due to copy paste.
Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32"
Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32"

Docs:

http://git.0pointer.net/rtkit.git/tree/README

CLIENTS:
        To be able to make use of realtime scheduling clients may
        request so with a small D-Bus interface that is accessible on
        the interface org.freedesktop.RealtimeKit1 as object
        /org/freedesktop/RealtimeKit1 on the service
        org.freedesktop.RealtimeKit1:

                void MakeThreadRealtime(u64 thread_id, u32 priority);

                void MakeThreadHighPriority(u64 thread_id, s32 priority);
2020-11-09 10:11:38 -08:00
Sam Lantinga 1577366c36 Fixed duplicated switch statement processing Xbox controller dpad state 2020-11-08 23:49:03 -08:00
Bart van der Werf 3d92e8c742 hidapi: Also parse data[12] with dpad values on the xb1s controller 2020-10-21 10:43:46 -04:00
Sam Lantinga 1ef45c1801 Fixed bug 5339 - Minor memory leak in SDL_x11events.c
wcodelyokoyt

The atom name that X11_GetAtomName() returns never gets freed, which result in a minor memory leak (14 bytes?) every time the user drops a file on a window.
You can see the line in question here:
6b6170caf6/src/video/x11/SDL_x11events.c (L1350)

Fix: call XFree on name after the while loop.
2020-11-08 23:40:17 -08:00
Sam Lantinga 723d76c8ec Fixed bug 5333 - Replace character of legacy code page with utf-8 one.
Joel Linn

This patch fixes a MSVC warning, which is dependent on the regional settings of the build system. Although the character is inside a comment and harmless, it is undesirable to disable the warning for this.
2020-11-08 23:34:59 -08:00
Ryan C. Gordon 0e4ce84801 opengl: Make diagonal lines match the software renderer.
OpenGL leaves the final line segment open, SDL's software renderer does not,
so we need a tiny bit of trigonometry here to move one more pixel in the right
direction.
2020-11-08 20:57:17 -05:00
Ryan C. Gordon da49f79500 opengles: use glDrawArrays() correctly with GL_LINE_STRIP. 2020-11-08 19:56:12 -05:00
Ryan C. Gordon de6d0ac55a uikit: Patched to compile on older iOS SDKs. 2020-11-08 18:11:42 -05:00
Ryan C. Gordon 93a2c58c7e opengl: Use GL_LINE_STRIP instead of breaking down into seperate GL_LINES.
Surely GL drivers have improved in the last seven years. I hope...?
2020-11-08 12:37:09 -05:00
Ryan C. Gordon 731a5d1c53 metal: Fix line drawing, again. 2020-11-08 03:18:05 -05:00
Sam Lantinga 4ea1a10bd2 Added stub controller LED functions for WGI and RAWINPUT (thanks meyraud!) 2020-11-07 02:49:22 -08:00
Sam Lantinga 009b62f1c2 Be explicit about mapping the new game controller paddle buttons 2020-11-07 02:22:15 -08:00
Sam Lantinga 749062e72b Implemented SDL_GameControllerSetLED() for iOS/tvOS 2020-11-06 16:53:13 -08:00
Sam Lantinga faeac6e86c Added additional game controller button support on iOS/tvOS 2020-11-06 16:42:46 -08:00
Sam Lantinga 3a3aaac221 Added 4 auxiliary buttons to the game controller API
Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver
PS4 and PS5 controllers use AUX1 to represent the touchpad button
Nintendo Switch Pro controllers use AUX1 to represent the capture button
2020-11-06 11:30:52 -08:00
Sam Lantinga a22beef402 Moved the PS5 controller driver to a separate file, as the advanced feature protocol is very different from that of the PS4 2020-11-05 17:03:28 -08:00
Sam Lantinga bd2dd3f6bb Added Android mapping for the Sony PS5 Controller 2020-11-05 15:36:15 -08:00
Sam Lantinga 4d79f9662f Added initial support for the Sony PS5 Controller 2020-11-05 15:02:54 -08:00
Sam Lantinga e555d45331 Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
2020-11-05 11:07:54 -08:00
Ethan Lee 83cddd2ebc Add SDL_JoystickSetLED.
Currently, this is only supported by the PS4 HIDAPI driver.
2020-04-30 11:57:29 -04:00
Ryan C. Gordon 1b8dee7caf coreaudio: Remove unnecessary include of CoreServices.h 2020-10-31 11:32:40 -04:00
Sam Lantinga ddc0727bba Fixed implicit memcpy() when building for ARM64 on Windows (thanks Seigo!) 2020-10-27 09:00:42 -07:00
Ryan C. Gordon 010d5fba93 kmsdrm: Make this build with significantly older system libraries.
This allows one to build Raspberry Pi versions on an ancient version of
Raspbian and get both the KMSDRM and RPI video targets built into SDL, giving
maximum binary compatibility from linking against an older glibc, etc, but
also making one library that can access video on all RPi models and OS
releases.
2020-10-26 09:49:09 -04:00
Ozkan Sezer f0c5841714 SDL_shape_internals.h: forward-declare struct SDL_ShapeTree. 2020-10-25 10:10:10 +03:00
Ozkan Sezer a4040293dd os2: misc build fixes 2020-10-25 10:10:02 +03:00
Ozkan Sezer bfc80d83c2 minor coding style cleanup 2020-10-25 03:55:02 +03:00
Ryan C. Gordon ba36eb0437 metal: Make line drawing match software renderer.
Partially fixes Bugzilla #2711.
2020-10-21 00:03:33 -04:00
Ryan C. Gordon c33f808354 render: Restoring line rendering fixes that were previously put on hold.
(Backed out hg changeset 7a4240daba46)
2020-10-20 11:12:49 -04:00
Sam Lantinga 5dc6c3c951 Updated Vulkan headers to version 1.2.158
https://github.com/KhronosGroup/Vulkan-Headers
2020-10-24 10:46:18 -07:00
Manuel Alfayate Corchete 5682b066e9 kmsdrm: Add comment about KMSDRM_VideoQuit() changes. 2020-10-22 19:51:57 +02:00
Manuel Alfayate Corchete 63b7827709 kmsdrm: properly exit with an error when ATOMIC interface is not yet available, instead of just segfaulting. 2020-10-22 19:44:38 +02:00
Manuel Alfayate Corchete a3262205b5 kmsdrm: rearrange init function so we try ATOMIC compatibility first. 2020-10-22 17:55:45 +02:00
Manuel Alfayate Corchete b1ea0be865 kmsdrm: Add missing checks after SDL_calloc() calls. 2020-10-22 17:06:34 +02:00
Manuel Alfayate Corchete ad9ec8b363 kmsdrm: Small fix, missing bracket. 2020-10-22 16:15:34 +02:00
Manuel Alfayate Corchete 87a86675ed kmsdrm: Always use spaces for indentation. Always use SDL_calloc() for calloc. 2020-10-22 16:01:51 +02:00
Ozkan Sezer cfc1362011 os2 video: updates to my_gradd.h 2020-10-21 23:28:02 +03:00
Sam Lantinga f1b603ac6a Fixed bug 5323 - SDL_SetWindowMaximumSize fails if Width or Height is equal to minimum Height or Width
batyastudios

Basicly there is problem and somewhat a solution: https://discourse.libsdl.org/t/setwindowmaximumsize-bug/28267

If you SDL_SetWindowMaximumSize() after SDL_SetWindowMinimumSize() with one of axes have the same value, function will have no effect.

This: (line 2144@SDL_video.c)
if (max_w <= window->min_w || max_h <= window->min_h) {
    SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
    return;
}

May be changed to this:
if (max_w < window->min_w || max_h < window->min_h) {
    SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
    return;
}
2020-10-20 11:51:23 -07:00
Ozkan Sezer cbadd1e380 geniconv/os2iconv.c: make it build correctly against os2tk headers. 2020-10-20 20:32:20 +03:00
Manuel V?gele 554037a6f7 audio: fix popping sounds caused by signed/unsigned conversion
When converting audio from signed to unsigned values of vice-versa
the silence value chosen by SDL was the value of the device, not
of the stream that the data was being put into. After conversion
this would lead to a very high or low value, making the speaker
jump to a extreme positon, leading to an audible noise whenever
creating, destroying or playing scilence on a device that reqired
such conversion.
2020-09-26 09:30:08 +02:00
Sam Lantinga f311e0a826 Removed debug log message 2020-10-19 17:29:16 -07:00
Yiding Jia f31ad57fde Implement keyboard repeat in wayland video driver 2020-10-05 19:17:52 -07:00
Alberts Muktup?vels 73010da4dc x11events: ignore UnmapNotify events from XReparentWindow
UnmapNotify event does not mean that window has been iconified. It
just reports that window changed state from mapped to unmapped.

XReparentWindow can unmap and remap window if it was mapped. This
causes unnecessary events - HIDDEN, MINIMIZED, RESTORED and SHOW.

These events are problematic with Metacity 3.36+ which started to
remove window decorations from fullscreen windows.

- SDL makes decorated window fullscreen
- Metacity removes decorations
- SDL gets UnmapNotify and exits from fullscreen
- Metacity re-adds decorations

As SDL will also get MapNotify event it will try to restore
window state causing above steps to repeat.

https://bugzilla.libsdl.org/show_bug.cgi?id=5314
2020-10-19 17:26:33 -07:00
Sylvain Becker ffb307e4dc Fixed bug 5304 - add SDL_HasSurfaceRLE() (Thanks Rene Dudfield and Dan Lawrence) 2020-10-18 09:52:56 +02:00
Sylvain Becker 19a65a46a6 Fixed bug 5321 - crash in SDL_ConvertSurface with RLE surfaces
keep RLE information in flags when converting the surface
2020-10-17 21:47:05 +02:00
Ozkan Sezer c70191d2b7 SDL_os2video.c (OS2_CreateDevice): remove duplicated assignment. 2020-10-17 07:37:00 +03:00
Ozkan Sezer 77d0f043e5 os2video.c: add missing FOURCC_R666 define, enable FOURCC_R666 case in _getSDLPixelFormatData(). 2020-10-16 23:50:00 +03:00
Sam Lantinga 99ed0d7ab9 Map the guide button by default on Android 11 2020-10-16 12:40:12 -07:00
Sam Lantinga 3755f6920f Added mapping for Xbox One S controller and PS4 controller on Android 11, including guide button 2020-10-16 12:40:10 -07:00
Sam Lantinga 58976bda31 Allow more than one window on iOS as long as they're on different displays 2020-10-15 12:00:15 -07:00
Ozkan Sezer a90f0400a5 os2: a _lot_ of coding style cleanup, sot that they match the SDL style.
also renamed the 'debug' macro to debug_os2: the former was dangerously
a common name.

the binary (dll) output is precisely the same as before.
2020-10-15 21:37:30 +03:00
Sam Lantinga bdc5129f13 Use a high priority dispatch queue for GCKeyboard and GCMouse events for the lowest latency possible
This appears to reduce latency between 1-4 ms on an iPad Pro.
2020-10-15 10:13:46 -07:00
Sam Lantinga a3a0ef7527 Added support for low latency mouse and keyboard handling in iOS 14
The mouse support in iOS 14.0 has a bug with accumulating duplicate mouse deltas that won't be fixed until iOS 14.1, so we don't enable it until then.
2020-10-15 10:13:44 -07:00
Sam Lantinga d9aea0c3a0 Update the existing haptic player when we rumble on iOS 2020-10-15 10:13:42 -07:00
Manuel Alfayate Corchete cca16c9cb1 kmsdrm: merge GetDisplayDPI implementation by bms20 <brett@mynah-software.com> 2020-10-15 17:56:19 +02:00
Ozkan Sezer d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Ozkan Sezer 5807cb3d31 os2: remove dependency to gradd.h from IBM's ddk which is non-free:
Add a minimal my_gradd.h containing structures and constants only used
by SDL_os2vman.c -- based on public knowledge from around the internet
including pages from http://www.osfree.org and http://www.edm2.com .
2020-10-14 23:01:06 +03:00
Ozkan Sezer b6965a1774 os2: Andrey Vasilkin agreed that his code to be put under Zlib license:
add SDL license headers to geniconv sources.
2020-10-14 23:01:05 +03:00
Ozkan Sezer 1d9cf23e4c os2: updated copyright dates for 2020. header guard fixes. 2020-10-14 23:01:05 +03:00
Ozkan Sezer a3d7913c07 SDL_os2audio.c (OS2_OpenDevice): change spec->samples assignment:
Original code assigned MCIMixSetup.ulSamplesPerSec value to it, but it
is just the freq... We now change spec->samples only either if it is 0
or we changed the frequency, by picking a default of ~46 ms at desired
frequency (code taken from SDL_audio.c:prepare_audiospec()).

With this, the crashes I have been experiencing are gone.
2020-10-14 23:01:05 +03:00
Ozkan Sezer e112b776fc SDL_os2audio.c (OS2_OpenDevice): change {0} initializers to SDL_zero() 2020-10-14 23:01:05 +03:00
Ozkan Sezer 72594e255a SDL_os2audio.c (OS2_OpenDevice): remove assignment to wrong spec member
Correct assignment to 'format' member is done below, already.
2020-10-14 23:01:04 +03:00
Ozkan Sezer fe2cc8d86c OS2_VideoQuit(): avoid double free()ing of displays.
Our caller SDL_VideoQuit() already frees display_modes, driverdata, etc.
Noticed in bitwiseworks' version at https://github.com/bitwiseworks/SDL2-os2
2020-10-14 23:01:04 +03:00
Ozkan Sezer fba32ee21f OS2_VideoInit: zero the stSDLDisplay and stSDLDisplayMode variables
Fixes testdisplayinfo.exe crashing in SDL2-2.0.13.  (How it did work before?..)
2020-10-14 23:01:04 +03:00
Ozkan Sezer 54ced668c4 port from 2.0.12 to 2.0.13 / current SDL-hg repository.
- video:  VideoBootStrap->available() is gone.
- thread: all important SDL_CreateThread internal data now put into
          struct SDL_Thread: changes to SDL_SYS_CreateThread().
2020-10-14 23:01:04 +03:00
Ozkan Sezer 5da796fe52 os/2: port from SDL2-2.0.5 to SDL2-2.0.12
- events / video: SDL_SetDoubleClickTime() removed -- functionality
         moved to SDL_mouse.c:SDL_MouseDoubleClickTimeChanged().
- video: struct SDL_VideoDevice-> CreateWindow and CreateWindowFrom
         members renamed to CreateSDLWindow and CreateSDLWindowFrom
2020-10-14 23:01:03 +03:00
Ozkan Sezer 5d89217f6b os2/SDL_sysfilesystem.c: fix crash if one of the parameters is NULL
Has been happening with testfilesystem from 2.0.6 and newer because
of commit 572a721879ef.

Also set error strings in certain error conditions.

Also applied coding style / whitespace fixes, while I was there.
2020-10-14 23:01:03 +03:00
Ozkan Sezer 222f026899 os/2: port from SDL2-2.0.4 to SDL2-2.0.5:
changes to SDL_os2audio.c, SDL_os2video.c, os2/SDL_systhread.c in order
to accomodate SDL2-2.0.5 changes.
- audio:  WaitDone() is gone, CloseDevice() interface changes.
- events / video:  DropFile() changes:
          SDL_DROPBEGIN and SDL_DROPCOMPLETE events, window IDs for drops.
- thread: struct SDL_Thread->stacksize
2020-10-14 23:01:03 +03:00
Ozkan Sezer 5f3f67b16b os2/SDL_sysfilesystem.c: use OS/2 api DosCreateDir() instead of mkdir().
mkdir() from watcom and emx differ - the latter being unix-ish, so this
change avoids ifdefs.
2020-10-14 23:01:03 +03:00
Ozkan Sezer 1b99d805db os2: updates from Andrey Vasilkin's 2020-09-07 sources. 2020-10-14 23:01:02 +03:00
Ozkan Sezer aa790837eb os2: several warning fixes.
mostly those "W007: '&array' may not produce intended result" warnings
from Watcom, visible only in C++ mode.  one or two others here & there.
2020-10-14 23:01:02 +03:00
Ozkan Sezer f9af19f51d os2: updates to SDL_systhread.c:
removed lots of garbage.  added SDL_PASSED_BEGINTHREAD_ENDTHREAD guard,
because the code requires it.
2020-10-14 23:01:02 +03:00
Ozkan Sezer c218861946 os2: added a 2-byte padding to os2 SDL_PrivateAudioData 2020-10-14 23:01:01 +03:00
Ozkan Sezer d1323eb0a9 os2: better error reporting from loadso 2020-10-14 23:01:01 +03:00
Ozkan Sezer 861ac81b37 os2: changes to debug macros 2020-10-14 23:01:01 +03:00
Ozkan Sezer 110a0f7bb1 os2: update include paths. add missing libc includes to geniconv. 2020-10-14 23:01:01 +03:00
Ozkan Sezer 74cfb81dbb os2: add port files for SDL2-2.0.4 from Andrey Vasilkin
only geniconv/iconv.h (was from LGPL libiconv) is replaced with a generic
minimal iconv.h based on public knowledge.
2020-10-14 23:01:00 +03:00
Ozkan Sezer 93e1449764 SDL_waylanddatamanager.c (mime_data_list_add): constify the buffer param
Fixes -Wdiscarded-qualifiers warnings from Wayland_data_source_add_data()
2020-10-14 15:50:04 +03:00
Sam Lantinga b9cbea354f video: Refresh Windows display list on WM_DISPLAYCHANGE
- Displays may have been added, removed or changed and all cached monitor
  handles are invalidated as a result.

- Display events are handled in three steps:
  1. Mark all currently know displays as invalid
  2. Enumerate all displays, adding new ones and marking known displays as valid
  3. Remove all displays still invalid after enumeration

- Display connect/disconnect events are sent when displays are added or removed
  after initial setup
2020-10-13 21:08:20 -07:00
Sam Lantinga a558409b2e Only include CoreHaptics if we're building with rumble support 2020-10-13 21:08:18 -07:00
Sam Lantinga 75d5be974c Fixed compiling with an older iOS SDK 2020-10-13 21:08:17 -07:00
Sam Lantinga 6b62494ee4 Added support for controller battery status on iOS 14 2020-10-13 21:08:15 -07:00
Sam Lantinga 1b31e9f6dc Added support for game controller rumble on iOS 14 2020-10-13 21:08:13 -07:00
Sam Lantinga 2d7b33cb41 Added support for the controller home button on iOS 14 2020-10-13 21:08:11 -07:00
Cameron Cawley 59022829f4 riscos: Implement SDL_OpenURL() 2020-10-11 17:32:32 +01:00
Ozkan Sezer 34a82fca49 SDL_cpuinfo.c (OS2): undefine HAVE_SYSCTLBYNAME 2020-10-10 20:50:02 +03:00
Sam Lantinga b546db2f85 Only watch for display connect/disconnect events while the video subsystem is initialized 2020-10-09 12:58:28 -07:00
Ozkan Sezer 7991cc38bc dynapi: move SDL_SIMDRealloc down below, after SDL_GetPreferredLocales.
https://hg.libsdl.org/SDL/rev/884cb29cb80e  wrongly added it after its
family i.e. SDL_SIMDAlloc, not at the end of the list.
2020-10-09 21:40:28 +03:00
Ryan C. Gordon b79832ba11 cocoa: Cut and paste from HTML strikes again! 2020-10-08 21:11:09 -04:00
Ozkan Sezer 19aaa2944d Fix https://bugzilla.libsdl.org/show_bug.cgi?id=5306
(Also see: https://bugzilla.libsdl.org/show_bug.cgi?id=4822)

Building the current tree against 10.8 SDK, clang emits the following warning:
src/video/cocoa/SDL_cocoawindow.m:1846:27: warning: instance method '-isOperatingSystemAtLeastVersion:' not found (return type defaults to 'id') [-Wobjc-method-access]
            ![processInfo isOperatingSystemAtLeastVersion:version]) {
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/MacOSX10.8.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSProcessInfo.h:20:12: note: receiver is instance of class declared here
@interface NSProcessInfo : NSObject {
           ^
1 warning generated.

isOperatingSystemAtLeastVersion is an 10.10 thing.
2020-10-09 04:00:00 +03:00
Ozkan Sezer 69fbd60d25 Fix https://bugzilla.libsdl.org/show_bug.cgi?id=4877#c2
loadNibNamed:owner:topLevelObjects is available on 10.8 and newer.
There is an issue report here about an app failing to function on
10.7 and earlier: https://discourse.libsdl.org/t/28179
2020-10-09 04:00:00 +03:00
Sam Lantinga bd14f2676c Removed unused variable 2020-10-08 16:58:34 -07:00
Ozkan Sezer d86a746542 SDL_video.c: fix whitespace 2020-10-09 02:55:00 +03:00
Sam Lantinga 76980e30f2 Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
Sam Lantinga cd703b5628 Fixed whitespace 2020-10-08 16:41:48 -07:00
Ozkan Sezer 54bb9aaccb k_rem_pio2.c: fix typo in second memset(): iq, not q. fixes bug #5309. 2020-10-08 11:51:02 +03:00
Ryan C. Gordon 061256a3b3 metal: Clear the framebuffer if presenting without any other operations. 2020-10-07 14:45:24 -04:00
Ryan C. Gordon 003a16980c wav: Make sure the data size is a multiple of blockalign, not an exact match.
I _think_ this is a right thing to do; it fixes a .wav file I have here that
has blockalign==2 when channels==2 and bitspersample==16, which otherwise
would fail.
2020-10-06 11:07:50 -04:00
Ryan C. Gordon 4627426994 url: WinRT actually works now (and has been tested, hooray!). 2020-10-06 00:42:17 -04:00
Ryan C. Gordon fc05a696ad url: Attempt #23235 at WinRT support... 2020-10-05 18:08:58 -04:00
Ryan C. Gordon 02addf135d url: Another attempt at WinRT implementation. 2020-10-05 18:01:47 -04:00
Ozkan Sezer 1f4b5d54ca windows/SDL_syslocale.c: make it build against older SDKs. 2020-10-06 00:20:20 +03:00
Ryan C. Gordon 7bec9df11a url: Add to Xcode project files, iOS/mac fixes. 2020-10-05 16:10:10 -04:00
Ryan C. Gordon 57e3003d3f url: Attempt at WinRT support. 2020-10-05 15:47:47 -04:00
Ryan C. Gordon 566479c8ef url: ShellExecuteW returns an HINSTANCE, so deal with that more correctly. 2020-10-05 15:37:37 -04:00
Ryan C. Gordon ee56090d3d url: Cleanups and compiler warning fixes. 2020-10-05 15:03:44 -04:00
Ryan C. Gordon cc158f2983 url: removed "extern" from function declaration. 2020-10-05 14:36:37 -04:00
Ryan C. Gordon a3802cc533 url: Patched to compile on C89 compilers. 2020-10-05 14:30:33 -04:00
Ryan C. Gordon 0099e38a9a url: More win32 fixes. 2020-10-05 14:21:03 -04:00
Ryan C. Gordon 1f4fecc5c1 url: Patched to compile on Windows. 2020-10-05 14:07:32 -04:00
Ryan C. Gordon 777d0f19f8 url: patched to compile on macOS. 2020-10-05 14:06:25 -04:00
Ryan C. Gordon d068d05aa5 url: Make sure Haiku's C++ implementation is flagged as 'extern "C"' 2020-10-05 14:01:08 -04:00
Ryan C. Gordon bf9fcb539a url: The function is "SDL_Unsupported" not "SDL_Unimplemented" 2020-10-05 14:00:08 -04:00
Ryan C. Gordon 2d82cf78e1 url: put the Android bits in core/android 2020-10-05 13:59:03 -04:00
Ryan C. Gordon efd665e2c7 Backed out changeset a43cb4e54949
Trying this a different way.
2020-10-05 13:56:45 -04:00
Ryan C. Gordon 913aa610b5 url: Include SDL_misc.h to get public function declaration. 2020-10-05 13:53:15 -04:00
Ryan C. Gordon 5f68812249 url: patched to compile on Android. 2020-10-05 13:52:52 -04:00
Ryan C. Gordon 84f1b95008 url: fixed wrong include. 2020-10-05 13:39:39 -04:00
Ryan C. Gordon 77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
Sylvain Becker cd6670bff3 SDL_Surface refcount: fix memory leak when blitting between stack'ed surfaces
(see bug 5226)
2020-10-02 10:48:27 +02:00
Ozkan Sezer 883509fc84 ran gendynapi.pl after new (android-only) api additions. 2020-10-01 17:01:00 +03:00
Sylvain Becker dd55bfe89c Android: add helper function to open an URL/URI (see bug 2783) 2020-10-01 14:41:09 +02:00
Sam Lantinga 45c644cc99 Added support for the MOGA XP5-X Plus 2020-09-28 21:19:45 -07:00
Manuel Alfayate Corchete 78c274cb5d kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments. 2020-09-26 19:18:09 +02:00
Sylvain Becker 955f3184f9 Fixed bug 5239 - Play audio on Android while backgrounded (Thanks Superfury)
Add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO not to pause audio when
the app goes to background.
(It requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
2020-09-25 10:14:42 +02:00
Ryan C. Gordon 7ef188a1fb jack: Fixed memory leak on device close. 2020-09-19 14:01:57 -04:00
Cameron Gutman 9a769da04a X11: Remove our X11 error callback in X11_DeleteDevice()
If we don't remove it, we will infinitely recurse if X11_CreateDevice() is
called again and orig_x11_errhandler becomes X11_SafetyNetErrHandler().
2020-09-07 20:10:50 -07:00
Manuel Alfayate Corchete 9c342e76dd kmsdrm: merge heap buffer overflow and cursor creation patches from meyraud705. 2020-09-13 21:41:10 +02:00
Manuel Alfayate Corchete 0cb9bfa502 kmsdrm: less excessive error checkhing 2020-09-12 15:58:47 +02:00
Manuel Alfayate Corchete 5bed30dd61 kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered(). 2020-09-12 04:56:55 +02:00
Manuel Alfayate Corchete 9e9227add3 kmsdrm: reimplement modesetting for fullscreen window scaling and AR-correction. 2020-09-12 04:52:56 +02:00
Manuel Alfayate Corchete 4575c6942a kmsdrm: delete ununsed variable. 2020-09-12 02:36:02 +02:00
Manuel Alfayate Corchete 01b0cf1c90 Backed out changeset 4a45d1a30d25
kmsdrm: Fake KMSDRM_SetDisplayMode() is needed for some programs after all.
2020-09-12 00:47:00 +02:00
Manuel Alfayate Corchete 7b67654872 kmsdrm: don't fool SDL into thinking that changing the physical videomode is done. 2020-09-12 00:16:08 +02:00
Manuel Alfayate Corchete a6d182d326 kmsdrm: no need to reconnect/reactivate things in SwapWindowDoubleBuffered(). 2020-09-11 23:47:26 +02:00
Manuel Alfayate Corchete 47e2d0304e kmsdrm: greatly improve comments in SwapBuffersFenced() for future reference. 2020-09-10 23:26:02 +02:00
Ryan C. Gordon 3c6004feb7 kmsdrm: Choose how to swap buffers based on EGL extension availability. 2020-09-10 15:07:23 -04:00
Ryan C. Gordon c7e761f872 kmsdrm: Patched to compile if EGL headers lack EGL_ANDROID_native_fence_sync. 2020-09-10 15:05:55 -04:00
Ryan C. Gordon 224aa45b59 kmsdrm: Implement GL_DefaultProfileConfig for Raspberry Pi compatibility.
If we think this might be a Raspberry Pi device, default to ES2. Otherwise,
accept SDL's higher-level defaults.
2020-09-10 15:04:35 -04:00
Ryan C. Gordon 092162ede7 video: Set up default before calling GL_DefaultProfileConfig().
This way, the implementation can opt to do nothing to accept SDL's defaults.
2020-09-10 15:02:51 -04:00
Ryan C. Gordon e758dd53dc egl: Make SDL_EGL_HasExtension() available outside of SDL_egl.c. 2020-09-10 15:02:00 -04:00
Manuel Alfayate Corchete 055cad49b6 kmsdrm: no need to re-connect/reactivate things in SwapWindow() anymore because we use a dumb buffer on KMS buffers destruction now. 2020-09-10 02:15:53 +02:00
Manuel Alfayate Corchete 351219bfd8 kmsdrm: On VideoQuit(), only destroy dumb buffer if it exists. 2020-09-09 03:18:26 +02:00
Sam Lantinga 8709f67ebc Fixed bug 5215 - Fixing filenames passed to dlopen for OpenBSD
Brad Smith

Attached is a patch to use the proper filenames when trying to dlopen the respective shared libraries on OpenBSD.
2020-09-08 08:42:30 -07:00
Cameron Gutman 1b6de9a987 Fix SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH=1 on Metal windows
SDL_cocoametalview was consuming the first click rather than passing it
through to the SDLView underneath which overrides [NSView acceptsFirstMouse]
based on the user's SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH preference.
2020-09-05 15:01:45 -07:00
Manuel Alfayate Corchete 244d0ad854 kmsdrm: Tell SDL that mouse has entered the window via artificial event. Fixes sticky mouse in Scummvm. 2020-09-08 15:30:45 +02:00
Manuel Alfayate Corchete 550e153365 kmsdrm: No need to test for display driverdata when freeing a plane. 2020-09-08 02:42:32 +02:00
Manuel Alfayate Corchete 6e03fab982 kmsdrm: add temporary RPI4_COMPAT define to try RPI4+current Rasbian compatibility. 2020-09-07 23:15:33 +02:00
Manuel Alfayate Corchete 0f807fd607 kmsdrm: use a black dumb buffer for keeping the PRIMARY PLANE occupied when we destroy the KMS buffers, instead of using the TTY buffer, to avoid flickering. 2020-09-07 22:54:15 +02:00
Sylvain Becker 4d1c2a1857 Fix false compiler warning: initialize the variable 'memdiff' 2020-09-07 19:00:21 +02:00
Sylvain Becker ebc12a2fd2 SDL_Surface refcount: destination surface keep track of surfaces
that are mapped to it and automatically invalidate them when it is freed

- refcount is kept so that an external application can still create a reference
to SDL_Surface.

- lock_data was un-used and is now renamed and used as a list keep track of the blitmap
2020-09-07 18:50:30 +02:00
Manuel Alfayate Corchete cce6c60518 kmsdrm: fix errors when trying to free up videomode driverdata pointers on quit. 2020-09-07 01:33:04 +02:00
Manuel Alfayate Corchete 9501b1c698 kmsdrm: fix scaling for SDL_WINDOW_FULLSCREEN windows. 2020-09-07 00:18:13 +02:00
Manuel Alfayate Corchete daa752b10e kmsdrm: fix first frame display: no need to wait for SwapWindow() for EGL surface creation. 2020-09-06 23:19:54 +02:00
Manuel Alfayate Corchete 68ac9349aa kmsdrm: more coherent returns for SwapWindow. 2020-09-06 12:48:39 +02:00
Manuel Alfayate Corchete d3d9d432ac kmsdrm: Remove debug printfs in SwapWindow. 2020-09-06 12:17:27 +02:00
Manuel Alfayate Corchete d7aebbd58f kmsdrm: Don't create surfaces until EGL context is available. 2020-09-06 12:08:22 +02:00
Sylvain Becker 97fad04551 Fixed bug 5278 - export SDL_AndroidRequestPermission() (Thanks Huki!) 2020-09-02 19:38:03 +02:00
Manuel Alfayate Corchete f4e02a5c1b kmsdrm: Do NOT modify window size manually from the backend: doing so caused renderer scaling params miscalculation. 2020-08-31 19:17:17 +02:00
Manuel Alfayate Corchete c09d1cee95 kmsdrm: Apply window reconfiguration in SetWindowSize(), too. 2020-08-28 23:04:00 +02:00
Manuel Alfayate Corchete 31b1794534 kmsdrm: use PLANE and CRTC to do hardware-driven window scaling and AR-correction. 2020-08-28 22:38:26 +02:00
Manuel Alfayate Corchete fe3f97961b kmsdrm: unload EGL and GL lib only if using them. 2020-08-26 01:37:30 +02:00
Manuel Alfayate Corchete 9b43464d81 kmsdrm: Add programmer credits to the Atomic KMSDRM driver. 2020-08-25 16:30:23 +02:00
Manuel Alfayate Corchete 9316a8d979 kmsdrm: move FENCE FD props setting to SwapWindow(), where it belongs. 2020-08-25 16:18:49 +02:00
Manuel Alfayate Corchete 3f38009b2f kmsdrm: comment out atomic commit fast-debugging printf. 2020-08-25 15:40:36 +02:00
Manuel Alfayate Corchete 0d16761cbe kmsdrm: fix segfault on quit beacuse of freed _this->egl_data. 2020-08-25 05:53:13 +02:00
Manuel Alfayate Corchete d43e666eed kmsdrm: Buffer management refactoring. Fixes for compatibility with more video drivers. 2020-08-25 04:05:36 +02:00
Manuel Alfayate Corchete eade05ca03 kmsdrm: Finetune integer type usage. Add some comments. 2020-08-24 12:51:20 +02:00
Manuel Alfayate Corchete a76f176361 kmsdrm: Move cursor plane setup and freeing to MouseInit() and MouseQuit(), for better consistency. 2020-08-24 01:10:11 +02:00
Manuel Alfayate Corchete 0d593d7ead kmsdrm: Add error control to plane prop setting function. Do most plane prop setting with a single function. 2020-08-23 23:44:07 +02:00
Manuel Alfayate Corchete e06e9c35c8 kmsdrm: move cursor-related atomic helper functions and related struct typedefs to the SDL_kmsdrmmouse unit. 2020-08-23 11:26:55 +02:00
Manuel Alfayate Corchete 0b7b7721b9 kmsdrm: remove redundant function, use drm_atomic_setbuffers() for disconnecting planes instead. 2020-08-23 03:13:50 +02:00
Manuel Alfayate Corchete 16c04f266a kmsdrm: Init cursor surface on SetCursor() ONLY. Removal of dynamic modeset because it causes A LOT of problems with some kernel video drivers. Some refactoring and cleanups. 2020-08-23 02:58:57 +02:00
Manuel Alfayate Corchete 0d0ba111ae kmsdrm: correct parameter name. 2020-08-19 01:34:56 +02:00
Manuel Alfayate Corchete 5d32eda956 kmsdrm: implement smarter surface recreation function to be used in videomode changes. Other minor arrangements. 2020-08-19 01:31:22 +02:00
Manuel Alfayate Corchete f79da81721 kmsdrm: free all connector, crtc and plane memory on KMSDRM_VideoQuit(). 2020-08-18 01:52:15 +02:00
Sylvain Becker 965b466ee8 Fixed bug 4297 - Android StrictMode policy. Remove APK expansion support
"In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play"
(see https://developer.android.com/guide/app-bundle)
And "Android App Bundles don't support APK expansion (*.obb) files".
2020-08-17 19:50:20 +02:00
Manuel Alfayate Corchete 92cb9192e3 kmsdrm: move hardware cursor functionality to the ATOMIC interface. Disconnect the display plane from the GBM surface buffers before destroying the GBM surface. 2020-08-17 18:35:04 +02:00
Kai Krakow c3ecf18cc4 Linux: Add hint for disabling deadzones 2020-07-21 23:38:42 +02:00
Tudor Brindus c094332825 wayland: defer pointer confine creation until pointer unlock
It is a protocol error to attempt to create a pointer confine (i.e.
`SDL_SetWindowGrab`) while a locked pointer is active, and vice-versa.
Instead of aborting due to a protocol error, this commit makes SDL
gracefully downgrade locked pointers to confines when appropriate.
2020-07-21 13:14:24 -04:00
Ryan C. Gordon a720d1a294 render: fixes to how we convert touch events for logical scaling.
We now handle HiDPI correctly, and touches are clamped to the viewport. So
if you are rendering to a logical 640x480 in a 720p window, and touch the
letterboxing at point (640,700), it will report the touch at (0.5,1.0) instead
of outside the documented range.
2020-08-09 00:55:39 -04:00
Manuel Alfayate Corchete c437729b21 kmsdrm: separate requests in different functions so we only need one atomic commit for everything, as expected by atomic design. 2020-08-08 14:27:55 +02:00
Manuel Alfayate Corchete 3b9f1073c6 kmsdrm: wait for possible pending atomic commits before destroying surfaces, and before restoring video on quit. Move messages to the SDL_Log* functions. 2020-08-07 11:53:04 +02:00
Manuel Alfayate Corchete 96c99693a2 kmsdrm: wait for pending atomic commits before restoring videomode and crtc->buffer on VideoQuit, and simplify double-buffer SwapWindow() implementation. 2020-08-06 01:36:56 +02:00
Manuel Alfayate Corchete 09692b6170 kmsdrm: move videomode restoration on VideoQuit() to using the atomic interface instead of the legacy drmModeSetCrtc() function. Refactoring of get_plane_id(). 2020-08-05 18:55:22 +02:00
Manuel Alfayate Corchete fc722b2d21 kmsdrm: free memory for plane, crtc and connector property tables on VideoQuit. 2020-08-05 15:28:51 +02:00
Manuel Alfayate Corchete 2d69ce08ba kmsdrm: double and triple buffered versions of SwapWindow() are now both reimplemented in atomic pageflipping versions, and can be selected via SDL_VIDEO_DOUBLE_BUFFER env variable. 2020-08-05 02:06:59 +02:00
Manuel Alfayate Corchete 8996ee1786 kmsdrm: update SwapWindow fn, moving it to triple-buffer. 2020-08-03 22:24:49 +02:00
Ryan C. Gordon ea171c0564 winrt: Another attempt at getting this to compile.
IntPtr isn't a POD type like I thought, so hopefully we can just construct
one that works out? C++/CX is so weird.
2020-08-01 18:58:42 -04:00
Manuel Alfayate Corchete b131661c6d kmsdrm: rewrite the new SwapWindow() fn to avoid tearing. Double-buffer only for now. 2020-08-01 18:23:34 +02:00
Ryan C. Gordon 282e4c65bf winrt: Patched to compile...?
Microsoft's C++/CX is weird, no idea if this will actually fix it.  :/
2020-07-31 19:42:23 -04:00
Manuel Alfayate Corchete 1a5503ce9f kmsdrm: Moved to the ATOMIC KMS/DRM interface for buffer swapping, leaving DRM-legacy behind. 2020-07-28 21:11:25 +02:00
Ryan C. Gordon e410b34f92 stdlib: Corrected implementation of SDL_wcsncmp.
It was a copy/paste of SDL_strcmp, apparently, not SDL_strncmp, so it ignored
the maxlen parameter.

Thanks to Jack Powell for pointing this out!
2020-07-24 22:24:03 -04:00
RALOVICH, Kristof c7eb557d89 kmsdrm: do not leak drmModeConnector
Previously conn was leaked on the success path (when available was
set to SDL_TRUE).
2020-07-20 10:09:07 -07:00
Manuel Alfayate Corchete 412b21b0e8 Rename the gbm device struct from gbm to gbm_dev for better readabilty. 2020-07-20 11:42:23 +02:00
RALOVICH, Kristof 155fdc7ac0 kmsdrm: settle with first card that has a connected connector
Previously the first card with non-empty connectors, encoders
and crtcs would be selected, however KMSDRM_VideoInit could still reject
it if the connector was not connected. This allow finding the first card
(in a multi GPU setup) that is actually connected to a display.
2020-07-19 21:48:17 -04:00
RALOVICH, Kristof b78b88f7fb kmsdrm: fix typo 2020-07-19 21:46:41 -04:00
Manuel Alfayate Corchete 75fe4b14e3 Added comment about window creation behaviour in KMSDRM. 2020-07-19 19:53:57 +02:00
Manuel Alfayate Corchete 2f660c4fdd Delete windata variable no longer needed in KMSDR_SetDisplayMode(). 2020-07-19 19:11:02 +02:00
Manuel Alfayate Corchete 3a1d7d9c9a Surfaces have to be recreated immediately from KMSDRM_SetDisplayMode(). 2020-07-19 19:09:15 +02:00
Manuel Alfayate Corchete b6a818b6a2 Fix SDL_Window recreation: drmModeSetCrtc() has to be called everytime the EGL and GBM surfaces are recreated. 2020-07-19 18:45:29 +02:00
Sam Lantinga 71e9df99c7 Fixed bug 5231 - Fix for hardware cursor: size and alpha-premultiplication.
Manuel Alfayate Corchete

I noticed pt2-clone had problems with it's optional hardware mouse on the KMSDRM backend: cursor had a transparent block around it.
So I was investigating and it seems that a GBM cursor needs it's pixels to be alpha-premultiplied instead of straight-alpha.
A
lso, I was previously relying on "manual testing" for the cursor size, but it's far better to use whatever the DRM driver recommends via drmGetCap(): any working driver should make a size recommendation via drmGetCap(), so that's what we use now. I took this decision because I found out that the AMDGPU driver reported working cursor sizes that would appear garbled on screen, and only the recommended cursor size works.
2020-07-19 08:55:01 -07:00
Ryan C. Gordon b7a4fdd318 metal: Make sure we have a command buffer available before trying to present.
This fixes a case where you render to the backbuffer, then render to a render
target, set the current target back to the backbuffer, and then present
without drawing anything else; in this circumstance, the Present command
would never happen.

Fixes Bugzilla #5011.
2020-07-17 11:16:35 -04:00
Ryan C. Gordon b5affd12e6 Patched to compile. 2020-07-16 13:28:59 -04:00
Ryan C. Gordon 3b38e61a7d winrt: Fix casting a pointer to int.
Fixes Bugzilla #5202.
2020-07-16 13:25:50 -04:00
Ryan C. Gordon 8babda2c20 egl: SDL_EGL_LoadLibaryOnly() shouldn't set _this->gl_config.driver_loaded = 1
This is handled in in the higher-level SDL_GL_LoadLibrary().

All uses of SDL_EGL_LoadLibrary (which calls the Only version) are just
target-specific wrappers for their own GL_LoadLibrary hook, with two
exceptions which now handle driver_loaded correctly (although it's
questionable if these init-if-no-one-did-it-correctly-already code blocks
should exist at all, fwiw).

Fixes Bugzilla #5190.
2020-07-16 13:18:19 -04:00
Sam Lantinga cab1a715f5 Fixed bug 5233 - PS3 Gamepad Motion Control not correctly ignored on Linux
Igor Morgado

PS3 Controller motion sensor string is being reported as

`Gasia Co.,Ltd PS(R) Gamepad Motion Sensors`

But `src/joystick/SDL_gamecontroller.c` line1690 only ignores if matches the string  `Controller Motion Sensors`.

```
#if defined(__LINUX__)
    if (name && SDL_strstr(name, "Controller Motion Sensors")) {
        /* Don't treat the PS3 and PS4 motion controls as a separate game controller */
        return SDL_TRUE;
    }
#endif
```

Therefore, SDL is mapping 2 Game controllers instead one.

Maybe reduce the substring to match `Motion Sensors` instead.


A simple log from my application is shown below:

INFO: Game controller device 0 - PS3 Controller:PS3 Controller found.
INFO: Controller 0: Player 0: 054c:0268:8111 - PS3 Controller - PS3 Controller - Gasia Co.,Ltd PS(R) Gamepad
INFO: Game controller device 1 - PS3 Controller:PS3 Controller found.
INFO: Controller 1: Player 1: 054c:0268:8111 - PS3 Controller - PS3 Controller - Gasia Co.,Ltd PS(R) Gamepad Motion Sensors
2020-07-15 10:15:52 -07:00
M Stoeckl a78b9763f1 Reuse Wayland connection from availability check 2020-07-14 19:18:16 -04:00
M Stoeckl 8669a87f05 Reuse X11 connection from availability check
Instead of creating an X11 connection to test that X11 is available,
closing the connection, and then reconnecting for real, use the same
connection to handle both cases.

The X11 connection retry delay mechanism in the case where X11 is
dynamically loaded has been removed. It was only necessary to avoid
authetnication token reuse from the XOpenDisplay call that used to
exist in X11_Available. Now that this call is only made once, it
is no longer needed.

Also drop unused and inapplicable code from a comment.
***
2020-07-14 21:13:27 -04:00
M Stoeckl 052a13738d Merge VideoBootStrap::available into VideoBootStrap::create
The two are only ever called together, and combining them makes it possible
to eliminate redundant symbol loading and redundant attempts to connect
to a display server.
2020-07-12 19:11:15 -04:00
Ozkan Sezer 49ec65587a fix bug #5228 -- Add AltiVec detection for FreeBSD.
thanks Piotr Kubaj.
2020-07-11 08:10:02 +03:00
stfx b162629546 cmake: Fix building with -DSDL_HAPTIC=Off 2020-07-08 17:28:34 +02:00
Ryan C. Gordon 0e98040d43 joystick: Linux joysticks now recover better from dropped events.
Fixes Bugzilla #4830.
2020-06-28 16:23:05 -04:00
Sylvain Beucler e594a6738a emscripten: Introduce SDL_HINT_EMSCRIPTEN_ASYNCIFY
See https://github.com/emscripten-core/emscripten/issues/10746

and

https://github.com/emscripten-ports/SDL2/pull/112

Fixes Bugzilla #4997.
2020-06-27 16:25:47 -04:00
Sylvain Beucler 01af7b0254 emscripten: support pseudo-synchronous screen refresh and events update using asyncify 2020-06-27 16:22:50 -04:00
Ryan C. Gordon 694fea8ad8 video: Make SDL_CreateWindow use SDL_Init(SDL_INIT_VIDEO), not SDL_VideoInit.
Otherwise, the video subsystem won't deinitialize during SDL_Quit().

Fixes Bugzilla #5067.
2020-06-26 21:37:29 -04:00
Ryan C. Gordon 1947ca7028 video: Changed SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS to default to FALSE.
Fixes Bugzilla #5106.  (and probably many others, too!)
2020-06-26 20:16:43 -04:00
Sam Lantinga ce293eed8d Fixed bug 5208 - Fix libGL loading on OpenBSD 2020-06-23 10:12:24 -07:00
Sam Lantinga c2b8530591 Fixed bug 5209 - cpuinfo recognize OpenBSD ARM
Brad Smith

OpenBSD/arm only supports ARMv7 and and not any CPUs that do not support NEON.
2020-06-23 10:09:29 -07:00
Ozkan Sezer 4ba0a84718 core/linux/SDL_threadprio.c: fix build against older glibc versions 2020-06-22 23:24:02 +03:00
Sam Lantinga b9f55b6d80 Fixed bug 5199 - Fix KMSDRM_CreateWindow() segfault when starting L?VE2D engine.
Manuel Alfayate Corchete

This small patch fixes the KMSDRM_CreateSurfaces() call in KMSDRM_CreateWindow(), that was segfaulting deeper into SDL internals because the windata->viddata pointer wasn't set before the KMSDRM_CreateSurfaces() call.
So that's what this small patch does.

Now, L?VE2D works perfectly well on the Raspberry Pi 3, instead of just segfaulting.
2020-06-19 10:37:14 -07:00
Sam Lantinga 56622f9c92 Fixed bug 5126 - MinGW compile error SDL_windowssensor.c
Martin Gerhardy

SDL_windowssensor.c includes InitGuid.h - but it should be initguid.h
2020-06-17 10:09:07 -07:00
James Legg f1d5ced167 x11: Fix spurious keyboard focus events 2020-06-17 12:48:40 +01:00
Sam Lantinga 48989e2a87 Reverted comment change in previous commit 2020-06-17 08:47:27 -07:00
Sam Lantinga a7ff6e9615 Fixed overflow in surface pitch calculation 2020-06-17 08:44:45 -07:00
stfx efe0935904 Fix compile without DIRECTX 2020-06-15 10:31:16 +02:00
Ozkan Sezer 163896543f fix watcom build of SDL_test_common.c 2020-06-14 12:05:56 +03:00
Ethan Lee 2aa8974f97 Add SDL_SIMDRealloc 2020-06-11 12:03:33 -04:00
Sam Lantinga 20aada0efc Fixed bug 5170 - Build fails when using Visual Studio 2017 with Windows 10 SDK 10.0.19041.0 in uwp
JackBoosY

In src/video/winrt/SDL_winrtgamebar.cpp line 55:

    virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
        __FIEventHandler_1_IInspectable *handler,
        Windows::Foundation::EventRegistrationToken *token) = 0;

The macro __FIEventHandler_1_IInspectable defined in windows.fondation.h(Windows10 SDK 10.0.17763.0) line 3576:
#define __FIVector_1_Windows__CFoundation__CPoint ABI::Windows::Foundation::Collections::__FIVector_1_Windows__CFoundation__CPoint_t

but no longer exists in Windows 10 SDK 10.0.19041.0.
After searching this macro in the sdk include path, I found that it was defined in many header files. But it should be replaced in windows.system.h .
2020-06-10 09:38:43 -07:00
Sam Lantinga 44f50c647e Fixed bug 5171 - PollEvent impacts performance in 2.0.12
On some systems, GetClipCursor() impacts performance when called frequently, so only call it every once in a while to make sure we haven't lost our capture.
2020-06-09 21:47:41 -07:00
Sam Lantinga 511a9702fc Fixed whitespace 2020-06-09 21:43:00 -07:00
Sam Lantinga aefe19ff08 Added support for the NACON Revolution Pro Controller 3 and the GameStop PS4 Fun Controller 2020-06-09 11:31:39 -07:00
Sam Lantinga 6f241bd520 Fixed build 2020-06-09 10:47:29 -07:00
Sam Lantinga 086be21e7a ControllerList: add support for NACON asymetric controller and Revolution 3, Hori mini wireless ps4 controller, and 2 PDP switch controllers 2020-06-09 10:47:27 -07:00
Sam Lantinga 3b76109f64 ControllerList: remove giotek controller from list - vid/pid appears to be reused in bunch of devies including ones with different fw/protocol and treating as ps4 controller breaks them. 2020-06-09 10:47:25 -07:00
Sam Lantinga a9cfac3835 Controller: Deadzone improvements 2020-06-09 10:47:23 -07:00
Sam Lantinga 9fa8d6d0be Define constants not available on older kernels 2020-06-08 17:07:55 -07:00
Sam Lantinga 3ac24bfc1a Fixed mouse drag with an external mouse on iOS 2020-06-08 17:01:50 -07:00
Sam Lantinga ff53521bc6 Fixed Bluetooth audio output on Apple TV 2020-06-04 12:26:57 -07:00
Sam Lantinga cced5eb937 Fixed bug 5169 - Can not build current sources because of recent thread management changes
Manuel Alfayate Corchete

I'm trying to build SDL2 with threads support here in GNU/Linux, both X86 and ARM, and it does not seem to be possible ATM:


/home/manuel/src/SDLLLL/src/core/linux/SDL_threadprio.c:233:26: error: 'rtkit_max_realtime_priority' undeclared (first use in this function)
2020-06-04 09:23:18 -07:00
Sam Lantinga 958c42827c Fixed build warning 2020-06-04 09:13:49 -07:00
Ryan C. Gordon 60435712f2 video: Set window->surface NULL after freeing it.
Otherwise, when SDL_CreateWindowFramebuffer() is called again, it will return
the free'd surface instead of creating a new one.
2020-06-03 16:42:19 -04:00
Sam Lantinga eea0b0e088 Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen
meyraud705

Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
2020-06-02 17:08:31 -07:00
Cameron Gutman 134362e745 Enable Xbox One HIDAPI driver on macOS
The Xbox One HIDAPI driver is required on macOS for Xbox One S Bluetooth
support since https://hg.libsdl.org/SDL/rev/10c3a10908e9
2020-04-25 19:15:51 -07:00
Sam Lantinga ac1f174ad5 Fixed bug 5167 - Memory leak in GuessXInputDevice
meyraud705

Variable 'devices' is not freed if function GuessXInputDevice, in SDL_xinputjoystick.c, return early.
2020-06-02 17:02:37 -07:00
Sam Lantinga d48c97c4a4 Fixed bug 5147 - KMSDRM: SetWindowFullscreen() failing with SDL_WINDOW_FULLSCREEN_DESKTOP
Manuel Alfayate Corchete

This patch is needed so programs that do this work as expected:
1) Start in a different video mode than the mode used by the system and then...
2) Try to go fullscreen with the mode originally used by the system via SetWindowFullScreen() with the SDL_WINDOW_FULLSCREEN_DESKTOP flag.

An example would be pt2-clone in https://github.com/8bitbubsy/pt2-clone.
This program does this:

Starts with:

video.window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
    SDL_WINDOWPOS_CENTERED, screenW, screenH, windowFlags);


and then, *IF* the user has configured it in fullscreen mode in its .ini, it tries to go fullscreen with the desktop mode:

SDL_SetWindowFullscreen(video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);


This sequence of operations is currently failing because SDL_SetDisplayModeForDisplay() in SDL_video.c fails because display->desktop_mode is not being initialized with its correct value: SetDisplayMode() in SDL_kmsdrmvideo.c will not be able to set the mode because it detects the mode to have a driverdata of 0x0 ("if (!modedata)") and rightfully returns an error.

So, the included patch fixes this small problem, and programs that first change the video mode and then try to go fullscreen with the system video mode will now work.
The patch simply fixes an small omission, but its really needed now that dynamic video mode changing was implemented on the KMSDRM backend.
2020-06-02 16:57:20 -07:00
Sam Lantinga 9325b22ef0 Fixed bug 5113 - SDL_UpdateWindowSurfaceRects BitBlt the entire surface on Win32
Ryan C. Gordon

As discussed here:
https://discourse.libsdl.org/t/question-about-implementation-of-sdl-updatewindowsurfacerects/27561

"As you can see this function [WIN_UpdateWindowFramebuffer, in src/video/windows/SDL_windowsframebuffer.c] calls BitBlt on entire screen, even though it accepts the rects. Rects variable is not even used in this function at all. Now my question is why is that the case?"
2020-05-29 21:26:32 -07:00
Sam Lantinga d000c1cd6d Fixed bug 5155 - HIDAPI_JoystickDisconnected incorrect array shift
Anthony Pesch

I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward.

The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
2020-05-29 21:22:11 -07:00
Cameron Gutman 77b0dad271 cocoa: Change Caps Lock behavior to toggle instead of locking
It currently behaves like a locking key which is pressed
when Caps Lock is enabled and released when disabled. This
means that apps that trigger events on Caps Lock key down will
only fire these events every other time Caps Lock is pressed.
2020-05-25 20:55:29 -07:00
Sam Lantinga bdfd1b68ba Fixed bug 5146 - SDL_RenderFillRect doesn't work in DirectFB
Lacky

It looks like refactoring of SDL2 internal API has broken SDL_RenderFillRect for DirectFB. In new version function SDL_RenderFillRect returns 0, but rectangle is not visible.

Replacing "count" with "len" in the argument list for SDL_memcpy in DirectFB_QueueFillRects fixes problem.
2020-05-29 16:02:49 -07:00
Tudor Brindus a6ca61d732 wayland: update pointer position on initial enter event 2020-05-21 00:06:09 -04:00
Sam Lantinga ae9ff11bae The zero happens at a higher level now 2020-05-29 14:54:07 -07:00
Sam Lantinga 39c958bbaa Initialize the raw_map before getting controller mappings from the driver 2020-05-29 14:48:39 -07:00
Sam Lantinga 2db049473b Fixed variable names to be consistent across functions 2020-05-29 14:48:05 -07:00
Sam Lantinga 345b4d7e14 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification
Jan Bujak

I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL.

Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this:

https://www.kernel.org/doc/html/v4.15/input/gamepad.html

Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments.

Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.)

With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
2020-05-29 13:37:21 -07:00
James Legg e2dbed9cfe SDL_blit: Fix undefined bitshift operations
Arithmatic operations promote Uint8 to signed int. If the top bit of a
Uint8 is set, and it is left shifted 24 places, then the result is not
representable in a signed 32 bit int. This would be undefined behaviour
on systems where int is 32 bits.
2020-05-29 13:05:37 +01:00
Brendan Shanks 032fa681a8 Add Logitech G29 to steering wheel list 2020-04-24 14:03:30 -07:00
Ryan C. Gordon aa259ed52d wayland: Changed output removal in handle_surface_leave()
No longer needs an extra malloc, handles unexpected cases like the same
output being listed twice.
2020-05-28 15:18:41 -04:00
Ryan C. Gordon ce7ae4ec8d wayland: Move buffer copy into mime_data_list_add()
It makes it clearer who owns the memory, and more reasonable to free it on
failure in the creating function.

(and, of course, pacifies static analysis.)
2020-05-28 14:57:10 -04:00
Ryan C. Gordon 22da9d4d77 wayland: assert that mmap() didn't return NULL.
In practice, it never _would_, but in theory it _might_, so this assertion
tells the static analyzer not to worry about it.
2020-05-28 14:47:55 -04:00
Sam Lantinga 1a1f1704a2 Don't include the iOS joystick driver if joysticks are disabled 2020-05-27 10:35:43 -07:00
Sam Lantinga 57149c2410 Fixed building with --disable-joystick on iOS 2020-05-27 10:27:20 -07:00
Sam Lantinga cf01ee1694 Fixed building with --disable-joystick on Linux 2020-05-27 10:27:04 -07:00
Sam Lantinga e9f567c707 Fixed building on iOS with MFI controllers disabled 2020-05-27 10:14:08 -07:00
Sam Lantinga 97ca96bdee Use nil instead of NULL for Objective-C objects 2020-05-27 10:13:01 -07:00
Sam Lantinga 03a7abf80c Fixed building with --disable-joystick on macOS 2020-05-27 09:57:26 -07:00
Sam Lantinga af5eb56c76 Fixed uninitialized variable warning 2020-05-27 09:28:03 -07:00
Sam Lantinga 31916f11aa Fixed compiler warning building on FreeBSD 2020-05-27 09:22:12 -07:00
Sam Lantinga bcbaa4ec1f If there isn't a GetGlobalMouseState() implementation, fall back to the normal one. 2020-05-26 16:34:50 -07:00
Sam Lantinga 437577f91e Fixed bug 5141 - KMSDRM: manage SDL_GetGlobalMouseState()
Manuel Alfayate Corchete

On the KMSDRM backend, there is no such thing as a desktop, yet some programs could (and DO) use SDL_GetGlobalMouseState().
So I think its good idea that, in KMSDRM, it returns the same mouse coordinates anyway as SDL_GetMouseState() would return. There is nothing else it could return, as far as I can understand, since there is no desktop anyway.
This small patch does precisely that.
2020-05-26 16:29:26 -07:00
Sam Lantinga 1df0a1e497 Fixed bug 5140 - KMSDRM: Dynamic vsync toggle does not work
Manuel Alfayate Corchete

The KMSDRM backend was doing things wrong because of some small (but important) misconceptions on how KMS/DRM works: to implement a largely broken non-vsync refresh mechanism, the SwapWindow() function was issuing new pageflips before previous ones had completed, thus causing EBUSY returns, buffer mismanagement, etc... resulting in general breakage on vsync disabling from apps, that would not allow vsync to work again without KMSDRM video re-initialization.
To further clarify, on most DRM drivers async pageflips are NOT working nowadays, so all issued pageflips will complete on next VBLANK, NOT ASAP (calling drmModePageFlip() with the DRM_MODE_PAGE_FLIP_ASYNC flag will return error).

The old code was assuming that can just issue a synchronous (=on VBLANK) pageflip and then pass a 0 timeout to the pull() function so we do not wait for the pageflip event, thinking that this will lead to correct non-vsynced screen updates from the program: That is plain wrong.
Each pageflip has to be waite before issuing a new one, ALWAYS. And if we do not support ASYNC pageflips on the DRM driver level, then we are forced to wait for the next VBLANK. There is no way around it.

I have also added many comments on the KMSDRM code. This is needed for future reference for me or others who may need to look at this code: KMS/DRM terminology regarding what SYNC and ASYNC mean in pageflip terms, and where to do certain things and why, is not trivial. It is not desirable or possible to invest time on researching the same concepts every time there is need to dive into this code. So please leave all these comments in the patch.
2020-05-26 16:27:00 -07:00
Sam Lantinga 15294e2121 Fixed iOS build 2020-05-26 13:54:47 -07:00
Sam Lantinga cc2fe84d73 Getting closer. 2020-05-26 13:19:48 -07:00
Sam Lantinga 0713c5790d More Linux fixes. 2020-05-26 13:19:44 -07:00
Sam Lantinga c7d1dab1fe Rename Linux-only variable. 2020-05-26 13:19:41 -07:00
Sam Lantinga b820a81ffb Include SDL_hints.h. 2020-05-26 13:19:35 -07:00
Sam Lantinga de866e6606 Include SDL_hint.h. 2020-05-26 13:19:29 -07:00
Sam Lantinga abd5841850 Make some changes to SDL_SetThreadPriority to try and have SDL transparently handle more of the work.
1. Comment that SDL_SetThreadPriority will make any necessary system changes when applying priority.
2. Add a hint to override SDL's default behavior for scheduler policy.
3. Modify the pthreads SDL_SetThreadPriority so that instead of just using the current thread scheduler policy it will change it to a policy that should work best for the requested priority.
4. Add hint checks in SDL_SetThreadPriority so that #3 can be overridden if desired.
5. Modify the Linux SDL_SetThreadPriority so that in the case that policy, either by SDL defaults or from the hint, is a realtime policy it uses the realtime rtkit API.
6. Prior to calling rtkit on Linux make the necessary thread state changes that rtkit requires.  Currently this is done every time as it isn't expected that SDL_SetThreadPriority will be called repeatedly for a thread.
2020-05-26 13:19:19 -07:00
Sam Lantinga f16e6bfa8e Fixed creating a metal renderer without specifying a metal window 2020-05-25 14:10:51 -07:00
Sam Lantinga f176d7fda0 Added a note not to use XinputUap.dll for XInput support 2020-05-22 16:45:02 -07:00
Ryan C. Gordon 600a2fc7c3 locale: Removed unused variable. 2020-05-21 04:01:37 -04:00
Ryan C. Gordon a299fdd789 sensor: Fixed compiler warnings on mingw64. 2020-05-21 03:52:48 -04:00
Ryan C. Gordon ba11122ea0 locale: Fixed compiler warning on Visual Studio. 2020-05-21 03:48:56 -04:00
Ryan C. Gordon b4e76b58e7 sensor: Fix overaggressive search/replace. :) 2020-05-20 17:32:23 -04:00
Ryan C. Gordon 27c38eb22e sensor: Correct fix for redefinition of various symbols. 2020-05-20 17:22:52 -04:00
Ryan C. Gordon 5fe34a4079 hidapi: Fix compiler warning. 2020-05-20 17:01:25 -04:00
Ryan C. Gordon c9d358bce9 sensor: Fix build on various Windows compilers with various predefinitions. 2020-05-20 16:59:35 -04:00
Ryan C. Gordon 68777406e5 windows: Fix calls to CoCreateInstance() so last parameter is a LPVOID *. 2020-05-20 16:58:33 -04:00
Ryan C. Gordon 539125b895 locale: Fixed compiler warning on WinRT. 2020-05-20 16:43:02 -04:00
Ryan C. Gordon d66b73666d locale: Patched to compile on Windows Phone. 2020-05-20 16:15:14 -04:00
Ryan C. Gordon 3808b120dc locale: Make sure C++ implementations (Haiku!) use C linkage. 2020-05-19 03:14:46 -04:00
Ryan C. Gordon 863776f8dd haiku: Another attempt at fixing build. 2020-05-19 01:19:52 -04:00
Ryan C. Gordon e53d39cf35 haiku: Patched to compile. 2020-05-19 00:09:59 -04:00
Sylvain Becker db4246f695 Only set colorkey, if converted surface has no alpha channel (2979) 2020-05-17 21:23:17 +02:00
Sylvain Becker f6197aec85 Fix issue with colorkey, palette and format conversion
Set the colorkey information on the converted surface.
Test-case in bug 3826/2979, conflicting with bug 4798
2020-05-17 20:45:55 +02:00
Sylvain Becker 39690a0478 Fix static analysis warning in SDL_render.c 2020-05-15 21:33:47 +02:00
Ryan C. Gordon daf360e040 emscripten: Fix crash in SDL_SetWindowTitle().
This patch came from emscripten-ports, thanks!

Fixes Bugzilla #5133.
2020-05-13 16:48:42 -04:00
Tudor Brindus 1a291ab118 wayland: add support for SDL_SetWindowGrab 2020-04-17 13:55:44 -04:00
Sam Lantinga b47f577a9d Fixed bug 5098 - macOS CreateWindowFrom doesn't work with high-dpi displays
michaeljosephmaltese

Display ends up taking only 1/4 of the screen area. It needs to call "setWantsBestResolutionOpenGLSurface:highdpi", like when creating a window the normal way.
2020-05-11 14:36:23 -07:00
Sam Lantinga eadc8693dd Fixed bug 5103 - Port fcitx support to both fcitx 4 & 5
wengxt

Due to the new major fcitx version is coming close, the existing code need to be ported to use new Fcitx dbus interface.

The new dbus interface is supported by both fcitx 4 and 5, and has a good side effect, which is that it will work with flatpak for free. Also the patch remove the dependency on fcitx header. Instead, it just hardcodes a few enum value in the code so need to handle the different header for fcitx4 or 5.
2020-05-11 14:31:04 -07:00
Sylvain Becker 2491f16f85 Android: send SDL_LOCALECHANGED when locale changes 2020-05-08 21:40:28 +02:00
Sylvain Becker 2a4ddeeea9 Android: fix missing prototype warning 2020-05-08 11:15:38 +02:00
Sylvain Becker 0059ace0b4 Android: factorize asset manager code (bug 2131 and 4297) 2020-05-08 11:00:51 +02:00
Ryan C. Gordon fa23e3d00b locale: Implemented SDL_GetPreferredLocales().
This was something I proposed a long time ago, Sylvain Becker did
additional work on it, then back to me.

Fixes Bugzilla #2131.
2020-05-04 02:27:29 -04:00
Sam Lantinga 1e5dd06f83 Added support for the HORI Real Arcade Pro on Mac OSX and Linux 2020-05-06 12:19:58 -07:00
Sam Lantinga cd2bdaef1c ControllerList: add PDP Faceoff Deluxe Audio Switch Controller and HORI Real Arcade Pro V Switch Edition 2020-05-06 11:19:52 -07:00
Sam Lantinga 0e5b48d2d8 ControllerList: add NACON Revolution Unlimited (and it's dongle) and NACON Daija fight stick. 2020-05-06 11:19:47 -07:00
Ryan C. Gordon b3a34c94e0 hid: Add Microsoft Precision Mouse to the joystick blacklist.
Same deal as the Razer keyboards, it hangs the enumeration.
2020-05-06 03:18:25 -04:00
Ryan C. Gordon 85d97410d4 hid: Cleanup Windows joystick blacklist code, to make additions easier. 2020-05-06 03:13:44 -04:00
Ryan C. Gordon b0a20a153c stdlib: Fixed compiler warnings about int vs size_t. 2020-05-05 12:48:55 -04:00
Sam Lantinga 0eb6512b53 Fixed bug 5121 - Use SDL_calloc instead of calloc in Wayland_CreateWindow
meyraud705

'SDL_Windows::driverdata' of a Wayland window is allocated by calloc in 'Wayland_CreateWindow' but freed by SDL_free in 'Wayland_DestroyWindow'.
2020-05-04 13:19:26 -07:00
Sam Lantinga 65ad45340d Improvement for bug 3446 - The haptic API does not allow to select the direction axes
meyraud705

I see how the documentation is confusing. I think that the choice of the axis is an implementation detail. The documentation should state the goal of this value, so I propose this wording:

    "Use this value to play an effect on the steering wheel axis. This provides
     better compatibility across platforms and devices as SDL will guess the
     correct axis."

Value could even be renamed 'SDL_HAPTIC_STEERING_AXIS'.

For Linux, sending an effect on the X axis with a Logitech wheel works. Others brands don't have driver for Linux as far as I know.
2020-05-04 13:17:43 -07:00
Sam Lantinga 11723411ab Added support for the Razer Kishi 2020-05-04 10:16:10 -07:00
Ryan C. Gordon 8601996fbc hints: Allow specifying audio device metadata.
This is only supported on PulseAudio. You can set a description when opening
your audio device that will show up in pauvcontrol, which lets you set
per-stream volume levels.

Fixes Bugzilla #4801.
2020-05-03 22:13:48 -04:00
Sam Lantinga 8b60d39cb0 Fixed bug 5112 - CMake won't compile in VS2019
dark_sylinc

Trying to build SDL with VS2019 using CMake will encounter a linking error

More specifically:

    1>SDL_string.obj : error LNK2019: unresolved external symbol memset referenced in function SDL_vsnprintf_REAL
2020-05-02 14:43:17 -07:00
Sam Lantinga b0b12e46ba Fixed running on older versions of iOS 2020-04-27 13:31:10 -07:00
Sam Lantinga 01fd8130fd Fixed compiler warning 2020-04-23 11:13:02 -07:00
Sam Lantinga c6b24b4b7c Added support for the following controllers:
* 8BitDo N30 Pro 2
* 8BitDo SN30 Gamepad
* 8BitDo SN30 Pro+
* 8BitDo Zero 2
* SZMY-POWER PC Gamepad
* ThrustMaster eSwap PRO Controller
* ZEROPLUS P4 Wired Gamepad

In additional, all 8BitDo controllers use SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS to have the correct mapping based on user preferences.
2020-04-23 11:07:07 -07:00
Sam Lantinga 4727f79416 Don't use the WGI driver if another driver is already handling the joystick 2020-04-23 10:13:17 -07:00
Sam Lantinga 6ca7f510ae Fixed crash trying to get battery status on some devices 2020-04-23 09:35:32 -07:00
Sam Lantinga 0f374b069b Fixed build on older Visual Studio, enable new features on newer Visual Studio 2020-04-22 15:42:32 -07:00
Sam Lantinga 589d636bb9 Fixed rare crash when creating an X11 window 2020-04-22 14:57:06 -07:00
Sam Lantinga d12ea89c1e Added support for the following controllers:
* PDP Afterglow Switch Controller
* Thrustmaster ESwap Pro PS4 controller
* Giotek VX4
* Generic PS4 controller vid/pid that several knock offs use
2020-04-22 10:50:50 -07:00
Ryan C. Gordon 3625b83c63 hid: Add Razer Arctosa keyboard to hid enumeration blacklist.
Hangs SDL, same as the Razer Lycosa.

Fixes Bugzilla #5101.
2020-04-21 01:32:48 -04:00
Ryan C. Gordon 09ca66bf66 SDL_error: simplified error string management.
This patch removes deferred error string formatting: now we do it during
SDL_SetError(), so there's no limit on printf-style arguments used.

Also removes stub for managing error string translations; we don't have the
facilities to maintain that and the way we set arbitrary error strings
doesn't really make this practical anyhow.

Since the final error string is set right away and unique to the thread,
we no longer need a static buffer for legacy SDL_GetError(), and we don't
have to allocate 5x 128-byte argument fields per-thread. Also, since we now
use SDL_vsnprintf instead of parsing the format string ourselves, there's a
lot of code deleted and we have access to more robust formatting powers now.

This does mean the final error strings can't be more than 128 bytes, down
from the theoretical maximum of around 768, but I think this is probably okay.
They might truncate but they will always be null-terminated!

Fixes Bugzilla #5092.
2020-04-21 01:30:36 -04:00
Ryan C. Gordon 67760f0ed7 joystick: Don't report duplicate recentering events for game controllers. 2020-04-20 18:58:18 -04:00
Ryan C. Gordon c5f2a1ce4e joystick: On disconnect, recenter all game controller inputs.
The joystick layer can't necessarily give us perfect centering, but we know
that the game controller level has logical absolute idle positions that have
nothing to do with the physical device.

So send game controller events to make it look like the device is completely
untouched before sending the final removal event.
2020-04-20 16:01:36 -04:00
Sam Lantinga aba2792896 Added a Windows Gaming Input joystick driver
This driver supports the Razer Atrox Arcade Stick

Some of the quirks of this driver, inherent in Windows Gaming Input:
* There will never appear to be controllers connected at startup. You must support hot-plugging in order to see these controllers.
* You can't read the state of the guide button
* You can't get controller events in the background
2020-04-18 21:41:37 -07:00
Sam Lantinga b90b59279e Added support for the Razer Atrox Arcade Stick 2020-04-17 21:30:58 -07:00
Sam Lantinga dbcda0b212 Added support for the Razer Wolverine Ultimate 2020-04-17 21:30:56 -07:00
Sam Lantinga 2b32385502 Don't send rumble packets too quickly to Nintendo Switch Pro controllers over Bluetooth 2020-04-17 15:08:48 -07:00
Sam Lantinga c02f54a0ed Fixed the default face button mapping for Nintendo Switch Pro controllers 2020-04-17 15:08:46 -07:00
Ryan C. Gordon eaaa809e40 hidapi: Blacklist the Razer Lycosa keyboard from enumeration.
It's not a joystick and it hangs device enumeration.
2020-04-15 13:33:09 -04:00
Ryan C. Gordon a7a4e16b5b haiku: Patched to compile. 2020-04-15 13:31:54 -04:00
Sam Lantinga a990a34ac4 Cleanly switch between audio recording, playback, and both, on iOS 2020-04-14 22:26:02 -07:00
Sam Lantinga 14661d3f30 Added support for mousewheel on iOS 2020-04-14 17:31:31 -07:00
Sam Lantinga 50b1c19549 Fixed bug 5091 - Suspicious condition in HIDAPI_DriverXbox360_UpdateXInput
meyraud705

On line 220 of SDL_hidapi_xbox360.c https://hg.libsdl.org/SDL/file/4608f0e6e8e3/src/joystick/hidapi/SDL_hidapi_xbox360.c#l220

if (!XINPUTGETSTATE(user_index, &xinput_state[user_index].state) == ERROR_SUCCESS) {

logical not is only applied to the left hand side of this comparison.

I think you mean:
if (XINPUTGETSTATE(user_index, &xinput_state[user_index].state) != ERROR_SUCCESS) {
2020-04-14 09:55:33 -07:00
Sam Lantinga 2ae1c0f5d0 Allow Bluetooth headphones for iOS playandrecord mode 2020-04-14 09:52:27 -07:00
Sam Lantinga f34d2c60cc Added zlib license for Steam Controller headers 2020-04-14 07:35:35 -07:00
Sam Lantinga 3e4856c97f Fixed mouse button mapping on iOS 2020-04-13 23:07:54 -07:00
Sam Lantinga e1215e857f Fixed mouse button mapping on iOS 2020-04-13 22:50:46 -07:00
Sam Lantinga dbf7f84fd9 Implemented left/right mouse click detection on iOS 2020-04-13 22:29:10 -07:00
Sam Lantinga 171ba00a6a Hide the mouse cursor appropriately on iOS 2020-04-13 19:44:26 -07:00
Ryan C. Gordon 132f87c3a1 opengl: Don't try to do Desktop OpenGL stuff if support isn't available. 2020-04-13 22:06:12 -04:00
Ryan C. Gordon a96d8a4355 render: Fixed compiler warning about implicit cast. 2020-04-13 22:05:36 -04:00
Sam Lantinga 6f3fa02e27 Make sure we're using the bounds of the view for our mouse region 2020-04-13 18:25:38 -07:00
Sam Lantinga cab1ee9cbc Don't build iOS mouse support on Apple TV 2020-04-13 15:57:04 -07:00
Sam Lantinga e5d3629931 Added support for new mouse APIs in iOS 13.4 2020-04-13 15:46:12 -07:00
Ryan C. Gordon e96b05c395 egl: Attempt to make this compile on WinRT, etc. 2020-04-13 18:21:28 -04:00
Sam Lantinga 1d8797876a Fixed implicit linkage to ftol2() on Windows 2020-04-13 13:24:56 -07:00
Sam Lantinga c302c1abb8 Fixed build 2020-04-13 13:24:19 -07:00
Sam Lantinga bf87604ef1 Fixed rare crash when unplugging Xbox controller on Windows 2020-04-13 12:33:29 -07:00
Conn O'Griofa c0a875faff SDL_EGL_ChooseConfig: don't fall through if no matching format exists
On Raspberry Pi 3 via the VC4 driver in firmware KMS mode, none of the
found configs match the desired format, causing the function to fall through
without any config being selected.

Fix by first iterating over the found configs, and if no match exists,
don't exclude the non-matching configs. This should fix RPI3 and possibly other
targets without breaking targets that have a matching native format (such as RPI4).
2020-04-13 14:48:38 -04:00
Ryan C. Gordon 64617d259a opengl: Convert an int to an SDL_bool. 2020-04-13 14:45:40 -04:00
Ryan C. Gordon 389c8995d2 opengl: Allow SDL_GL_MakeCurrent() to accept a NULL window (thanks, Martin!).
This allows you to bind surfaceless contexts on a background thread to, for
example, load assets in a separate context, for platforms that have different
requirements about sharing surfaces, etc.

Martin's notes on the matter:

"Here's a patch that enables passing NULL windows to SDL_GL_MakeCurrent, if
the involved APIs allow it. Currently, this is only the case for EGL, and
even then only if some specific extensions are present (which they usually
are).

If "surfaceless" contexts are not supported, SDL_GL_MakeCurrent continues to
generate an error (albeit with a more specific error message than it used to),
so this should not break anything that wasn't broken before."

(Please see https://bugzilla.libsdl.org/show_bug.cgi?id=3695 for more
discussion.)

Fixes Bugzilla #3695.
2020-04-13 14:44:21 -04:00
Jay Petacat 8a5ee3faf9 video: NULL out pointer to freed window surface
This behavior matches SDL_RecreateWindow and makes it less likely that
another piece of code (e.g. a DestroyWindowFramebuffer implementation)
will attempt to use or free the stale surface pointer.
2020-04-12 00:55:52 -04:00
hmk 0918903f3c render: add a hint for toggling relative scaling
Fixes Bugzilla #4811.
2019-09-30 22:54:16 +03:00
hmk aa188048f1 render: Scale relative mouse motion better for logical sizing
From hmk:

"When scaling is enabled (e.g. via SDL_RenderSetLogicalSize, size not equal
to window size), mouse motion events are also scaled.  Small motions are
rounded up (SDL_max() when the value after scaling is less than 1), while
larger motions are truncated by the floating point -> integer conversion.

https://hg.libsdl.org/SDL/file/b18197f9bf9d/src/render/SDL_render.c#l658

The end result feels something like mouse reverse mouse acceleration + angle
snapping at low speeds, but less consistent (amount of truncation & rounding
depends on how fast the mouse is moved) and potentially much worse if the
scaling factor is large.  This pretty much makes it useless for anything
where you need precise mouse aiming (think of games).  I suspect this is why
aiming gets so terrible in some games that let you use scaling to reduce the
render resolution (e.g. Ion Fury).

With 4x4 scaling, I can reproduce a situation where it takes three fast flicks
of the mouse across the pad to undo one slow sweep across the pad.  In other
words, extreme reverse acceleration.  This does not happen when scaling is
disabled.

Furthermore, any game that uses relative mouse motion events for 3D camera
rotation probably wants the raw mouse deltas and not a value that depends on
scaling and resolution and rounding and truncation.  Ideal camera rotation
just takes mouse input, multiplies it by sensitivity, and adds it to the
angle-in-radians or whatever measure is used for yaw & pitch.  Pixels and
screen resolution or window dimensions should not be a part of the equation
at all, even if it could be implemented without rounding errors.

[...]

This [patch] completely eliminates angle snapping for me, and makes
sensitivity consistent.  In other words, it's completely usable for, say,
aiming in a first person shooter."

Partially fixes Bugzilla #4811.
2020-04-10 12:23:08 -04:00
Ryan C. Gordon d292f6bd4f stdlib: Add SDL_trunc and SDL_truncf 2020-04-10 12:17:14 -04:00
Ryan C. Gordon a791689086 metal: Added some support interfaces to Apple's Metal API (thanks, Caleb!).
Caleb Cornett's comments:

"A few weeks ago, Alex added a partial Metal API to SDL2:

https://hg.libsdl.org/SDL/rev/22c8e7cd8d38

I noticed it was missing a few features that would help Metal become a
first-class citizen in SDL, so I went ahead and wrote them! Here are the new
APIs:

1. SDL_WINDOW_METAL flag for SDL_CreateWindow(). This allows the programmer
to specify that they intend to create a window for use with SDL_MetalView.
The flag is used to ensure correct usage of the API and to prevent
accidentally defaulting to OpenGL on iOS.

2. SDL_Metal_GetLayer(). This function takes a SDL_MetalView and returns a
pointer to the view's backing CAMetalLayer. This simplifies things
considerably, since in the current version of the SDL_Metal API the
programmer is required to bridge-cast a SDL_MetalView handle to an NSView or
UIView (depending on the platform) and then extract the layer from there.
SDL_Metal_GetLayer automatically handles all of that, making the operation
simple and cross-platform.

3. SDL_Metal_GetDrawableSize(). This function already exists in the current
SDL_Metal API (and is used behind-the-scenes for SDL_Vulkan_GetDrawableSize
on Apple platforms) but was not publicly exposed. My patch exposes this
function for public use. It works just like you'd expect.

Tested on macOS 10.14 and iOS 12.4."

Fixes Bugzilla #4796.
2020-04-10 00:37:35 -04:00
Charlie Birks 258d410653 emscripten: Add a few keyCode mappings for German keyboards
From @sy2002 in https://github.com/emscripten-ports/SDL2/issues/108
2020-04-09 15:57:12 +01:00
Charlie Birks babf010c60 emscripten: Pass canvas id to request_pointer_lock
Fixes pointer lock with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
2020-04-09 15:01:47 +01:00
Daid 287772f5e9 emscripten: Let SDL_GetDisplayUsableBounds return the size of the window
This does not account for scrollbars nor margins. But is much better then returning the full display size when not running fullscreen, but for example in an iframe.
2020-04-09 15:01:45 +01:00
Daid fb3df3a18d emscripten: Fix the reported keys for the numpad. See https://github.com/emscripten-ports/SDL2/issues/94 2020-04-09 15:01:41 +01:00
Sylvain Beucler 44716b0236 emscripten: Send SDL_APP_TERMINATING before unload (#88) 2020-04-09 15:01:37 +01:00
Beuc 0380cbd792 emscripten: Typo 2020-04-09 15:01:32 +01:00
Sam Lantinga d4f1b520c9 Added support for press/release hardware keyboard events in iOS 13.4 2020-04-08 19:16:31 -07:00
Sam Lantinga e9c94ac0b3 Fixed Windows accelerometer data units 2020-04-08 10:27:30 -07:00
Sam Lantinga 09f552639a Fixed memory leak and removed debug code from Windows sensor implementation 2020-04-08 09:00:10 -07:00
Sam Lantinga 55515a8c25 SDL: ps4 controller trigger bits on other controllers just mean that there's some activity, not saturation - only force it on if the analog value is 0. 2020-04-08 08:42:15 -07:00
Sam Lantinga ba95fa6152 Revert "Fix incorrectly terminated MakeThreadHighPriority dbus message"
The first terminator is for input parameters. The second terminator was for the
output parameters.

If an error occurs when calling MakeThreadHighPriority(), e.g. a bad thread id,
then the reply from connection_send_with_reply_and_block() will be null.
2020-04-08 08:42:09 -07:00
Sam Lantinga 3180ba81af First pass at Windows sensor implementation 2020-04-08 08:34:27 -07:00
Ryan C. Gordon 6e6b517789 cocoa: Patched to compile. 2020-04-07 23:34:41 -04:00
Ryan C. Gordon 8c165adde7 joystick: Remove force_centering flag; we handle this on disconnect now. 2020-04-07 23:17:27 -04:00
Ryan C. Gordon fba081e489 wasapi: Patched to compile on C89 systems, and use SDL_ceilf instead of ceilf. 2020-04-07 14:51:08 -04:00
Ryan C. Gordon 4c2be47207 wasapi: Improve WASAPI audio backend latency (thanks, Anthony!).
Anthony Pesch's notes on his patch:

"Currently, the WASAPI backend creates a stream in shared mode and sets the
device's callback size to be half of the shared stream's total buffer size.

This works, but doesn't coordinate will with the actual hardware. The hardware
will raise an interrupt after every period which in turn will signal the
object being waited on inside of WaitDevice. From my empirical testing, the
callback size was often larger than the period size and not a multiple of it,
which resulted in poor latency when trying to time an application based on the
audio callback. The reason for this looked something like:

* The device's callback would be called and and the audio buffer was filled.
* WaitDevice would be called.
* The hardware would raise an interrupt after one period.
* WaitDevice would resume, see that a a full callback had not been played and
  then wait again.
* The hardware would raise an interrupt after another period.
* WaitDevice would resume, see that a full callback + some extra amount had
  been played and then it would again call our callback and this process would
  repeat.

The effect of this is that the pacing between subsequent callbacks is poor -
sometimes it's called very quickly, sometimes it's called very late.

By matching the callback's size to the stream's period size, the pacing of
calls to the user callback is improved substantially. I didn't write an actual
test for this, but my use case for this was my Dreamcast emulator
(https://redream.io) which uses the audio callback to help drive the emulation
speed. Without this change and with the default shared stream buffer (which
has a period of ~10ms) I would get frame times that were between ~3-30
milliseconds; after this change I get frame times of ~11-22 milliseconds.

Note, this patch also has a change that removes passing a duration to the
Initialize call. It seems that the default duration used (when 0 is passed)
does typically match up with the duration returned by GetDevicePeriod, however
the Initialize docs say:

> To set the buffer to the minimum size required by the engine thread, the
> client should call Initialize with the hnsBufferDuration parameter set to 0.
> Following the Initialize call, the client can get the size of the resulting
> buffer by calling IAudioClient::GetBufferSize.

This change isn't strictly required, but I made it to hopefully rule out
another source of unexpected latency."

Fixes Bugzilla #4592.
2020-04-07 14:37:24 -04:00
Michael Maltese 361417c0a4 cocoa: allow calling CreateWindowFrom on an NSView
This lets applications embed SDL with other widgets surrounding it.
Already possible on Windows and X11.

Fixes Bugzilla #5060.
2020-03-25 16:40:43 -07:00
Ryan C. Gordon 8641f6e99d emscripten: support KaiOS's Left Soft Key and Right Soft Key (thanks, pelya!).
Fixes Bugzilla #5027.
2020-04-07 14:03:13 -04:00
Ryan C. Gordon 309d6137ae cocoa: OpenGL setView and update must be used on main thread (thanks, Tim!).
If called from background threads, use Grand Central Dispatch to use the
main thread instead. On the main thread, just call them directly.

Fixes Bugzilla #4932.
2020-04-07 14:01:25 -04:00
Ryan C. Gordon 024698779b wayland: Support wayland compositors with wl_seat version < 5 (thanks, Nia!).
Fixes Bugzilla #5074.
2020-04-07 13:30:46 -04:00
Sam Lantinga 3cb62d5265 Fixed setting the controller name for the RAWINPUT driver 2020-04-07 11:17:52 -07:00
Sam Lantinga e62c25b693 The 0x02ff product ID shows up for new firmware Xbox One controllers using the RAWINPUT driver 2020-04-07 11:17:22 -07:00
Sam Lantinga 88cecee495 Fixed build warning 2020-04-07 10:14:12 -07:00
Sam Lantinga 50cb8e0f04 Fixed deadlock in new raw input joystick code
The appropriate locking is done elsewhere, this prevents inverted lock acquisition
2020-04-07 10:13:08 -07:00
Sam Lantinga b6afbe6317 Added SDL_log.h to SDL_internal.h so logging is available everywhere 2020-04-07 09:38:57 -07:00
Sam Lantinga 488b94cb40 Don't interpret raw input messages with no mouse position
This happens occasionally on touch devices when raw input is enabled
2020-04-07 09:18:19 -07:00
Sam Lantinga 0721931f5b Avoid sending regular mouse messages for touch input 2020-04-06 19:21:56 -07:00
Jay Petacat c760c02c6c Fix some format specifier warnings
The warnings were produced by GCC 9.2.x for x86_64-linux-gnu or
i386-pc-msdosdjgpp targets.

Most of the fixes involve changing the type of a variable rather than
the format specifier. For many of the affected test conuter variables,
a basic int seems sufficient.

Some format specifier warnings still remain for cases where changing
type or casting seemed inappropriate. Those warnings will probably
require some new format specifier macros (e.g. SDL_PRIu32).
2020-03-25 01:34:15 -04:00
Sam Lantinga dad73b1f0c Fixed bug 5073 - SDL does not handle URL Schemes in MacOS
Jason

In iOS, URL Events trigger the DropFile event. I would also expect the same event to be fired on the macOS platform but this is not implemented at all in the AppDelegate.
2020-04-05 10:47:58 -07:00
Sam Lantinga 9525f9729a Fixed bug 5076 - SDL_netbsdaudio: Add support for 32-bit LPCM
Nia Alarie

The kernel supports this, make SDL expose it so it can be used.
2020-04-05 10:44:51 -07:00
Sam Lantinga e05d92a17d Fixed bug 5075 - Don't assume a GL library version number on NetBSD.
Nia Alarie

If you install X as part of NetBSD, the GL library is libGL.so.3, but if you install the GL library later as a package, it's libGL.so.1.
2020-04-05 09:01:33 -07:00
Sam Lantinga d4b561f472 Fixed bug 5015 - SDL_RenderReadPixels on DirectX 11.1 backend seems to be broken
Konrad

It appears that I cannot use SDL_RenderReadPixels on a bound framebuffer (SDL_Texture set as render target) as it simply results in gibberish data. However, drawing that framebuffer into the default target (window surface) does render it correctly. Other backends (OpenGL, software, Direct3D) do work fine.

It looks to me like D3D11_RenderReadPixels just gets the general backbuffer and not the current render target and its backbuffer.

Here is the patch which actually fetches the current render target and its underlying ID3D11Resource which is ID3D11Texture2D.
2020-04-05 08:58:47 -07:00
Sam Lantinga f3e609679d Fixed setting the "playandrecord" audio hint on Apple TV
The Apple TV doesn't have record capability by default, so activating the audio session with AVAudioSessionCategoryPlayAndRecord fails.
2020-04-02 12:27:29 -07:00
Sam Lantinga 378a5cfb61 Updated thread priorities for Apple operating systems 2020-04-01 16:39:05 -07:00
Sam Lantinga 3154d92473 SDL: plumb previously unused digital trigger bits for PS4 controllers. Victrix fight stick only sets these bits and doesn't send the analog values
CR: SamL
2020-03-30 14:26:21 -07:00
Sam Lantinga f4a56d7e61 Enable thread-safety features in libdbus
There are multiple SDL APIs that internally sink into dbus calls, e.g. battery
status, thread priority. If those calls happen in different threads simultaneously
it can result in dbus crashes.

To abide by dbus's multithreading guidelines we must call dbus_threads_init_default()
to enable dbus's internal locking mechanisms:
https://dbus.freedesktop.org/doc/api/html/group__DBusThreads.html#gac7b8a7001befc3eaa8c6b043151008dc

Additionally, access to a DBusMessage must be synchronized between threads.
SDL was already abiding that guideline as the DBusMessage structs aren't shared.

The following email from the dbus mailing list hints that arbitrating access to
the DBusConnection on the SDL may also be required:
https://lists.freedesktop.org/archives/dbus/2017-September/017306.html
2020-03-30 14:26:15 -07:00
Sam Lantinga 2e667a8be9 Fix incorrectly terminated MakeThreadHighPriority dbus message
Currently the message is double terminated, which results in SDL_DBus_CallMethodInternal()
incorrectly assuming that the other party is always returning true.

I'm not super familiar with dbus, so I'm not sure if this could also be the cause of this bug:
https://github.com/ValveSoftware/steam-for-linux/issues/6901
2020-03-30 14:26:10 -07:00
David Ludwig 6e7465bd60 Fixed Bug 4883, redux - connect SDL_GetDisplayDPI to UIKit_GetDisplayDPI
SDL_GetDisplayDPI was failing on iOS, as UIKit_GetDisplayDPI was
not getting assigned to SDL's internal field in SDL_VideoDevice:
GetDisplayDPI.
2020-03-28 15:43:55 -04:00
Ryan C. Gordon 55b4f18e1a coreaudio: The default SDL audio device now tracks the system output default.
So if you go into System Preferences on a MacBook and toggle between a pair of
connected bluetooth headphones and built-in internal speakers, SDL will
switch the device it is playing sound through, to match this setting, on the
fly.

Likewise if the default output device is a USB thing and is unplugged; as the
default device changes at the system level, SDL will pick this up and carry
on with the new default. This is different from our unplug detection for
specific devices, as in those cases we want to send the app a disconnect
notification, instead of migrating transparently as we now do for default
devices.

Note that this should also work for capture devices; if the device changes,
SDL will start recording from the new default.

Fixes Bugzilla #4851.
2020-03-29 01:54:00 -04:00
Ryan C. Gordon 46bb47cf04 thread: Put all important SDL_CreateThread internal data into SDL_Thread.
This avoids the need to malloc something extra, use a semaphore, etc, and
fixes Emscripten with pthreads support, which might not spin up a web worker
until after SDL_CreateThread returns and thus can't wait on a semaphore at
this point in any case.

Fixes Bugzilla #5064.
2020-03-26 22:14:59 -04:00
Sam Lantinga abdc5cbf24 Allow background music to play in the "play and record" case on iOS 2020-03-26 19:30:17 -07:00
Ryan C. Gordon 369e5f33fb dbus: System bus is optional, we only need a session bus (thanks, tamo!).
Fixes Bugzilla #4795.
2020-03-26 20:28:04 -04:00
Ryan C. Gordon 07f231eeae joystick: Make sure recentering events happen before disconnect events.
Fixes Bugzilla #5063.
2020-03-26 18:47:04 -04:00
Ryan C. Gordon f2ff953ef7 cocoa: Just update the OpenGL context directly if on the main thread. 2020-03-26 13:42:56 -04:00
Fabrice Fontaine 9354aea198 src/video/kmsdrm/SDL_kmsdrmvideo.c: fix build
Build is broken without EGL since version 2.0.12 and
https://hg.libsdl.org/SDL/rev/72cc4740dec2:

/home/giuliobenetti/autobuild/run/instance-1/output-1/build/sdl2-2.0.12/src/video/kmsdrm/SDL_kmsdrmvideo.c: In function 'KMSDRM_CreateSurfaces':
/home/giuliobenetti/autobuild/run/instance-1/output-1/build/sdl2-2.0.12/src/video/kmsdrm/SDL_kmsdrmvideo.c:394:5: error: unknown type name 'EGLContext'
     EGLContext egl_context;
     ^

Fixes:
 - http://autobuild.buildroot.org/results/fafd20a01591032662f9ca025fcea3478239cf3c

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-03-25 09:38:45 -07:00
Fabrice Fontaine a4b0204b1a src/video/directfb/SDL_DirectFB_render.c: fix build
Build with directfb is broken due to a spurious '}' and a missing 'E'
since version 2.0.12 and https://hg.libsdl.org/SDL/rev/4c2dcf490cba:

/home/buildroot/autobuild/run/instance-2/output-1/build/sdl2-2.0.12/src/video/directfb/SDL_DirectFB_render.c: In function 'SetBlendMode':
/home/buildroot/autobuild/run/instance-2/output-1/build/sdl2-2.0.12/src/video/directfb/SDL_DirectFB_render.c:202:9: error: case label not within a switch statement
  202 |         case SDL_BLENDMODE_MUL:
      |         ^~~~

/home/buildroot/autobuild/run/instance-2/output-1/build/sdl2-2.0.12/src/video/directfb/SDL_DirectFB_render.c:205:67: error: 'DSBF_DSTCOLOR' undeclared (first use in this function); did you mean 'DSBF_DESTCOLOR'?
  205 |             SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DSTCOLOR));
      |                                                                   ^~~~~~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/83ccefee68c2800c0544e6f40fa8bc8ee6b67b77

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-03-24 10:05:51 -07:00
Sam Lantinga 885b3f6948 Don't check the HIDAPI driver for the virtual device created by xow 2020-03-23 14:10:25 -07:00
Sam Lantinga 2c02b7410c Fixed bug 5052 - Interval between SDL_SENSORUPDATE events for gyroscopes is too high
Andrei Kortunov

Hello. I try to implement an application for Android, which uses a new sensors API from 2.0.9 to control a camera rotation via built-in gyroscope, using the code from the test/testsensor.c as an example.

Gyroscope input itself works well, but an interval between SDL_SENSORUPDATE events is about 200ms (the SENSOR_DELAY_NORMAL, I believe), when I need the interval about 20-40ms (the SENSOR_DELAY_GAME or SENSOR_DELAY_FASTEST).
2020-03-23 12:10:05 -07:00
Jay Petacat e0a270561f Do not overwrite window surface created by driver
If a driver's implementation of CreateWindowFramebuffer sets the window
surface, use that rather than overwriting it. A driver may set the window
surface if data cannot be passed via the CreateWindowFramebuffer output
parameters (e.g. surface palette colors).
2020-03-22 20:09:14 -04:00
Sam Lantinga 1fd548b67a Fixed building back to Mac OSX using the 10.7 SDK 2020-03-23 11:42:44 -07:00
Ryan C. Gordon 19a5f4ab5d opengl: Don't enable/disable texturing except when actually rendering.
Otherwise our cached state goes out of sync when updating a texture. Since
these state changes aren't necessary, they were removed instead of updating
the cached state.

Fixes Bugzilla #4998.
2020-03-22 14:32:47 -04:00
Sam Lantinga cb8c91d956 Fixed bug 5051 - Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth
bluenaxela+sdl

I've noticed that the Switch Pro Controller hidapi driver does not report battery levels when connected via Bluetooth, despite having code for setting joystick->epowerlevel.

This is caused by the driver always using k_eSwitchInputReportIDs_SimpleControllerState via Bluetooth. Using that mode means that the state reports you get back from the controller do not include battery state. Not using the full controller state over Bluetooth effectively makes this driver's support for setting joystick->epowerlevel entirely pointless, only ever reporting SDL_JOYSTICK_POWER_WIRED.

Is there a reason this was set to only use SimpleControllerState via Bluetooth?

I've attached a patch I'm using to allow getting battery level for the Switch Pro Controller.

A couple notes about this patch:
1) It changes LoadStickCalibration to accept the input_mode that is selected, because that's really what should determine what is used for stick extents, since stick extents differ between the modes.
2) In my patch I only use FullControllerState when the vid/pid matches the official Switch Pro Controller, as a cautionary measure in case some third-party controllers have problems with FullControllerState mode via Bluetooth (I noticed a HORI Wireless Switch Pad I had seemed to not read controller calibration correctly for stick extents. Maybe it's calibration data was uninitialized on account of having never been used with a Switch? I'm unsure, though if that guess is right maybe SDL2 should be detecting an uninitiated calibration state and using some sensible defaults)
2020-03-22 11:01:14 -07:00
Sam Lantinga f55cbdfd96 Allow Valve devices in driver check, we know they're well behaved controllers 2020-03-20 21:05:07 -07:00
Sam Lantinga 6e646b6156 Removed blacklist entries for devices that aren't game controllers, allow Steam Controllers 2020-03-20 20:53:26 -07:00
Cameron Gutman 5ed71f3bc0 Only enumerate HID devices on Windows that have gamepad HID usages
There are a number of poorly behaved HID devices that time out on attempts to
read various strings. Rather than end up on an endless treadmill of blacklisting
broken devices, reduce our risk by only querying devices that are gamepads.
SDL_hidapijoystick.c already checks these same usages, so we shouldn't
exclude any working HID devices (caveat below).

This also makes HidP_GetPreparsedData() and HidP_GetCaps() failure skip
the device entirely, but that seems desired. If a device can't even return basic
top-level collection data properly, we want nothing to do with that broken device.
If we do find devices that work with HIDAPI joystick and fail these calls, we can
add an exception via VID+PID matching.
2020-03-20 13:44:50 -07:00
Sam Lantinga 106ffd57d8 Fixed bug 5049 - HORI Wireless Switch Pad does not connect properly via Bluetooth
bluenaxela+sdl

The HORI Wireless Switch Pad does not properly connect via bluetooth. I did some debugging and found that the code that tries to control the Home LED causes this controller to disconnect.
2020-03-20 20:45:30 -07:00
Jimb Esser 417713a75c Probable fix for compile errors on Mac OS and (non-VS) Win32 2020-03-20 19:49:19 -07:00
Sam Lantinga dc36f133b4 Backed out changeset c29d04c3fa49 2020-03-20 19:49:15 -07:00
Sam Lantinga 2db65a7fe7 Fixed compile warnings 2020-03-20 19:47:46 -07:00
Ryan C. Gordon 90f9e8f8b6 egl: Don't use SDL_LoadFunction to get GL entry points on Emscripten.
This results in a dlsym() call, which causes Emscripten to panic if the game
wasn't explicitly built dlopen support. eglGetProcAddress works just fine on
this platform, so just let that codepath handle it.
2020-03-20 15:13:09 -04:00
Emir Marincic 5b3b55a181 [NSOpenGLContext update[ is prohibited outside the main thread 2020-03-20 11:52:18 +03:00
David Ludwig 7e5340c5ac Fix for Bug 5034 - Replugging in a controller crashes on macOS in SDL 2.0.12
This is a multi-part fix, and is the 2nd attempt at a fix for Bug 5034.  Here
are the problems being addressed:

1. On macOS 10.14.x and earlier, trying to call IOHIDDeviceUnscheduleFromRunLoop
   without a prior, paired call to IOHIDDeviceScheduleWithRunLoop, appears to
   lead to a crash.  A per-device flag has been added to make sure that these
   calls are paired.
2. DARWIN_JoystickDetect was free'ing its SDL_joystick's hwdata field
   (via FreeDevice) without setting it to NULL, and DARWIN_JoystickRumble wasn't
   checking for a NULL hwdata.  FreeDevice will now set hwdata to NULL and
   DARWIN_JoystickRumble will check for a NULL hwdata.
2020-03-17 17:34:24 -04:00
Sam Lantinga 4c22a21e06 Fixed bug 3446 - The haptic API does not allow to select the direction axes
meyraud705

Added Linux implementation, otherwise you get "Unsupported direction type" error.
Added documentation to explain why one would use SDL_HAPTIC_FIRST_AXIS.
2020-03-17 14:18:05 -07:00
Sylvain Becker e6189f4046 Fix warnining implicit declaration of SDL_DetectPalette (Thanks meyraud705) 2020-03-17 15:47:30 +01:00
Sylvain Becker 838bbf1f7a Fixed bug 5037 - Regression 2.0.12 Alpha value of 0 on palette may become opaque
(see also bug 3827)
2020-03-17 09:35:42 +01:00
David Ludwig 36d5845152 Backout prior fix for Bug 5034, which needs more research
This backs-out the change, https://hg.libsdl.org/SDL/rev/14c961903135
2020-03-17 02:31:47 -04:00
Sam Lantinga 55a2a12ddf Fixed compile warning 2020-03-16 22:34:33 -07:00
Sam Lantinga 9b879a08aa Fixed compiler warning 2020-03-16 19:15:28 -07:00
Jimb Esser c2c5d0b392 Fix compile error 2020-03-16 16:52:49 -07:00
David Ludwig 197b14de4a Fixed Bug 5034 - Replugging in a controller crashes on macOS in SDL 2.0.12
The Darwin/macOS joystick driver was freeing its joystick's hwdata field
without zeroing it out in any live instance of SDL_Joystick.
2020-03-16 19:24:25 -04:00
Jimb Esser 47da53b91d Fix compiler warnings 2020-03-16 14:49:20 -07:00
David Ludwig 8cd08646bb virtual joysticks: move variable decls to top of function (for C90 compat; Bug 5038) 2020-03-16 17:19:18 -04:00
Sam Lantinga 7379991778 Fixed bug 3446 - The haptic API does not allow to select the direction axes
Mathieu Laurendeau

Consider a device supporting effects on multiple axes.
There's currently no way to play effects against a single-axis direction.


A device supporting effects against X and Y may not allow to play effects with a two-axis direction coordinate, even if one of the coordinates is null.

My current (ugly) work around for this is to add a direction type SDL_HAPTIC_X_FORCE to play effects against a X-axis only direction (patch attached).

This issue impacted two GIMX users using the following wheels:
- Leo Bodnar SimSteering force feedback wheel
- Accuforce direct drive wheel

Playing constant/spring/damper effects against a X-axis direction worked well for the first wheel, but not for the second one.

A better strategy seems to play the effects against the first axis reported by the DirectInput enumeration.

This strategy also works with Logitech wheels (at least the DFGT).

It's been more than a year that I have the latest patch (playing effects against the first axis only) in the GIMX software. It's being used by thousands of people, mostly for adapting their FFB wheel to the PS4. I had no report that proves this strategy to be wrong.
2020-03-16 13:28:38 -07:00
Sam Lantinga 543994b193 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows
Jimb Esser

Add new RawInput controller API, and improved correlation with XInput/WGI

Reorder joystick init so drivers can ask the others if they handle a device reliably
Do not poll disconnected XInput devices (major perf issue)
Fix various cases where incorrect correlation could happen
Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation
Correlate by axis motion as well as button presses
Fix failing to zero other trigger
Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init()
Add missing device to device names
Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices

Updated to SDL 2.0.13 code with the following notes:
New HID driver: xbox360w - no idea what that is, hopefully urelated
SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data.
SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem.
Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason.
Something changed in how devices get names, so getting generic names.
Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
2020-03-16 12:25:02 -07:00
Sam Lantinga 4dea340ca7 Fixed bug 4477 - Support more than 4 XInput-capable devices on Windows
Jimb Esser

Add new RawInput controller API, and improved correlation with XInput/WGI

Reorder joystick init so drivers can ask the others if they handle a device reliably
Do not poll disconnected XInput devices (major perf issue)
Fix various cases where incorrect correlation could happen
Simple mechanism for propagating unhandled Guide button presses even before guaranteed correlation
Correlate by axis motion as well as button presses
Fix failing to zero other trigger
Fix SDL_HINT_JOYSTICK_HIDAPI not working if set before calling SDL_Init()
Add missing device to device names
Disable RawInput if we have a mismatch of XInput-capable but not RawInput-capable devices

Updated to SDL 2.0.13 code with the following notes:
New HID driver: xbox360w - no idea what that is, hopefully urelated
SDL_hidapijoystick.c had been refactored to couple data handling logic with device opening logic and device lists caused some problems, yields slightly uglier integration than previously when the 360 HID device driver was just handling the data.
SDL_hidapijoystick.c now often pulls the device off of the joystick_hwdata structure for some rumble logic, but it appears that code path is never reached, so probably not a problem.
Looks like joystick_hwdata was refactored to not include a mutex in other drivers, maintainers may want to do the same refactor here if that's useful for some reason.
Something changed in how devices get names, so getting generic names.
Had to fix a (new?) bug where removing an XInput controller caused existing controllers (that moved to a new XInput index) to get identified as 0x045e/0x02fd ("it's probably Bluetooth" in code), rendering the existing HIDAPI_IsDevicePresent and new RAWINPUT_IsDevicePresent unreliable.
2020-03-16 12:23:38 -07:00
David Ludwig b2296506bc virtual joysticks: MSVC support part 1/2, make driver's .c file be uniquely named 2020-03-15 15:05:36 -04:00
David Ludwig cc90875647 virtual joysticks: removed ball support (Bug 5028) 2020-03-15 13:25:49 -04:00
Sam Lantinga 151c8fbf19 Fixed build error
Malte Kie?ling

I get a build error in SDL_sysjoystick.c:74 for the merged patch, but its nothing to sweat about, just -Werror=declaration-after-statement doing its usual stuff.
2020-03-14 17:45:00 -07:00
Sam Lantinga 1ff483d1f3 Added SDL_GetErrorMsg() to get the error message in a thread-safe way 2020-03-13 21:28:09 -07:00
Sam Lantinga 19c3484469 Fixed slow enumeration when Apple Cinema HD display 30" is plugged in 2020-03-13 19:19:29 -07:00
Ethan Lee 133b475586 Use LIBUSB_CALL for hidapi's read_callback function 2020-03-11 14:17:19 -04:00
Sam Lantinga 2be75c6a61 Fixed bug 5028 - Virtual Joysticks (new joystick backend)
David Ludwig

I have created a new driver for SDL's Joystick and Game-Controller subsystem: a Virtual driver.  This driver allows one to create a software-based joystick, which to SDL applications will look and react like a real joystick, but whose state can be set programmatically.  A primary use case for this is to help enable developers to add touch-screen joysticks to their apps.

The driver comes with a set of new, public APIs, with functions to attach and detach joysticks, set virtual-joystick state, and to determine if a joystick is a virtual-one.

Use of virtual joysticks goes as such:

1. Attach one or more virtual joysticks by calling SDL_JoystickAttachVirtual.  If successful, this returns the virtual-device's joystick-index.
2. Open the virtual joysticks (using indicies returned by SDL_JoystickAttachVirtual).
3. Call any of the SDL_JoystickSetVirtual* functions when joystick-state changes.  Please note that virtual-joystick state will only get applied on the next call to SDL_JoystickUpdate, or when pumping or polling for SDL events (via SDL_PumpEvents or SDL_PollEvent).


Here is a listing of the new, public APIs, at present and subject to change:

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

/**
 * Attaches a new virtual joystick.
 * Returns the joystick's device index, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickAttachVirtual(SDL_JoystickType type, int naxes, int nballs, int nbuttons, int nhats);

/**
 * Detaches a virtual joystick
 * Returns 0 on success, or -1 if an error occurred.
 */
extern DECLSPEC int SDLCALL SDL_JoystickDetachVirtual(int device_index);

/**
 * Indicates whether or not a virtual-joystick is at a given device index.
 */
extern DECLSPEC SDL_bool SDLCALL SDL_JoystickIsVirtual(int device_index);

/**
 * Set values on an opened, virtual-joystick's controls.
 * Returns 0 on success, -1 on error.
 */
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualAxis(SDL_Joystick * joystick, int axis, Sint16 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualBall(SDL_Joystick * joystick, int ball, Sint16 xrel, Sint16 yrel);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualButton(SDL_Joystick * joystick, int button, Uint8 value);
extern DECLSPEC int SDLCALL SDL_JoystickSetVirtualHat(SDL_Joystick * joystick, int hat, Uint8 value);

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

Miscellaneous notes on the initial patch, which are also subject to change:

1. no test code is present in SDL, yet.  This should, perhaps, change.  Initial development was done with an ImGui-based app, which potentially is too thick for use in SDL-official.  If tests are to be added, what kind of tests?  Automated?  Graphical?

2. virtual game controllers can be created by calling SDL_JoystickAttachVirtual with a joystick-type of SDL_JOYSTICK_TYPE_GAME_CONTROLLER, with naxes (num axes) set to SDL_CONTROLLER_AXIS_MAX, and with nbuttons (num buttons) set to SDL_CONTROLLER_BUTTON_MAX.  When updating their state, values of type SDL_GameControllerAxis or SDL_GameControllerButton can be casted to an int and used for the control-index (in calls to SDL_JoystickSetVirtual* functions).

3. virtual joysticks' guids are mostly all-zeros with the exception of the last two bytes, the first of which is a 'v', to indicate that the guid is a virtual one, and the second of which is a SDL_JoystickType that has been converted into a Uint8.

4. virtual joysticks are ONLY turned into virtual game-controllers if and when their joystick-type is set to SDL_JOYSTICK_TYPE_GAMECONTROLLER.  This is controlled by having SDL's default list of game-controllers have a single entry for a virtual game controller (of guid, "00000000000000000000000000007601", which is subject to the guid-encoding described above).

5. regarding having to call SDL_JoystickUpdate, either directly or indirectly via SDL_PumpEvents or SDL_PollEvents, before new virtual-joystick state becomes active (as specified via SDL_JoystickSetVirtual* function-calls), this was done to match behavior found in SDL's other joystick drivers, almost all of which will only update SDL-state during SDL_JoystickUpdate.

6. the initial patch is based off of SDL 2.0.12

7. the virtual joystick subsystem is disabled by default.  It should be possible to enable it by building with SDL_JOYSTICK_VIRTUAL=1



Questions, comments, suggestions, or bug reports very welcome!
2020-03-13 19:08:45 -07:00
Sam Lantinga 879f137aec Added support for the older Xbox One S Bluetooth controller report format 2020-03-13 19:00:24 -07:00
Sam Lantinga d662a65964 Fixed crash if manufacturer or product string is NULL 2020-03-13 19:00:22 -07:00
Sam Lantinga 255c9c23d4 Fixed bug 4921 - Do not swap B/X buttons on GameCube controller unless it's requested
The binding for the Mayflash GameCube controller adapter now respects the SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS hint
2020-03-13 13:28:33 -07:00
Sam Lantinga 6318765d54 Handle entirely duplicated joystick product names, as well as vendor and product names that start with the name of the vendor, but with different case (e.g. 8bitdo 8BitDo) 2020-03-13 13:05:43 -07:00
Sam Lantinga de2001eeee Fixed binding the D-PAD on the 8BitDo M30 controller 2020-03-13 13:05:40 -07:00
Sam Lantinga cb2f78b12d Updated 8BitDo SF30 Pro mapping with hint support, added Android binding for the 8BitDo M30 Gamepad 2020-03-13 13:05:38 -07:00
Sam Lantinga cb986aff9f Fixed exception at shutdown if the controllers are closed after the HIDDeviceManager is shutdown 2020-03-13 13:05:32 -07:00
Sam Lantinga 80d075a01a Fixed compiler warnings 2020-03-13 09:43:48 -07:00
Sam Lantinga 5722e88481 Fixed build warnings 2020-03-12 19:49:33 -07:00
Sam Lantinga c44473ba73 Unified code to standardize joystick names 2020-03-12 19:47:30 -07:00
Sam Lantinga db3b3a1d84 Added support for SDL hints in the game controller mapping database 2020-03-12 19:47:28 -07:00
Sam Lantinga 93ed3c8baf Updated SDL to version 2.0.13 for development builds 2020-03-10 18:25:47 -07:00
Sam Lantinga 983bbf9ef3 Backed out changeset 51622f74dc85 2020-03-10 18:35:31 -07:00
Sam Lantinga 9fdc6cf307 Removed Xbox HIDAPI debug code 2020-03-10 18:34:33 -07:00
Sam Lantinga 4fb06a2a38 Updated SDL to version 2.0.13 for development builds 2020-03-10 18:25:47 -07:00
Sam Lantinga fe97992185 Read the buttons on Nintendo Switch and GameCube controllers as they are labeled, and swap them if the applications wants positional button data instead. 2020-03-10 17:35:14 -07:00
Sam Lantinga 4caa6a0688 Fixed bug 4921 - Do not swap B/X buttons on GameCube controller unless it's requested
Ethan Lee

Basically replicating the solution of the Switch Controller's button label issue. Physical layout should take priority unless it's explicitly requested by the user or application!
2020-03-10 16:41:42 -07:00
Sam Lantinga 342f62ca69 Fixed bug 5022 - SDL_iconv_string can get stuck in an infinite loop when encountering invalid characters
ciremo6483

In `SDL_iconv_string` the `while (inbytesleft > 0)` loop can end up in a state where it never terminates because the library `iconv` function called from `SDL_iconv` doesn't consume any bytes.

This happened when a `WCHAR_T` input string was being converted to `UTF-8` but contained invalid characters. It would first It would first skip a few bytes due to `case SDL_ICONV_EILSEQ` but when there were 3 bytes remaining of `inbytesleft` `iconv` just didn't consume anything more (but didn't throw an error either).

It just so happens that the Microsoft Classic IntelliMouse `product_string` contains such invalid characters (`"Microsoft? Classic IntelliMouse?"`), meaning the function would get stuck with said mouse plugged in.

A fix for this would be to check if `inbytesleft` was unchanged after an iteration and in that case either decrement the counter like when `SDL_ICONV_EILSEQ` is returned or simply break the loop.
2020-03-10 16:29:28 -07:00
Sam Lantinga 1f4965c8c4 Fixed warnings building with mingw64 2020-03-08 21:24:06 -07:00
Sam Lantinga c8c05a9fc3 Fixed bug 4991 - Pixel shader problem when recreating a texture for direct3d renderer
cmediaplayer

Hi, i already mentioned in the SDL discourse a bug that recreating of a texture occours pixel shader problem on direct3d renderer. There is no problem for direct3d11. You can see the issue by using my app named C Media Player which is available for Windows for free using my web site www.cmediaplayer.com. Just follow the steps:

*Open a media file
*When playing the file change the scale quality under the video menu.
*You will see the problem.
2020-03-08 19:23:21 -07:00
Sam Lantinga 367a356132 Don't release the backbuffer on error, we didn't acquire it. 2020-03-08 18:56:07 -07:00
Cameron Gutman 4e0fb110c8 Clear the old player index slot when moving to a new one 2020-03-07 19:21:21 -08:00
Cameron Gutman 165ccaa85b Fix incorrect player index when assigning a joystick the same index twice
Prior to this fix, we would hit the existing_instance >= 0 case and move the joystick
again to a different index than the one requested by the caller. It also breaks the assumption
that a SDL_JoystickID is only present in SDL_joystick_players at one location.
2020-03-07 17:20:04 -08:00
Cameron Gutman e152a3cedb direct3d: Don't attempt to create zero sized vertex buffer 2020-03-07 13:59:42 -08:00
Cameron Gutman 467434b92d Added support for indicating player index on DS4 controllers 2020-03-07 13:17:28 -08:00
Sam Lantinga 82be6dd7c9 Fixed regression in bug 4966 - KMSDRM: Add dynamic modeset support
Anthony Pesch

I was just communicating with one of the Retropie developers regarding this.

This change removed the forced window focus change on creation (3534cb3793) as part of the change no longer assumes there's only a single window being created. This was perhaps an over-aggressive removal.

Due to that change, joystick events are only received if SDL_SetKeyboardFocus is called explicitly, or if the app has specified SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS.

I think that part of my change should be reverted to continue setting mouse / keyboard focus to the window being created. If SDL_WINDOW_INPUT_FOCUS is to be used as an input flag the code could be conditional, but that would still leave existing software broken.
2020-03-07 08:48:04 -08:00
Ethan Lee 27889d0261 winrt: Wait for EnumerationCompleted before leaving WASAPI_EnumerateEndpoints 2020-03-03 12:31:41 -05:00
Sam Lantinga e9bc21fba5 Fixed rumble for third-party Nintento Switch Pro controllers
The 8BitDo SF30 Pro Gamepad will generate a single motor pulse for each rumble message, so we need to do this frequently to have continous rumble on this device.
2020-03-04 17:10:37 -08:00
Sam Lantinga 428cfddb4c Fixed crash when a controller is disconnected while rumble is pending 2020-03-04 14:59:44 -08:00
Sam Lantinga 281d05a6d1 Fixed handling the guide button with both V1 and V2 of the Xbox One Bluetooth wireless protocols 2020-03-04 09:42:10 -08:00
Sam Lantinga 69a8c8468c Fixed using more than one Xbox Bluetooth controller
Don't prevent duplicate devices using hidraw, instead libusb takes precedence and all hidraw devices that aren't handled by libusb are available
2020-03-04 09:42:08 -08:00
Sam Lantinga 2a91f682b5 Fixed bug 5012 - KaiOS keycodes support
pelya

KaiOS is an OS for feature phones, with numeric keypad and non-touch screen, and typically 512 Mb RAM and 4 Gb flash.
It is based on Firefox OS, all apps are made with HTML5 and Javascript. SDL can be cross-compiled using emscripten and packaged as native app.
This patch adds support for star '*' and pound '#' keys on such phones to generate SDL events.
2020-03-03 17:56:33 -08:00
Sam Lantinga 96836ec643 Add 500ms max wait time for hid_write to complete on Windows
It appears that with some (presumably) flaky drivers or hardware that the WriteFile in hid_write never completes leading to GetOverlappedResult to block forever waiting for it.
2020-03-03 09:22:43 -08:00
Sam Lantinga 07000bfc33 Fixed bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application
Jake Breen

I have tracked it down to a call on
hid_device_info() -> HidD_GetManufacturerString (Line 499 in src\hidapi\windows\hid.c)
2020-03-02 17:31:58 -08:00
Sam Lantinga aa384ad02b Fixed bug 5001 - Feature request: SDL_isupper & SDL_islower 2020-03-02 15:21:07 -08:00
Sam Lantinga 3b3ae4d14d Possible fix for bug 5010 - SDL_Init with SDL_INIT_JOYSTICK hangs for 10 seconds when playing audio from another application
Jake Breen

When I run SDL_INIT with SDL_INIT_JOYSTICK it stalls for about 10 seconds (last report was 10,615ms), but only if I'm currently playing audio. (Like in Spotify for example.)

querying something related to device access (last dll loaded)
'BabbysFirst64.exe' (Win32): Loaded 'C:\Windows\SysWOW64\deviceaccess.dll'.

I use a USB DAC because my mobo's audio out is pretty not great. And I've noticed unplugging it seems to solve the issue. I haven't noticed any other issues that are caused by my DAC.

My DAC is the Sound BlasterX G1 https://us.creative.com/p/gaming-headsets/sound-blasterx-g1
Vid = 041E
PID = 3249

My system specs:
- Windows 10 Pro
- Ryzen 2700x
- 16GB Ram
- Nvidia 2070 RTX

Additional USB devices plugged in:
- Valve Index
- Xbox One Elite Controller
2020-03-02 15:06:47 -08:00
Sam Lantinga a19757ac8d Fixed bug 5007 - Segfault in KMSDRM_VideoQuit() on Raspberry Pi Zero with no display attached
Charles Huber

This patch fixes the segfault on my Pi, though the valid display index range reported by the CHECK_DISPLAY_INDEX() macro in src/video/SDL_video.c is a little weird:

$ SDL_VIDEO_EGL_DRIVER=libEGL.so SDL_VIDEO_GL_DRIVER=libGLESv2.so ./a.out
SDL_Init(): displayIndex must be in the range 0 - -1
2020-03-02 14:55:40 -08:00
Sam Lantinga eb19631a1e This controller firmware is supported on Windows, and is covered by the Bluetooth check on Mac OSX 2020-03-02 10:57:57 -08:00
Sam Lantinga 49564c8b8d Added support for the PDP Victrix Pro FS with Touch Pad for PS4 2020-03-02 10:47:48 -08:00
Sam Lantinga 4572dd2ae6 Fixed bug 4854 - Add a way to extend the values in controller_type.h
Added a hint SDL_HINT_GAMECONTROLLERTYPE to allow overriding the built-in controller type database
2020-03-02 10:37:28 -08:00
Sam Lantinga 27f346a058 Fixed compile warning 2020-03-02 09:46:37 -08:00
Sam Lantinga 339612d5af ControllerList: add support for Victrix Pro FS w/ Touchpad for PS4 2020-03-02 09:35:12 -08:00
Sam Lantinga 52be663380 Use SDL math functions in Steam Controller support 2020-03-02 09:35:09 -08:00
Sam Lantinga 756d2073fe Updated the HIDAPI Xbox One driver with support for Bluetooth Xbox One controllers 2020-03-02 09:26:12 -08:00
Sam Lantinga 997f3e9e82 Fixed build warnings 2020-03-02 09:03:55 -08:00
Sam Lantinga bebc486774 We already have a hidapi implementation for Windows, we don't need libusb 2020-03-01 17:53:30 -08:00
Sam Lantinga 74ed215618 Updated version to 2.0.12 for release candidate build 2020-03-01 14:58:16 -08:00
Sam Lantinga 6590d078d7 Fixed bug 4996 - Mac: XBoxOne Bluetooth rumble isn't working
rofferom

I have an annoying issue on MacOS about XBoxOne Bluetooth rumble (Vendor: 0x045e, Product: 0x02fd).

When 360controller is installed, rumble is working correctly. However, Bluetooth rumble isn't working at all, with or without 360controller installed (although it is working with Chrome + https://html5gamepad.com).

I looked at the code, and it seems that XBox controllers are managed in MacOS in this file: SDL_hidapi_xbox360.c. The XBoxOne file is disabled for MacOS in SDL_hidjoystick_c.h.

The function HIDAPI_DriverXbox360_Rumble() is called correctly, and hid_write() returns no error.

I have tried a stupid test. I took the rumble packet from 360controller: ec4e88eb2d/XBOBTFF/FFDriver.cpp (L620). With the patch I have attached, I manage to have rumble working on Bluetooth (with some stupid vibration level, but it proves it can if the packet is changed).

But it breaks the USB rumble with 360controller. A comment in the function makes an explicit reference to 360controller, I think that's why I have broken this specific usecase.

I don't know what is the correct way to fix this, but it seems that the current implementation has a missing case for Bluetooth support.


Note that I also tested master this morning, and I have another issue:
    if (!device->ffservice) {
        return SDL_Unsupported();
    }

test fails in DARWIN_JoystickRumble(). This test has been done quickly, I'm not totaly confident about its accuracy.
2020-03-01 14:52:49 -08:00
Romain Roff? 5346216368 mac: Fix gamepad detection 2020-03-01 13:01:53 -08:00
Sam Lantinga 51e9e98451 Fixed whitespace 2020-03-01 13:00:50 -08:00
Sam Lantinga 8a6f1aa5f5 Fixed bug 4369 - Going fullscreen with green knob in MacOS freezes app for 15 seconds.
Elmar

creating a fullscreen window with SDL_CreateWindow(..SDL_WINDOW_FULLSCREEN_DESKTOP..) in MacOS works fine, except if it was triggered by the user with the green knob in the top left window title bar.

Then "something" is different, and SDL_CreateWindow hangs for 15-20 seconds (tested in MacOS 10.13 and 10.14).

Responsible for the hang is this code in SDL_cocoawindow.m - Cocoa_SetWindowFullscreenSpace:

        const int maxattempts = 3;
        int attempt = 0;
        while (++attempt <= maxattempts) {
            /* Wait for the transition to complete, so application changes
             take effect properly (e.g. setting the window size, etc.)
             */
            const int limit = 10000;
            int count = 0;
            while ([data->listener isInFullscreenSpaceTransition]) {
                if ( ++count == limit ) {
                    /* Uh oh, transition isn't completing. Should we assert? */
                    break;
                }
                SDL_Delay(1);
                SDL_PumpEvents();
            }
            if ([data->listener isInFullscreenSpace] == (state ? YES : NO))
                break;
            /* Try again, the last attempt was interrupted by user gestures */
            if (![data->listener setFullscreenSpace:(state ? YES : NO)])
                break; /* ??? */
        }

One trivial workaround is to change 'const int limit = 10000' to 500. Then the freeze is so short that it doesn't look like a freeze to the user.

Looking further into the problem, I observed that the function Cocoa_SetWindowFullscreenSpace recursively calls itself via some ObjectiveC messages. I managed to extract a callstack for this (copied below): Note how Cocoa_SetWindowFullscreenSpace in stack line 22 calls SDL_PumpEvents, which eventually arrives at  SDL_SendWindowEvent, which calls SDL_UpdateFullscreenMode (stack line 0), which then calls Cocoa_SetWindowFullscreenSpace again (not shown). This recursive second call is the one that hangs.

Another "solution" that worked for me was to add a flag to SDL_Window that is set in Cocoa_SetWindowFullscreenSpace and causes this function to return immediately if called from itself.

Obviously, this is also an ugly hack, but I don't have enough time to dive into this crazy Cocoa/ObjectiveC business deep enough to find a proper solution. But hopefully it's easy for one of the experts around.

Note that there is a "failure to go fullscreen"-message involved, maybe using the green knob causes this failure at first.

I can unfortunately not provide a minimum example.

Best regards,
Elmar

0   com.yasara.View               	0x00000001007495af SDL_UpdateFullscreenMode + 207
1   com.yasara.View               	0x00000001006e2591 SDL_SendWindowEvent + 401
2   com.yasara.View               	0x0000000100775a72 -[Cocoa_WindowListener windowDidResize:] + 370
3   com.yasara.View               	0x0000000100776550 -[Cocoa_WindowListener windowDidExitFullScreen:] + 512
4   com.apple.AppKit              	0x00007fff3180a2a4 -[_NSWindowEnterFullScreenTransitionController failedToEnterFullScreen] + 692
5   com.apple.AppKit              	0x00007fff31c59737 -[_NSEnterFullScreenTransitionController _doFailedToEnterFullScreen] + 349
6   com.apple.AppKit              	0x00007fff3172aa53 __NSFullScreenDockConnectionSendEnterForSpace_block_invoke + 135
7   libxpc.dylib                  	0x00007fff6114b9b1 _xpc_connection_reply_callout + 36
8   libxpc.dylib                  	0x00007fff6114b938 _xpc_connection_call_reply_async + 82
9   libdispatch.dylib             	0x00007fff60ec7e39 _dispatch_client_callout3 + 8
10  libdispatch.dylib             	0x00007fff60ede3b0 _dispatch_mach_msg_async_reply_invoke + 322
11  libdispatch.dylib             	0x00007fff60ed2e25 _dispatch_main_queue_callback_4CF + 807
12  com.apple.CoreFoundation      	0x00007fff33d39e8b __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13  com.apple.CoreFoundation      	0x00007fff33d3959a __CFRunLoopRun + 2335
14  com.apple.CoreFoundation      	0x00007fff33d38a28 CFRunLoopRunSpecific + 463
15  com.apple.HIToolbox           	0x00007fff32fd1b35 RunCurrentEventLoopInMode + 293
16  com.apple.HIToolbox           	0x00007fff32fd1774 ReceiveNextEventCommon + 371
17  com.apple.HIToolbox           	0x00007fff32fd15e8 _BlockUntilNextEventMatchingListInModeWithFilter + 64
18  com.apple.AppKit              	0x00007fff3128deb7 _DPSNextEvent + 997
19  com.apple.AppKit              	0x00007fff3128cc56 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
20  com.yasara.View               	0x000000010076fab2 Cocoa_PumpEvents + 290
21  com.yasara.View               	0x00000001006dd1c7 SDL_PumpEvents_REAL + 23
22  com.yasara.View               	0x00000001007795cf Cocoa_SetWindowFullscreenSpace + 223
23  com.yasara.View               	0x000000010074970b SDL_UpdateFullscreenMode + 555
24  com.yasara.View               	0x00000001006e2476 SDL_SendWindowEvent + 118
25  com.yasara.View               	0x0000000100774ff7 -[Cocoa_WindowListener resumeVisibleObservation] + 135
26  com.yasara.View               	0x000000010077664c Cocoa_ShowWindow + 188
27  com.yasara.View               	0x0000000100749492 SDL_FinishWindowCreation + 546
28  com.yasara.View               	0x0000000100748da5 SDL_CreateWindow_REAL + 1573
29  com.yasara.View               	0x000000010010d9b1 vga_setvideomode + 1347
30  com.yasara.View               	0x00000001003f0d46 mod_initscreen + 2614
31  com.yasara.View               	0x00000001003f344b mod_reinitscreen + 460
32  com.yasara.View               	0x00000001003f370d mod_resizescreen + 383
33  com.yasara.View               	0x0000000100418e39 mod_main + 815
34  com.yasara.View               	0x000000010029ca5d main2 + 5766
35  com.yasara.View               	0x000000010011d1b7 main.main_cpuok + 19
2020-03-01 12:58:50 -08:00
Sam Lantinga bd5da73afd Fixed bug 4992 - UWP/WinRT does not set thread priority when using SDL_SetThreadPriority
Ethan Lee

Attached is a diff that I used to get SetThreadPriority working locally. I still have no idea what the minimum SDK version is since Microsoft never documented it, but it's worth pointing out that they're much more aggressive about using the latest VS and UWP SDK anyway (for example, an updated Xbox is no longer compatible with VS2017, and updates are required to have a network connection of any kind).
2020-03-01 12:50:42 -08:00
Sam Lantinga 1af31a26d1 Fixed trying to handle the HORI Wireless Switch Pad when connected via USB 2020-02-27 13:53:32 -08:00
Sam Lantinga 20d67446e0 Xbox One controller rumble doesn't need synchronization if you use a packet counter of 0 2020-02-27 09:33:32 -08:00
Sam Lantinga 9013c9169c Fixed bug 5005 - warnings in kmsdrm
Malte Kie?ling

At the moment i get following warnings from kmsdrm:

 * in SDL_kmsdrmvideo.c KMSDRM_DestroySurfaces is return type int, but thats never returned or checked against
 * in SDL_kmsdrmvideo.c KMSDRM_DestroySurfaces the variable viddata is not used
 * in SDL_kmsdrmopengles.c KMSDRM_GLES_LoadLibrary a cast to NativeDisplayType is missing

I attached a patch for them :)
2020-02-27 08:20:34 -08:00
Sam Lantinga 7f26ff237d Fixed bug 4987 - Can't build on MinGW a recent state (15'th February, 2020): conflicting types 2020-02-27 08:18:20 -08:00
Sylvain Becker 21a2e0c787 Fix compilation C90 mixed declarations and code (Thanks Cameron Gutman !) 2020-02-25 06:53:51 +01:00
Sylvain Becker e2b132ca74 Better fix to set the palette opaque, when there is also a colorkey
(see bug 3827)
2020-02-24 21:57:03 +01:00
Sam Lantinga e3b0713e40 Don't call setPreferredOutputNumberOfChannels on iOS, it breaks audio output 2020-02-24 12:07:18 -08:00
Sam Lantinga 2c9871a4a8 Fixed surround sound support on Apple TV 2020-02-24 10:25:57 -08:00
Sylvain Becker f485766005 Fix: set to opaque when a palette surface is converted to an alpha format. 2020-02-23 23:07:15 +01:00
Sylvain Becker bf8aa1edae Fix regression: when a palette + colorkey is converted, it needs a blend mode.
- Regression of test_1.c of bug 3827, after fix from bug 4798.
- Blending is also needed when the palette contains alpha value, but not necessarily colorkey.
- Clean up SDL_ConvertColorkeyToAlpha which doesn't seem to need 'ignore_alpha' parameter any-more.

(see bug 3827)
2020-02-23 22:38:08 +01:00
Ryan C. Gordon 094655cff9 cocoa: Make sure wait for button enable can't be infinite. 2020-02-23 14:49:03 -05:00
Ryan C. Gordon 723165187f cocoa: Removed a debug printf that was accidentally committed. 2020-02-23 14:48:48 -05:00
Sylvain Becker 9a7c2b2246 Fixed bug 4999 - Palette surface always promoted to alpha (Thanks Cameron Gutman!)
MSVC Static analysis: Incorrect alpha_value check in SDL_render.c
(see also bug 4425)
2020-02-23 09:59:52 +01:00
Ryan C. Gordon 4d9e6e5f70 cocoa: When exiting a fullscreen space, wait for window state to normalize.
A good metric of this is when the titlebar's "minimize" button is reenabled,
which doesn't happen by the time windowDidExitFullscreen triggers.

This fixes minimizing a fullscreen window on macOS.

Fixes Bugzilla #4177.
2020-02-21 14:50:09 -05:00
Sam Lantinga 8d14636326 Fixed support for third party Xbox 360 wireless controller dongle 2020-02-19 08:26:00 -08:00
Ryan C. Gordon 44698c4970 dynapi: Fixed build on non-Android platforms. 2020-02-18 01:44:07 -05:00
Sam Lantinga ad225047b6 Added Android SDK conditionals to game controller mappings
The Nintendo Switch Pro controller has a different mapping on Android 10 and newer
2020-02-17 14:15:47 -08:00
Sam Lantinga d7ece7ee6f Made SDL_GetAndroidSDKVersion() available for applications 2020-02-17 13:54:45 -08:00
Ryan C. Gordon 93b26f172c opengl: Backed out hg changeset 94f9f40a957f
This is the OpenGL line drawing fix for Bugzilla #3182, but there's some
disagreement about what the renderers should do here, so I'm backing this out
until after 2.0.12 ships, and then we'll reevaluate all the renderer backends
to decide what's correct, and make them all work the same.
2020-02-17 16:15:04 -05:00
Ryan C. Gordon 1b82606e1d x11: Wait a bit in SDL_SetWindowSize() to see if window manager vetoed change.
Same idea as the fix for Bugzilla #4646.

Fixes Bugzilla #4727.
2020-02-17 16:11:18 -05:00
Ryan C. Gordon e731522578 x11: Don't delay an extra 10ms if we were just going to break out of the loop. 2020-02-17 15:02:37 -05:00