Commit Graph

4825 Commits

Author SHA1 Message Date
Eric Wasylishen
a0e055a7f9 testwm2: add mode menu, click on a mode to call SDL_SetWindowDisplayMode 2021-11-07 08:42:09 -08:00
Eric Wasylishen
70f7ebe635 SDL_test_font.c: add ability to draw on different SDL_Renderers
fixes `testwm2 --windows 2`
2021-11-07 08:42:09 -08:00
Cameron Gutman
6312aaea0f WGI: Add workaround for delayed callbacks after WGI_JoystickQuit() 2021-11-06 21:35:01 -07:00
Sam Lantinga
2248a54937 Update the focus in case we changed focus to a child window and then away from the application
In this case we'll get WM_KILLFOCUS when the child window is focused, but we'll retain focus on the top level window, but when we Alt-Tab away, we won't get another WM_KILLFOCUS or WM_NCACTIVATE, we get WM_ACTIVATE instead, so we need to check for focus updates in response to that as well.
2021-11-05 22:52:18 -07:00
Ozkan Sezer
6407d4b0a8 remove unnecessary parentheses from SDL_abs() 2021-11-05 17:10:02 +03:00
Kevin Colour
6cbee0634e include: Swap parameter names in atan2 functions 2021-11-05 17:04:00 +03:00
Cameron Gutman
2371b247ff windows: improve feature detection consistency between CMake and non-CMake builds 2021-11-03 08:41:36 -07:00
superzazu
839ca0ea64
SDL_OpenURL (macOS): try to open path if the url cannot be opened (#4830)
* SDL_OpenURL (macOS): try to open path if the url cannot be opened

* SDL_OpenURL (macOS): use CFURLCreateWithBytes & LSOpenCFURLRef to correctly escape input

* fix type casting + indentation
2021-11-03 08:35:24 -07:00
Sam Lantinga
8593076da7 Fixed whitespace 2021-11-02 16:04:36 -07:00
Brick
62629c2b5d Fix 64-bit timeval/timespec delta calculations 2021-11-02 16:02:18 -07:00
Sam Lantinga
6d5edfa733 Fixed crash on Android 8, due to bugs in AAudio implementation 2021-11-02 15:59:26 -07:00
Frank Praznik
43ddc59fa8
Export SDL_LinuxSetThreadPriorityAndPolicy() function (#4877)
It's marked as being a public symbol internally, however, it was missing from the header files and not visible in the shared library.  This adds it to the necessary headers and to the DynAPI list to expose it for use by applications.

Co-authored-by: Frank Praznik <frank.praznik@oh.rr.com>
2021-11-02 13:56:14 -07:00
Ivan Epifanov
848d7b1254 Vita: Implement command batching 2021-11-02 13:43:22 -07:00
Ivan Epifanov
3f7a94fc94 Vita: Remove FillRects 2021-11-02 13:43:22 -07:00
Cameron Gutman
f73376ae24 events: Add logging for SDL_CONTROLLERTOUCHPAD*, SDL_CONTROLLERSENSORUPDATE, and SDL_SENSORUPDATE events 2021-11-02 00:31:25 -05:00
Ryan C. Gordon
2379c52849 os/2: Don't try to be clever with the 32-bit GetTicks fallback. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon
cca79d32a2 android: Patched SDL_GetTicks64() to compile. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon
affb183ea4 unix: Fixed SDL_GetTicks64 function signature. 2021-11-01 14:28:00 -04:00
Ryan C. Gordon
99c9727dc0 timer: Added SDL_GetTicks64(), for a timer that doesn't wrap every ~49 days.
Note that this removes the timeGetTime() fallback on Windows; it is a
32-bit counter and SDL2 should never choose to use it, as it only is needed
if QueryPerformanceCounter() isn't available, and QPC is _always_ available
on Windows XP and later.

OS/2 has a similar situation, but since it isn't clear to me that similar
promises can be made about DosTmrQueryTime() even in modern times, I decided
to leave the fallback in, with some heroic measures added to try to provide a
true 64-bit tick counter despite the 49-day wraparound. That approach can
migrate to Windows too, if we discover some truly broken install that doesn't
have QPC and still depends on timeGetTime().

Fixes #4870.
2021-11-01 14:28:00 -04:00
Northfear
fba82ad1cb Remove sceGxmFinish from RenderPresent on Vita. Make sure that rendering is finished on render texture during locking 2021-10-31 09:17:13 -04:00
Sam Lantinga
a01aaf053c Fixed compiler warning 2021-10-30 21:42:07 -07:00
Cameron Cawley
4d3da5b75b riscos: Disable the mouse pointer for now 2021-10-30 21:25:01 -07:00
Cameron Cawley
1c256b892e riscos: Fix enumerating screen modes 2021-10-30 21:25:01 -07:00
Cameron Cawley
5a3c97f3a3 riscos: Fix detection of the current mode 2021-10-30 21:25:01 -07:00
Cameron Cawley
53b3db0c5d Handle the KMOD_SCROLL modifier on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley
1268984edc Implement mouse input on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley
f7f54f0d04 Implement keyboard input on RISC OS
Partially based on a patch from http://www.riscos.info/websvn/listing.php?repname=gccsdk&path=%2Ftrunk%2Fautobuilder%2Flibraries%2Fsdl%2Flibsdl2%2F&rev=7174#a6401c766f408f1ea356e6977894cc6a5
Currently lacks support for mapping scancodes to keycodes.
2021-10-30 21:25:01 -07:00
Cameron Cawley
f8a8ca3e1f Support proper mode switching on RISC OS 2021-10-30 21:25:01 -07:00
Cameron Cawley
fe9bb74764 riscos: Refactor framebuffer code 2021-10-30 21:25:01 -07:00
Cameron Cawley
25c71748ad Add a barebones RISC OS video driver 2021-10-30 21:25:01 -07:00
Cameron Gutman
a559864968 x11/wayland: Fix signal handling while blocking in WaitEventTimeout()
Add a new flag to avoid suppressing EINTR in SDL_IOReady(). Pass the
flag in WaitEventTimeout() to ensure that a SIGINT will wake up
SDL_WaitEvent() without another event coming in.
2021-10-30 21:23:45 -07:00
Cameron Gutman
c97c46877f core: Convert SDL_IOReady()'s 2nd parameter to flags 2021-10-30 21:23:45 -07:00
Ryan C. Gordon
8a4a282aaa
alsa: Make hotplug thread optional.
Even without the thread, it'll do an initial hardware detection at startup,
but there won't be any further hotplug events after that. But for many cases,
that is likely complete sufficient.

In either case, this cleaned up the code to no longer need a semaphore at
startup.

Fixes #4862.
2021-10-30 16:02:12 -04:00
Sam Lantinga
26706319d7 Ignore the ASRock LED controller, it's not a joystick 2021-10-30 05:53:12 -07:00
Cameron Gutman
ac54d57aa5 event: Check subsystem initialization before events or devices
SDL_WasInit() is cheaper SDL_NumJoysticks()/SDL_NumSensors().
2021-10-27 22:35:56 -05:00
Cameron Gutman
1bc6dc3ea0 event: Cap maximum wait time if sensor or joystick subsystems are active
Joystick and sensor subsystems require periodic polling to detect new devices.
2021-10-27 22:35:56 -05:00
Cameron Gutman
2bf36bfac4 wayland: Implement WaitEventTimeout() and SendWakeupEvent()
We can have spurious wakeups in WaitEventTimeout() due to Wayland events
that don't end up causing us to generate an SDL event. Fortunately for us,
SDL_WaitEventTimeout_Device() handles this situation properly by calling
WaitEventTimeout() again with an adjusted timeout.
2021-10-27 19:16:53 -05:00
Ivan Epifanov
9c799802c9 Vita: fix IME input languages 2021-10-26 08:29:56 -07:00
David Gow
c57bcb47b1 test: Fix building with libunwind under autotools
There are two issues which are stopping the SDL tests from building on
my machine:
- libunwind is not being linked
- Even if it is, it is missing several symbols.

The first is fixed by having the test programs link against libunwind if
available. Technically, SDL2_test should be linking against it, as it's
used in SDL_test_memory.c, but as SDL2_test is a static library, it
can't itself import libunwind. We just assume that if it's present on
the system, we should link it directly to the test programs. This should
strictly be an improvement, as the only case where this'd fail is if
SDL2 was compiled when libunwind was present, but the tests are being
compiled without it, and that'd fail anyway.

The second is fixed by #define-ing UNW_LOCAL_ONLY before including
libunwind.h: this is required to make libunwind link to predicatable
symbols, in what can only be described as a bit of a farce. There are a
few more details in the libunwind man page, but the gist of it is that
it disables support for "remote unwinding": unwinding stack frames in a
different process (and possibly from a different architecture?):
http://www.nongnu.org/libunwind/man/libunwind(3).html

Note that I haven't tried this with CMake: I suspect that it'll work,
though, as the CMakeLists.txt seems to have SDL2 link against libunwind if
it's present. This adds an ugly extra dependency to SDL2, but does mean
that issue 1 isn't present. The UNW_LOCAL_ONLY change shouldn't be
build-system-specific.
2021-10-25 11:28:20 -07:00
Cameron Gutman
408a93a1ec wayland: Use multi-thread event reading APIs
Wayland provides the prepare_read()/read_events() family of APIs for
reading from the display fd in a deadlock-free manner across multiple
threads in a multi-threaded application. Let's use those instead of
trying to roll our own solution using a mutex.

This fixes an issue where a call to SDL_GL_SwapWindow() doesn't swap
buffers if it happens to collide with SDL_PumpEvents() in the main
thread. It also allows coexistence with other code or toolkits in
our process that may want read and dispatch events themselves.
2021-10-25 12:00:35 -04:00
Sylvain
4960cc3dcb
Fixed a few warnings 2021-10-25 16:18:40 +02:00
Sylvain
b793394590
SDL_Renderer: make clear that we use render geometry for fillrect/copy/copyex when there is no specific back-end implementation (currently software, PSP, directfb) 2021-10-25 13:46:40 +02:00
Ozkan Sezer
b3f9d8f38d remove unused local vars after the latest commits. 2021-10-25 07:05:50 +03:00
Sylvain
502e9c3b45 SDL_Renderer simplifications:
- Factorize PrepQueueCmdDraw{,DrawTexture,Solid) into one single function
- Change SDL_Texture/Renderer r,g,b,a Uint8 into an SDL_Color, so that it can be passed directly to RenderGeometry
- Don't automatically queue a SET_DRAW_COLOR cmd for RenderGeometry (and update GLES2 renderer)
2021-10-24 22:27:56 -04:00
Sylvain
23e252bfc5 DirectFB: provide RenderCopyEx via RenderGeometry 2021-10-24 22:27:56 -04:00
Sylvain
79732c9d1e Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain
f02ad2820f Remove FillRects from back-end, where RenderGeometry can be used 2021-10-24 22:27:56 -04:00
Sylvain
70b10c753d Use correct indices when using RenderGeometry / FillRects 2021-10-24 22:27:56 -04:00
Sylvain
16beed9aeb Less code since color is constant when done with triangles 2021-10-24 22:27:56 -04:00
Sylvain
99a346439c OpenGLES2: LINES and POINTS successive commands are combined into a single draw call
(using the same case for DRAW_GEOMETRY)
2021-10-24 22:27:56 -04:00
Sylvain
f0cdc1d0f6 OpenGLES2: remove FillRects, since it's can be done with RenderGeometry 2021-10-24 22:27:56 -04:00
Sylvain
37c39d5cb4 Use geometry to implement FillRects 2021-10-24 22:27:56 -04:00
Sylvain
b0eef52fe1 GLES2 batching: probably need to check for blendMode changes 2021-10-24 22:27:56 -04:00
Sylvain
c27e1249e1 Remove SDL_HAVE_RENDER_GEOMETRY define 2021-10-24 22:27:56 -04:00
Sylvain
77026f673b Metal: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
0e5160a056 VITA: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
73f4ab4c13 Direct3D11: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
ab758398af Direct3D: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
1fe7e3616b OpenGL: a few opengl functions become unused 2021-10-24 22:27:56 -04:00
Sylvain
88548070a5 OpenGLES: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
d192515428 OpenGL: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
b92056bbea OpenGLES2: remove RenderCopy and RenderCopyEx from back-end 2021-10-24 22:27:56 -04:00
Sylvain
76f9fb96d9 Use RenderGeometry to implement RenderCopy and RenderCopyEx at higher level 2021-10-24 22:27:56 -04:00
Ryan C. Gordon
08797adaef opengles2: Attempt to batch RenderCopy calls into a single glDrawArrays call. 2021-10-24 22:27:56 -04:00
Tanuj Bagaria
1f0eb03a76
Fix PS5 mapping with HID-PLAYSTATION driver (#4675)
* add missing PS5 Linux GUID for Bluetooth

* Fix PS5 Mapping to work with HID-Playstation driver
2021-10-24 17:54:26 -05:00
Cameron Gutman
f499168c2c x11: Use SDL_IOReady() instead of calling select() directly
SDL_IOReady() properly handles EINTR and can use poll() if available.
2021-10-24 15:54:57 -05:00
Alex Szpakowski
ba4ef461ea macOS: Fix implicit integer downcast warnings 2021-10-23 17:45:27 -04:00
Ryan C. Gordon
d9d8f51eec
wikiheaders.pl: Add support for deprecated functions. 2021-10-23 14:41:23 -04:00
David Gow
a76b73dd2c kmsdrm: Use SDL_PremultiplySurfaceAlphaToARGB8888() for cursor surface
Instead of taking a direct copy of the mouse cursor surface, and then
premultiplying on every BO upload (using the custom
legacy_alpha_premultiply_ARGB8888 function), use the new
SDL_PremultiplySurfaceAlphaToARGB8888() function, which converts a whole
surface at a time, once and save the result.

The already-premultiplied data is then copied from that to the BO on
each upload, adjusting for the stride (which the previous implementation
required to be equal to the width), thereby making the extra copy
slightly useful..

This also adds support for non-SDL_PIXELFORMAT_ARGB8888 surfaces.
2021-10-22 05:50:00 -07:00
David Gow
b528d48446 wayland: Wayland cursors should use premultiplied alpha
It turns out that Wayland's WL_SHM_FORMAT_ARGB8888 format (and, indeed,
all wayland RGBA formats) should be treated as premultiplied. SDL
surfaces tend not to be premultiplied, and this is assumed by other
backends when dealing with cursors.

This change premultiplies the cursor surface in Wayland_CreateCursor()
using the new SDL_PremultiplySurfaceAlphaToARGB8888(). In so doing, it
also adds support for a wider range of input surfaces, including those
with non-ARGB8888 pixel formats, and those which don't have
pitch==width.

This should fix #4856
2021-10-22 05:50:00 -07:00
David Gow
84808ea4bb video: Add SDL_PremultiplySurfaceAlphaToARGB8888()
A number of video backends need to get ARGB8888 formatted surfaces with
premultiplied alpha, typically for mouse cursors. Add a new function to
do this, based loosely on legacy_alpha_premultiply_ARGB8888() from the
KMSDRM backend.

The new function, SDL_PremultiplySurfaceAlphaToARGB8888() takes two
arguments:
- src: an SDL_Surface to be converted.
- dst: a buffer which is filled with premultiplied ARGB8888 data of the
  same size as the surface (assuming pitch = w).

This is not heavily optimised: it just repeatedly calls SDL_GetRGBA() to
do the conversion, but should do for now.
2021-10-22 05:50:00 -07:00
uyjulian
007b5463e8 video/uikit: Do not use setNeedsUpdateOfPrefersPointerLocked on iOS SDKs older than 14 2021-10-21 21:21:57 -07:00
Sam Lantinga
b360965d0d Added a hint for alternate OpenGL NV12 data format 2021-10-21 20:48:05 -07:00
Cacodemon345
19dee1cd16
Add SDL_GetWindowICCProfile(). (#4314)
* Add SDL_GetWindowICCProfile

* Add new SDL display events

* Implement ICC profile change event for macOS

* Implement ICC profile notification for Windows

* Fix SDL_GetWindowICCProfile() for X11

* Fix compile errors
2021-10-21 17:37:20 -07:00
Sam Lantinga
a34fe8161f Added the ability to bind NV12 textures in the OpenGL renderer 2021-10-21 12:28:35 -07:00
Sam Lantinga
f3fd1ffb99 Fixed crash if SDL API functions are called on a disconnected controller on iOS 2021-10-20 15:18:03 -07:00
Sam Lantinga
a43d3f6931 Don't detect the ROG Chakram mouse as a joystick 2021-10-20 15:19:22 -07:00
Sam Lantinga
bfd2f8993f Fixed grab handling when focus changes between windows in the same application 2021-10-19 17:29:23 -07:00
James Howard
d9c44b6537 Allow Cocoa_VideoInit to succeed when current display mode has invalid flags
This fixes a specific issue seen on macOS 10.14.6 where a DELL E248WFP
Display connected to a 2014 Mac Mini with a scaled 1920x1080 resolution
selected and SDL_Init(SDL_INIT_VIDEO) failed with the error: "The video
driver did not add any displays".

The underlying cause was that the current 1080p display mode did not
have the flag kDisplayModeSafeFlag, the check for which was added in
a963e36, with the idea that certain display modes should not be
candidates for switching to in fullscreen exclusive mode. That may well
be the right thing to do for filtering down a list of candidate modes,
but it doesn't pay to be so picky about the current mode. After all,
this current mode was set by System Preferences, the picture does appear
correctly on screen, and other non-SDL based applications launch and run
correctly in this mode.

Therefore the fix is to have GetDisplayMode only filter out a mode based
on flags if it's part of a candidate list, but if it's the current mode
and it can possibly be converted to an SDL_DisplayMode, do so.
2021-10-19 15:50:21 -07:00
Sylvain
649a33ae47
X11: remove redundant 'wakeup_lock' mutex creation 2021-10-18 23:00:43 +02:00
Ozkan Sezer
c4bac66b74 os2, geniconv: replaced many uses of libc calls with SDL_ counterparts.
FIXME: figure out a way to handle errno checks properly.
2021-10-18 14:11:20 +03:00
Ozkan Sezer
0a0f685473 SDL_os2video.c: missed replacing a use of libc function 2021-10-18 14:10:56 +03:00
Ozkan Sezer
8e9ea2e362 SDL_os2joystick.c: missed replacing a use of libc function 2021-10-18 14:10:37 +03:00
Sylvain
8b1a2fe860
backout SDL_AndroidSetInputType() 2021-10-17 23:47:59 +02:00
Sylvain
6ef3bc5688
Add Dynapi for SDL_AndroidSetInputType() 2021-10-17 23:40:36 +02:00
Sylvain
ccb12457f9
Fixed bug #4843 - Can not get the ime candidatelist like chinese/japaness input method 2021-10-17 23:17:54 +02:00
Sam Lantinga
7fb4364391 Don't process WM_INPUT when handling relative mode by warping the mouse cursor 2021-10-17 13:56:31 -07:00
DomGries
06824b18fd Cleanup windows events after recent changes
Improves clarity without any functional changes
2021-10-17 13:36:42 -07:00
Sylvain
50f969c1b2
Fixed bug #4841 - Out of bounds read (by 1 byte) in yuvnv12_rgb24_sseu 2021-10-17 22:02:19 +02:00
shaquan-omari
ea97ab6164 Add mapping for HORI Fighting Commander OCTA controller on Linux 2021-10-16 15:25:38 -07:00
Sam Lantinga
1c5b3e0e16 Don't center the mouse when gaining focus unless we're using relative mode warping
This is necessary now that we actually change the mouse position when calling SDL_WarpMouseInWindow() in relative mode.
2021-10-15 18:12:18 -07:00
Sam Lantinga
a70a94e0b3 Don't send a mouse leave event if the mouse is outside the window when gaining focus and in relative mode. 2021-10-15 18:11:19 -07:00
Ozkan Sezer
c583055acb SDL_windowsevents.c (WIN_WindowProc): remove SAFE_AREA_X and SAFE_AREA_Y
Not used since commit a1fabca162
2021-10-15 10:11:24 +03:00
Sam Lantinga
d5700ed20b Don't log SDL_POLLSENTINEL, it's purely for internal bookkeeping 2021-10-15 00:01:39 -07:00
Sam Lantinga
dd5d89505d Fixed whitespace 2021-10-14 23:53:41 -07:00
Brick
8bf32e12d8
Improved SDL_PollEvent usage (#4794)
* Avoid unnecessary SDL_PumpEvents calls in SDL_WaitEventTimeout

* Add a sentinel event to avoid infinite poll loops

* Move SDL_POLLSENTINEL to new internal event category

* Tweak documentation to indicate SDL_PumpEvents isn't always called

* Avoid shadowing event variable

* Ignore poll sentinel if more (user) events have been added after

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2021-10-14 22:26:10 -07:00
Sam Lantinga
88e9f7765c Fixed relative mouse mode using warping after 82793ac279 2021-10-14 18:37:27 -07:00
Sam Lantinga
a1fabca162 Removed mouse warping for local mice and improved warp handling for mouse over RDP 2021-10-14 16:52:21 -07:00
Sam Lantinga
82793ac279 Fixed mouse warping while in relative mode
We should get a mouse event with an absolute position and no relative motion and shouldn't change the OS cursor position at all
2021-10-14 14:26:21 -07:00
Sylvain
072e3fdfc4
Fixed bug #4534: NEON implementation of Convert51ToStereo (Thanks Ryan!) 2021-10-14 23:17:08 +02:00