Commit Graph

6275 Commits (2c518747b9cf45c1b94c570c19912e04476e8eed)

Author SHA1 Message Date
Cameron Cawley 347659e8cf riscos: Ensure that last_mouse_buttons is initialised correctly 2022-05-25 14:26:36 -07:00
Cameron Cawley cb43eb43f8 riscos: Ensure the mouse focus is set when creating the window 2022-05-25 14:26:36 -07:00
Cameron Cawley 6eda520f64 riscos: Add a basic implementation of SDL_ShowCursor() 2022-05-25 14:26:36 -07:00
Sam Lantinga 22d6e09a8d Don't try to call hid_ble_scan() if HIDAPI is disabled
Fixes https://github.com/libsdl-org/SDL/issues/5699
2022-05-25 11:05:39 -07:00
Sam Lantinga b28d304b23 Only include controller_type.h in SDL_joystick.c
It has a huge array of controllers and we only want it instantiated once
2022-05-24 17:24:54 -07:00
Ozkan Sezer 9220f92bae hidapi/libusb/hid.c (read_thread): mark as SDLCALL 2022-05-25 01:01:02 +03:00
Simon McVittie 412ceb84d4 video: Only check major version in SDL_GetWindowWMInfo
Since #5602, SDL is intended to have the same ABI across the whole
major-version 2 cycle, so we should not check that the minor version
matches the one that was used to compile an application.

There are two checks that could make sense here.

The first check is that the major version matches the expected major
version. This is usually unnecessary and is not usually done (if we're
calling into the wrong library we'll likely crash anyway), but since we
have the information, we might as well continue to use it.

The second check is whether the version provided by the caller is
equal to or greater than a threshold version at which additional fields
were added to the struct. If it is, we should populate those fields;
if it is not, then we cannot. This is only useful on platforms where
additional fields have genuinely been added during the lifetime of
SDL 2, like Windows and DirectFB (but not X11).

This commit changes the first check to be consistent about only looking
at the minor version, while leaving the second check using SDL_VERSIONNUM
(which will be removed or widened in SDL 3, but it's fine for now).

Resolves: https://github.com/libsdl-org/SDL/issues/5711
Fixes: cd7c2f1 "Switch versioning scheme to be the same as GLib and Flatpak"
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-24 08:56:23 -07:00
Mathieu Eyraud fe46569cce Fix potential memory leak in SDL_AddHintCallback 2022-05-21 09:47:34 -07:00
Ivan Le Lann e4b5afa576 fix unused variable depending on YUV format 2022-05-21 09:46:46 -07:00
Christian Rauch e59cba95a0 add libdecor_dispatch 2022-05-21 09:40:26 -07:00
Ryan C. Gordon dc62fec5e9
audio: Fix locking in backends that manage their own callback threads.
Otherwise you might get a race where an app pauses the device, but
the audio callback still manages to run after the pause is in place.
2022-05-20 21:08:29 -04:00
Sam Lantinga b1cf322971 Fixed HIDAPI PS4 controller being picked up when running under Steam
Input with PS4 configuration enabled
2022-05-19 16:50:59 -07:00
Ryan C. Gordon 9edd411a83
x11: send move/resize events when waiting on fullscreen change.
Otherwise we ignore the Configure/etc events when they come in because
the window is already in an identical state as far as SDL is concerned.

Fixes #5593.

May also fix:
Issue #5572.
Issue #5595.
2022-05-19 17:19:52 -04:00
Cameron Cawley b798e49c92 Fix build warning with MSVC 2022-05-19 23:55:24 +03:00
Cameron Cawley f0566702c5 Fix enabling SDL_DYNAMIC_API in OpenWatcom builds 2022-05-19 20:11:10 +03:00
Cameron Cawley 3d52d04977 Remove the '_' prefix from symbol names in Windows OpenWatcom builds 2022-05-19 20:11:10 +03:00
Cameron Cawley 9dfa000bc0 Initial support for building for Windows with OpenWatcom 2022-05-19 20:11:10 +03:00
Sam Lantinga 5669743a43 Make sure SDL_CaptureMouse() is only called on the main thread
Windows handles mouse capture on a per-thread basis, and capture must be done on the thread used to create a window.

Fixes https://github.com/libsdl-org/SDL/issues/5577
2022-05-19 09:52:47 -07:00
Ozkan Sezer 15781a6986 dynapi: fix SDL_DYNAPI_PROC for SDL_iPhoneSetAnimationCallback() 2022-05-19 18:55:02 +03:00
Cameron Cawley f5cf0e37f7 Remove unused and duplicate defines from SDL_dynapi_overrides.h 2022-05-19 17:23:24 +03:00
Ozkan Sezer 03ebc4397f dynapi: add missing SDLCALL for SDL_TLSSet's dtor param. 2022-05-19 14:01:10 +03:00
Pierre Wendling 501a499180 Add clang-format on/off comments where necessary.
Comments were added in places where INDENT-ON/OFF comments are. Places
like stdlib's asm don't need it as clang-format doesn't try to indent it.
2022-05-19 01:31:29 -07:00
Sam Lantinga 0e6d4baa6b Fixed compile warning on gcc 11 2022-05-19 01:23:24 -07:00
Sam Lantinga c7dff3a22e Attempt to get the X1 and X2 button state on X11 by using the current event state instead of direct X11 query. 2022-05-19 00:35:22 -07:00
Sam Lantinga 57130b75a9 Revert "x11: get x1/x2 button state in GetGlobalMouseState"
This reverts commit 3fcc2cb500.

Button4 and Button5 are for the scrollwheel, not the extended buttons.
I don't know of a way to query the state of the extended buttons using X11.
2022-05-19 00:31:20 -07:00
Sam Lantinga 47f1cb550d Fixed picking up the correct mapping for virtual controllers on Android
Fixes https://github.com/libsdl-org/SDL/issues/5662
2022-05-18 23:48:15 -07:00
Sam Lantinga f7b774a7e0 Fixed build error on Linux if HAVE_INOTIFY isn't defined
Fixes https://github.com/libsdl-org/SDL/issues/5682
2022-05-18 17:59:17 -07:00
Sam Lantinga f9a9d3c8d4 Also restore previous capture window if CaptureMouse() fails 2022-05-18 17:23:49 -07:00
Sam Lantinga 7044452dd6 Handle recursion in SDL_UpdateMouseCapture()
Fixes https://github.com/libsdl-org/SDL/pull/5608
2022-05-18 17:15:45 -07:00
Ozkan Sezer dbd54dd708 adjust dynapi after commit 0cca71a changes for SDL_qsort and SDL_bsearch 2022-05-19 03:00:04 +03:00
Sam Lantinga e19a9a7931 Fixed a message box getting the mouse capture state out of sync 2022-05-18 15:34:07 -07:00
Cameron Cawley 622311c016 Add extra XInput structures and defines for older SDKs 2022-05-18 15:04:42 -07:00
Cameron Cawley c8eea02071 Fix C89 build errors in Windows builds 2022-05-18 15:03:15 -07:00
Cameron Cawley 0cca71a846 Use SDLCALL for callbacks in public APIs 2022-05-18 15:01:27 -07:00
Cameron Cawley ffab9f46b5 Avoid clashing with system headers when redefining standard library functions 2022-05-18 16:44:17 -04:00
Sam Lantinga 06aca7edaa Fixed warping back into the window when gaining focus with warp relative mode enabled 2022-05-18 10:10:51 -07:00
Sam Lantinga b44241ab2f Don't send mouse events when warping in relative mode
This fixes games which set relative mode and then did mouse warping at the same time

Reference https://github.com/libsdl-org/SDL/issues/5609
2022-05-18 08:56:09 -07:00
Ivan Epifanov 8c5bda6acd Vita: remove Vita-specific RWOps code 2022-05-18 08:29:25 -07:00
Sam Lantinga aa6ea607d9 Fixed whitespace
Whitespace inconsistencies reported in https://github.com/libsdl-org/SDL/pull/5673
2022-05-18 06:58:14 -07:00
Ryan C. Gordon 56665e1d9d cocoa: Try to use better system cursors.
These try to pull from the .pdf files that are installed with
macOS, which fit our needs better, and fall back to the most
reasonable defaults available from NSCursor if we can't load
them.

Since these are installed under /System, they should be sandbox
accessible, and if this totally fails, it should still go on,
albeit with a less good cursor.

Reference Issue #2123.
2022-05-17 12:51:08 -04:00
Alex Szpakowski e9c7b5191c macOS: Fix reference counts of internal window data.
Fixes crashes when destroying or recreating a window (#5664).
2022-05-16 18:17:27 -07:00
Ozkan Sezer a48004952d disable dynapi for os/2, at least for now. (see bugs #5667 and #5669.) 2022-05-17 01:33:20 +03:00
Ozkan Sezer ec1a0f62dd SDL_malloc.c: workaround calling convention issues for real_xxx procs. 2022-05-17 01:33:02 +03:00
Sam Lantinga 1f2a241688 Add new virtual joysticks to the end of the list
This guarantees that the device index that's returned is stable, as long as no joystick hotplug events occur.
2022-05-16 09:02:35 -07:00
Sam Lantinga 3c3ccb1d48 Fixed crash if a virtual joystick was disconnected 2022-05-16 08:56:17 -07:00
Ryan C. Gordon 2317a96c8e
x11: Use XC_top_left_corner/XC_top_right_corner instead of XC_fleur.
On Gnome (and hopefully others!), this produces something that actually
matches SDL_SYSTEM_CURSOR_SIZENWSE/SDL_SYSTEM_CURSOR_SIZENESW. On
other desktop enviroments, it probably fits the spirit better than
XC_fleur in any case.

Reference Issue #2123.
2022-05-16 10:53:01 -04:00
Sam Lantinga 48b6cd8bc2 Fixed whitespace 2022-05-16 07:23:30 -07:00
Sam Lantinga f0bc5c9cbf Added effects support for virtual controllers 2022-05-16 07:21:28 -07:00
Sam Lantinga b3a18706ee Removed unused variables 2022-05-16 06:37:38 -07:00
Sam Lantinga 7e005bd843 Fixed mapping the paddle buttons with the virtual controller 2022-05-16 06:22:18 -07:00
Sam Lantinga bfac54b59c Added the ability to specify which buttons and axes are present for virtual controllers 2022-05-15 20:34:44 -07:00
Sam Lantinga 94eeb587c1 First pass at extending virtual controller functionality
Added the ability to specify a name and the product VID/PID for a virtual controller

Also added a test case to testgamecontroller, if you pass --virtual as a parameter
2022-05-15 20:01:12 -07:00
Sam Lantinga 7ad15c5b8f Added game controller support for virtual joysticks
Fixes https://github.com/libsdl-org/SDL/issues/5662
2022-05-15 09:35:52 -07:00
Sam Lantinga 996b3dc37a Fixed warning building with Visual Studio 2022-05-15 09:33:28 -07:00
Ethan Lee e4bb3c8649 wayland: Fix build for configs without libdecor 2022-05-11 18:13:44 -04:00
Ethan Lee 6222bd3143
wayland: Don't create a new libdecor context if one already exists 2022-05-11 16:26:43 -04:00
Ethan Lee 6f88cbe4c9 wayland: Support xdg_decoration requesting client-side decorations.
Don't be fooled by the diff size - this ended up being a big refactor of the
shell surface management, masked only by some helper macros I wrote for the
popup support.

This change makes it so when xdg_decoration is supported, but CSD is requested,
the system bails on xdg support entirely and resets all the windows to use
libdecor instead. This transition isn't pretty, but once it's done it will be
smooth if decorations are an OS toggle since libdecor will take things from
there.

In hindsight, we really should have designed libdecor to be passed a toplevel,
having it manage that for us keeps causing major refactors for _every_ change.
2022-05-11 13:13:59 -07:00
Eddy Jansson d7866ffac8 assert: Check for integer overflow.
Move rendering of the assert message into a separate
function so we can remove the ugly loop construction.

Changes the logic such that allocation failure no longer
immediately returns SDL_ASSERTION_ABORT, instead we
fall back to the truncated message.

If an error is indicated from SDL_snprintf, then we do
abort with SDL_ASSERTION_ABORT.
2022-05-11 12:55:49 -07:00
Michael Fitzmayer 9b75fa0165
N-Gage port: add changes from code reviews, overall cleanup (#5618)
* Add changes from code review by @ccawley2011, #5597, overall cleanup

* Update N-Gage README, minor cleanup and rephrasing

* Call SDL_SetMainReady() before calling SDL_main, return SDL_main instead of main
2022-05-11 09:31:34 -07:00
Sam Lantinga 6da99d4a6c Don't use SDL_SIMDFree() if the pixels haven't been allocated with SDL_SIMDAlloc() 2022-05-11 08:40:17 -07:00
Cameron Cawley 2f924020e8 Add SDL_SCANCODE_CALL and SDL_SCANCODE_ENDCALL 2022-05-10 16:12:10 -07:00
Cameron Cawley 2bc373622b Add SDL_SCANCODE_SOFTLEFT and SDL_SCANCODE_SOFTRIGHT 2022-05-10 16:12:10 -07:00
Alex Szpakowski f871c178b9 macOS: remove dead code for supporting 10.6 at runtime. 2022-05-10 14:04:14 -07:00
Eddy Jansson f7280dcebb log: Check for integer overflow. 2022-05-10 06:47:11 -07:00
Alex Szpakowski ec8fa57750 macOS: always use Objective-C ARC (automatic ref counting).
Change Cocoa SDL_VideoData and SDL_WindowData implementations from C structs to Objective-C objects, since bridging between C and ObjC is easier that way.
2022-05-09 21:53:40 -07:00
Simon McVittie 2a7948016a cpuinfo: Check for overflow in SIMD allocation
If the size to be allocated is very large and untrusted, then adding
the padding etc. might be enough to cause unsigned overflow, after
which a very small amount of memory will be allocated.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-09 21:31:39 -07:00
Simon McVittie cf1daafa3f cpuinfo: Set padding to 0 if none is needed
It'll be simpler to use overflow detection after this refactor.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-09 21:31:39 -07:00
Frank Richter 0e63b514d5 Don't define memcpy(), memset() when using static VC runtime.
The linker will complain about duplicated symbols otherwise
(see #3662, #5156).
2022-05-07 08:10:52 -07:00
Sam Lantinga 8cd908e0b9 Fixed building with Visual Studio 2013
Added SDL_vacopy.h since it needs to be included after Windows headers
2022-05-06 10:51:55 -07:00
Sam Lantinga a3c1ca1fa1 Added support for the Backbone One guide button
The guide button is activated on a long press (> 400ms)
2022-05-06 09:07:36 -07:00
Simon McVittie fff97c95eb build: Mechanically generate ABI versions from version number
If we're strict about applying something resembling semantic versioning
to the "marketing" version number, then we can mechanically generate
the ABI version from it.

This limits the range of valid micro versions (patchlevels) to 0-99.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie cd7c2f1de7 Switch versioning scheme to be the same as GLib and Flatpak
For stable releases, this gives us the ability to make bugfix-only point
releases such as 2.24.1 if we want to, and distinguish between them
programmatically. For example, this ability could have been useful after
2.0.16 to fix Xwayland regressions, and after 2.0.18 to fix event loop
regressions.

For development releases, this gives us the ability to make multiple
prereleases during the same feature cycle, and distinguish between them
programmatically. For example, this would have been useful during 2.0.22
development, which went through three prereleases before reaching the
final release.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie 63814ec767 Add static assertions that the version number is consistent
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Simon McVittie d4b82bfa4c Add static assertions for version numbers' limits
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-04 09:55:35 -07:00
Cameron Cawley b398a847be Add SDL_FLOATWORDORDER for older ARM toolchains 2022-05-04 09:52:11 -07:00
Alexander Kanavin adac3bd1e2 video: restore ability to disable fb accel via hint
Somewhere in code refactoring between .20 and .22 this check
was lost, and so the hint had no effect anymore.
2022-05-04 08:35:13 -07:00
Ozkan Sezer 3f813cf1ef SDL_rawinputjoystick.c: fixed -Werror=declaration-after-statement 2022-05-04 10:05:56 +03:00
atfrase db9e14e504 disabled linux joystick debugging outputs and reverted unnecessary comment edit 2022-05-03 10:44:09 -07:00
atfrase 3b53555bcf copied default Steam Controller mapping for wired and wireless-dongle USB pids 2022-05-03 10:44:09 -07:00
atfrase 13b1bf4f21 added default gamepad mapping for Steam Controller with new GUID (possibly caused by the firmware update to enable BLE?) 2022-05-03 10:44:09 -07:00
atfrase f7a19f9ea8 relaxed the digital hat deadzone slightly, and fixed typo in DEBUG_GAMEPAD_MAPPING define 2022-05-03 10:44:09 -07:00
atfrase 3696e23d09 added hints SDL_HINT_LINUX_DIGITAL_HATS and SDL_HINT_LINUX_HAT_DEADZONES to control the new Linux hat handling; added define DEBUG_GAMEPAD_MAPPINGS to log messages when generating default gamepad mapings for Linux joysticks 2022-05-03 10:44:09 -07:00
atfrase 0b8e796e2c added hueristic to differentiate digital vs analog 'hat' input axes and expose the latter as regular axes; added automatic deadzones to hat outputs, in case analog axes are still mapped to digital hats; updated automatic gamepad control mapping to more completely follow the spec 2022-05-03 10:44:09 -07:00
Michael Fitzmayer fbd230bb6c
Add support for the Nokia N-Gage (#5597)
* Add initial support for the Nokia N-Gage

* N-Gage: disable clipping for the time being, issue needs to be resolved later

* Move va_copy definition to SDL_internal.h

* Move stdlib.h include to SDL_config_ngage.h, much cleaner this way

* Remove redundant include, add HAVE_STDLIB_H

* Revert "N-Gage: disable clipping for the time being, issue needs to be resolved later"

This reverts commit 4f5f0fc36cc7f34fad05e45671dfa7b8dc32fd51.

* N-Gage: fix clipping issue by providing proper math functions
2022-05-03 08:51:49 -07:00
emily 3fcc2cb500 x11: get x1/x2 button state in GetGlobalMouseState 2022-05-03 07:12:04 -07:00
Susko3 6150245d65 Add new verbosity level for logging of `SDL_SysWMEvent`s
Now logged only if SDL_HINT_EVENT_LOGGING is set to "3" or above.
2022-05-02 15:33:13 -07:00
Daniel Brookman d1a3981bf8 Fix crash when reading background events for MFi controllers on macOS
Enabling GCController.shouldMonitorBackgroundEvents to read background events
for MFi controllers before receiving the first GCControllerDidConnectNotification
is apparently a no-go on macOS (12.3.1 for me), and would crash on attempt.
Apple's documentation is... not great, and doesn't point this out.

This waits for IOS_AddMFIJoystickDevice() to get called down the chain from GCControllerDidConnectNotification, and enables GCController.shouldMonitorBackgroundEvents
if it hadn't been already.

On iOS and tvOS, GCController.shouldMonitorBackgroundEvents is ignored, so
there's no need to check their versions.
2022-05-02 15:31:28 -07:00
Jan200101 bb0b6dd42e Fixed using WGI without XInput 2022-05-02 11:33:55 -07:00
Sam Lantinga 5394238cdc Don't include the internal header for a file intended for use by applications 2022-04-30 11:40:26 -07:00
Eddy Jansson 9e5cbf034a Disallow non-positive allocation.
Ensure that we're not trying to call SDL_small_alloc()
with a count of zero.

Transforming the code like this fixes a
-Wmaybe-uninitialized warning from GCC 12.0.1
2022-04-29 18:34:13 -07:00
Eddy Jansson 6c2928b4be Switch uses of MIN() to SDL_min()
We're excluding files in src/hidapi to minimize the
diff against the upstream project.
2022-04-29 10:39:51 -07:00
Eddy Jansson ca26df3404 assert: Allow messages of any length.
Messages are no longer truncated to SDL_MAX_LOG_MESSAGE.
2022-04-29 10:39:02 -07:00
Eddy Jansson 888899244c log: Allow log messages of any length.
Log messages are no longer truncated to SDL_MAX_LOG_MESSAGE.
2022-04-29 10:39:02 -07:00
Eddy Jansson 645db217a0 log: Use malloc for long messages.
For short messages, use a stack buffer that is
significantly smaller than SDL_MAX_LOG_MESSAGE.

The rationale for this is that we don't want to risk
blowing the stack, while at the same time we would
like to not put pressure on the memory allocator unless
absolutely necessary.
2022-04-29 10:39:02 -07:00
Eddy Jansson 73448fe245 assert: Remove use of alloca()
For short messages, use a stack buffer that is
significantly smaller than SDL_MAX_LOG_MESSAGE.

For larger messages, fall back to allocation.
2022-04-29 10:39:02 -07:00
Eddy Jansson 97774cdf72 Move in va_copy() define block from stdlib. 2022-04-29 10:39:02 -07:00
Sam Lantinga 7e636b03cc Removed log message length limitation for Apple platforms
This works in conjunction with https://github.com/libsdl-org/SDL/pull/5584
2022-04-29 10:16:14 -07:00
Carl Friess 2ccb0dfd16 Check for macOS 10.16 to support apps built with older macOS SDKs 2022-04-29 00:24:23 -07:00
Sam Lantinga a0cdc1fc30 Added declaration of SDL_LogInit() and SDL_LogQuit()
Fixes compile warning on Android
2022-04-28 15:01:34 -07:00
Ryan C. Gordon 29694869b1
audio: Revert one of the resampler optimizations.
This is the one that splits the "left wing" into two for loops to
bubble out the conditional that decides if it should read from the
left padding or the input buffer.

I still believe the optimization is good, but the basic logic of it
was incorrect, and needs to be reexamined and fixed before going
back into revision control.
2022-04-28 15:58:39 -04:00
Ryan C. Gordon 0f45a4e303
log: Don't try to SDL_free the static array. :)
I shouldn't be allowed near computers, I swear.
2022-04-27 12:22:37 -04:00
Ryan C. Gordon 31e83cd14c
log: Fixed build (sorry!) 2022-04-27 12:13:44 -04:00
Ryan C. Gordon fde9a7086e
log: Make the message buffer static.
Now we don't have to worry about allocation failure, or performance
issues or changes to the allocation layout when trying to track down
subtle bugs.
2022-04-27 12:05:07 -04:00
Ryan C. Gordon c4141bc11c
log: Wrap the call to the logging implementation in a mutex.
Fixes #2463.
2022-04-27 09:41:05 -04:00
Ryan C. Gordon 2a42952281
log: Don't stack-allocate the message buffer.
It's 4 kilobytes, so I could see this failing if you have a thread with
a tiny stack that unexpectedly logs something.
2022-04-27 09:41:04 -04:00
Ozkan Sezer 12f15aaa74 fix build 2022-04-27 10:03:32 +03:00
Ryan C. Gordon 05bd225a80
x11: If XRandR isn't available, add a generic display.
We can get _some_ of the info we need out of standard Xlib and report a
single display (which might actually be multiple physical displays mushed
into a single desktop). This is better than nothing, but you should really
just build with XRandR support and get a better X server.  :)
2022-04-26 23:17:14 -04:00
Ryan C. Gordon ccc70e644b
x11: Fixed some compiler warnings. 2022-04-26 23:17:13 -04:00
Ryan C. Gordon 7d7ec9c951
x11: Remove XVidMode and Xinerama support.
Fixes #1782.
2022-04-26 23:17:13 -04:00
Sam Lantinga e551384a99 Added functions to get the platform dependent name for a joystick or game controller 2022-04-26 14:54:14 -07:00
Mirko Galimberti b293888c7d Fixes an issue introduced via #5573 when building for i686 2022-04-26 20:55:40 +03:00
Ryan C. Gordon 5066910bf5 audio: Make pregenerated resampler kaiser filter more precise. 2022-04-26 13:32:42 -04:00
Ryan C. Gordon 111c3add73 audio: Resampler optimizations.
- Calculate `j * RESAMPLER_SAMPLES_PER_ZERO_CROSSING` once per loop
  iteration since we use it multiple times.
- Do the left-wing loop in two sections: while `srcframe < 0` and then
  the remaining calculations when `srcframe >= 0`. This bubbles a conditional
  out of every iteration of a tight loop, giving us a boost. We could
  _probably_ do this to the right-wing loop too, but it's less straightforward
  there.
- The real win: Use floats instead of doubles. This almost doubles the speed
  of the entire function on Intel CPUs, and for embedded things without
  hardware-level support for doubles, the speedup is enormous. This in
  theory might reduce audio quality, though, and I had to put a check in
  place to avoid a division-by-zero that we avoided at higher precision, but
  this is likely to be worth keeping for at least the Sony PSP and other
  smaller platforms, if not everyone.
2022-04-26 13:32:42 -04:00
Ryan C. Gordon de019568dc audio: Prebake the resampler's kaiser table instead of doing it at runtime. 2022-04-26 13:32:42 -04:00
Ryan C. Gordon f6eb4b0759
pulseaudio: Feed audio data in response to write callbacks.
Instead of waiting until the entire buffer from the SDL callback is ready
to be accepted by PulseAudio, we use pa_stream_set_write_callback and
feed some portion of the buffer as callbacks come in asking for more.

This lets us remove the halving of the buffer size during device open,
and also (hopefully) solves several strange hangs that happen in unusual
circumstances.

Fixes #4387
Fixes #2262
2022-04-26 13:22:32 -04:00
Sam Lantinga 01ef98a5d0 Don't force keyboard auto-repeat on, if the user has disabled it for some reason
Fixes https://github.com/libsdl-org/SDL/issues/2400
2022-04-26 10:19:52 -07:00
FriendlyAI 795744fc75 Turn off relative mouse before window checks as well 2022-04-26 10:07:26 -07:00
FriendlyAI e2d268a399 SDL_cocoamouse.m: SetRelativeMouseMode even if out of focus
Should fix #3087
2022-04-26 10:07:26 -07:00
Jibb Smart d7c07d6b09
Read motion sensor scale from Switch controllers (#5555)
* Read IMU scale data from Switch controllers. Up until now, SDL has used hard-coded scaling which isn't correct with some supported controllers.

* Moved declarations to beginning of code blocks to better fit with SDL style requirements
2022-04-26 09:57:17 -07:00
Mirko Galimberti 76afb8583b Introduces Cocoa_GetWindowDisplayIndex. This enable a proper management for dpi when switching between retina and non-retina displays. 2022-04-26 09:51:31 -07:00
Dimitriy Ryazantcev c39df2fb0c joystick: get HID top-level collection preparsed data directly from RawInput API. 2022-04-26 09:48:35 -07:00
Ozkan Sezer e9ff4fdd49 add SDL_bsearch 2022-04-26 04:03:25 +03:00
Mathieu Eyraud 0b2a55ea7d Fix typo 2022-04-25 15:46:17 -07:00
meyraud705 3dcfe86082 Add joystick battery event 2022-04-25 15:46:17 -07:00
meyraud705 0964c84d77 Always use SDL_PrivateJoystickBatteryLevel to update battery level
But do not use it for initialisation.
2022-04-25 15:46:17 -07:00
Sam Lantinga fa29e2d7f7 Updated to version 2.0.23 for development 2022-04-25 13:45:51 -07:00
Ryan C. Gordon 53dea98309
x11: revert checks for _NET_WM_STATE_FULLSCREEN changes.
This reverts commit 85977354fb.
This reverts commit 0249df9d96.

Fixes #5572.
Reopens #5390.
2022-04-25 14:00:04 -04:00
Sam Lantinga 981e1e3c44 Fixed logical size synchronization issue on macOS
https://discourse.libsdl.org/t/sdl-2-0-22-prerelease/35306/6
2022-04-23 10:35:05 -07:00
Ozkan Sezer 7a5743031d hidapi, libusb: import mainstream commit 536bad201e 2022-04-23 20:01:40 +03:00
Sam Lantinga fa073ed01a Revert "Fix relative mouse input for Unvanquished (unvanquished.net)"
This reverts commit 3318590796.

Fixes https://github.com/libsdl-org/SDL/issues/5569
2022-04-22 22:31:04 -07:00
Sam Lantinga 8986efd643 Added support for the Backbone One controller on iOS 2022-04-22 14:21:46 -07:00
Sam Lantinga 2ca0837888 SDL: sometimes the PS5 controller doesn't report having to power even when connected over USB. Possibly related to being completely charged? Either way we already know that it's USB or BT so let's use the driver's knowledge instead. 2022-04-22 14:21:41 -07:00
Sam Lantinga 04bf7c9434 Fixed build 2022-04-22 09:36:39 -07:00
Sam Lantinga d9b5805ba5 Return a correlation error when trigger rumble is attempted without correlation 2022-04-22 09:13:40 -07:00
Sam Lantinga ba62ead5ec Handle potential out of memory condition when working with hints 2022-04-21 08:47:41 -07:00
Cameron Gutman 145824f6ab WGI: Only call RoUninitialize() if RoInitialize() succeeded 2022-04-21 08:47:22 -07:00
Cameron Gutman 00b2e10a7a WGI: Keep a reference to the MTA to avoid crashing on COM teardown
Fixes #5552
Fixes #5270
2022-04-21 08:47:22 -07:00
Cameron Gutman 8982d9f403 windows: Fix RoInitialize() failure after a CoInitializeEx() call using apartment threading
This mirrors the same codepath in WIN_CoInitialize() which handles STA and MTA.
2022-04-21 08:47:22 -07:00
Cameron Gutman 923cb4463e windows: Fix calling convention for RoInitialize/RoUninitialize
Fixes #5563
2022-04-20 21:02:40 -05:00
Ryan C. Gordon d4a01bfef0
os2: SDL_DestroyMutex should ignore NULL mutexes.
Every other backend does this, so this should match, now.
It's possible this was harmless, but we can avoid the system call
and the (likely?) debug message when it fails, though!
2022-04-20 14:08:09 -04:00
Eddy Jansson a40405d724 hidapi: Wrap CopyHIDDeviceInfo in define checks.
The purpose of this is to silence a 'defined but not used'
warning.
2022-04-20 09:33:40 -07:00
Frank Praznik aeadbdd788 Remove an unused function prototype 2022-04-20 09:39:34 -04:00
Frank Praznik c8c59a2139 Fix a -Wshadow warning 2022-04-20 09:39:34 -04:00
Jaylon Gowie d9009388c8 SceKernelMemBlockType to unsigned int 2022-04-19 14:17:27 -07:00
Jaylon Gowie 3753a7b1c3 Fix recent changes in VitaSDK 2022-04-19 14:17:27 -07:00
Sam Lantinga 02225aa738 Fixed build 2022-04-18 22:57:03 -07:00
Ryan C. Gordon 49a2e4b0ea
x11: Revert "Fix keymap updating for X11 backend"
This reverts commit de6d290266.

This patch had multiple issues, discussed in #5520.
2022-04-19 00:37:39 -04:00
Sam Lantinga b9fe6ba0e7 Fixed compile warnings 2022-04-18 13:09:08 -07:00
Sam Lantinga 57927a2458 Don't call scandir() inside of scandir()
This works around a crash in address sanitizer
2022-04-18 12:57:28 -07:00
Sylvain 1ede941f5c SDL_render.c: internally change viewport/cliprect type from SDL_FRect to SDL_DRect (double precision). (see bug #5547) 2022-04-18 12:26:32 -07:00
Sam Lantinga 9919d1a7a5 Remove HWND_TOPMOST for fullscreen windows
Fixes https://github.com/libsdl-org/SDL/issues/5509
2022-04-18 11:51:54 -07:00
pionere 009a0ff95f use explicit GetModuleFileNameW 2022-04-18 14:12:22 -04:00
pionere de711e1685 simplify SDL_GetBasePath on windows
- use GetModuleFileName directly (as recommended)
2022-04-18 14:12:22 -04:00
Jan Beich 7c140429a8 Enable evdev-based gamecontrollerdb on FreeBSD 2022-04-18 09:57:49 -07:00
Sam Lantinga e7b01ee745 Added controller mapping for the Thrustmaster Dual Analog 3.2 on Linux 2022-04-18 09:55:52 -07:00
Frank Praznik 2b52946143 video: Don't minimize fullscreen windows on focus loss by default when mode switching is disabled
When mode switching is disabled in a video backend, fullscreen windows are basically just fullscreen desktop windows with different internal scaling.  As no mode switching occurs, there's no need to minimize them on focus loss by default.  This can still be overridden by explicitly setting the internal hint for minimizing on focus loss.

This has the side effect of fixing a bug on GNOME, where, when a fullscreen Wayland window has it's focus lost and restored via alt+tab followed by switching back to windowed mode, the top portion of the window won't end up being obstructed by GNOME's top bar.
2022-04-18 09:39:25 -07:00
Ethan Lee c37090f9a4 wayland: Add support for TOOLTIP/POPUP_MENU 2022-04-18 12:31:02 -04:00
Sam Lantinga 9e264b921b Certain audio drivers, like the RME "Pro" Audio driver, have resampling quality issues when using WASAPI.
We'll use SDL's resampling algorithm so we have consistent quality between platforms and drivers.

Fixes https://github.com/libsdl-org/SDL/issues/5538
2022-04-18 09:20:47 -07:00
Sam Lantinga 254fcc90eb Revert "video: Prefer Wayland over X11"
This reverts commit 8ceba27d62.

SDL Wayland support is stable, but there are a number of issues with third-party software (NVIDIA drivers, libwayland event overflow, libdecor not handling plugin load failures, Steam overlay not working with Wayland, etc.) that make it better to default to X11 at this time.

Games which would like to prefer wayland when available can use the following code before SDL_Init():
	SDL_SetHint(SDL_HINT_VIDEODRIVER, "wayland,x11");

Fixes https://github.com/libsdl-org/SDL/issues/5527
2022-04-18 09:03:14 -07:00
Ryan C. Gordon c1336b21ed hints: Make SDL_VIDEODRIVER and SDL_AUDIODRIVER formal hints.
They were just environment variables before.

Fixes #5528.
2022-04-17 11:31:55 -07:00
Ryan C. Gordon 67e0f546c5
x11: Update the display when the WM changes a window's fullscreen state.
Fixes #5390.
2022-04-15 18:25:53 -04:00
Frank Praznik edb473cf46 video: Wayland: Always round scaled pointer coordinates down
Rounding up can cause the pointer coordinates to exceed the window boundaries at the right and bottom edges.
2022-04-15 16:24:20 -04:00
Frank Praznik 13393a1c4b video: Wayland: Clamp fullscreen window dimensions to desktop
A scaled fullscreen window may exceed the bounds of the desktop.  Clamp the window size to the desktop dimensions in fullscreen mode.
2022-04-15 16:24:20 -04:00
pionere 0adb67017b avoid NullPointer in SDL_GetRenderTarget 2022-04-15 15:47:35 -04:00
pionere 01b14e14e6 avoid NullPointer in SDL_GL_MakeCurrent 2022-04-15 08:30:33 -04:00
David Gow 9c2f46b0d5 Wayland: Add SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR
This hint allows libdecor to be used even when xdg-decoration is
available. It's mostly useful for debugging libdecor, but could in
theory be used by applications which want to (for example) bundle their
own libdecor plugins.
2022-04-12 11:52:41 -04:00
Mathieu Eyraud 99ae6395b1 Initialise scandir argument
'scandir' does not initialise 'entries' on error
2022-04-12 11:14:07 -04:00
pionere f708cebe10 fix os2 timer in fallback mode 2022-04-12 17:01:20 +03:00
Ryan C. Gordon 727eef7064
audio: SDL_ConvertStereoToMono_SSE3 missed an unaligned load. 2022-04-09 10:13:37 -04:00
Sam Lantinga 505d6a4a05 Update version to 2.0.22 for release 2022-04-08 18:18:56 -07:00
Frank Praznik c2093fab99 video: wayland: Set the surface damage region when using fullscreen viewports
When using emulated display modes, the output size is often larger than the drawable buffer.  As the surface damage region is automatically calculated from the smaller drawable buffer size, the damage region needs to be manually set to cover the entire viewport region or visual repaint artifacts can result.
2022-04-08 14:11:44 -04:00
Ethan Lee ba0ba9ef16 direct3d11: Set the swapchain target immediately after creating it.
Fixes #4782
2022-04-07 23:47:20 -07:00
Ethan Lee cb81630816 render: Update the size/scale/viewport on moves, in addition to resizes.
For OpenGL this means resetting the viewport state shadowing flag too.

Fixes #1504
2022-04-07 23:38:33 -07:00
Sam Lantinga 5613a56032 Make sure the UIKit message box is being handled on the main thread
Potentially fixes https://github.com/libsdl-org/SDL/issues/4865
2022-04-07 11:33:54 -07:00
Sam Lantinga 49b9e3470b Only update modifier state for keys that are pressed in another application
Fixes https://github.com/libsdl-org/SDL/issues/4432
2022-04-07 08:24:03 -07:00
Ryan C. Gordon 85977354fb
x11: Treat WM setting the window "fullscreen" like FULLSCREEN_DESKTOP.
Fixes #5390.
2022-04-07 09:15:27 -04:00
Ethan Lee d1f7f9e35d wayland: Pin the fake window position at (0, 0).
I kind of thought it'd be nice to have it in the center, but this is an issue
for applications that still assume global mouse and window positions are
accessible. For example, this fixes cursor offset issues in UE5.
2022-04-06 11:18:46 -04:00
Ethan Lee 279aeb59be
wayland: Add a bug link for the detach FIXME 2022-04-06 01:32:57 -04:00
Ethan Lee 3ada694e62
wayland: Try to detach at the beginning of ShowWindow, just in case.
It's possible that an external component (probably a GL/VK context) committed, so we need to cover our bases and detach in both HideWindow and ShowWindow.

Fixes a crash in UE5 editor's pop-ups.
2022-04-06 01:18:03 -04:00
Ethan Lee dcfb7fff00
wayland: Evaluate WINDOWPOS_CENTERED_DISPLAY for move events
Partially fixes the mouse cursor in UE5 editor. Imperfect because UE5 uses window position and global mouse state to get position, but of course we don't have global mouse and this is just to get the right display index so this still fails overall. We really need to make global mouse support a feature query...
2022-04-06 00:55:32 -04:00
Sam Lantinga 7ea1b69dd4 Sort controllers by the js* index on Linux
Also fixed the initial scan to directly scan devices instead of using
udev so they can be sorted, as intended.

Fixes https://github.com/libsdl-org/SDL/issues/4688
2022-04-05 21:02:52 -07:00
Ryan C. Gordon 0249df9d96
x11: Try to keep SDL_WINDOW_FULLSCREEN* in sync with window manager.
So if Gnome/KDE/etc have a keyboard shortcut or titlebar decoration to
make any window go fullscreen (with the _NET_WM_FULLSCREEN flag on the
_NET_WM_STATE property), we update the SDL window flag.

Fixes #5390.
2022-04-05 23:18:10 -04:00
Sam Lantinga eb660e862c Cache the fact that a device didn't look like a joystick
Fixes https://github.com/libsdl-org/SDL/issues/5211
2022-04-05 19:47:42 -07:00
Weng Xuetian 138d96c8a6
Send key release event to input method. (#5281)
Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
2022-04-05 22:30:25 -04:00
Ryan C. Gordon 8bae343f25
x11: when waiting on fullscreen changes, not window position _and_ size.
This makes sure the window doesn't have outdated values if you try to access
them (or call something that does, like SDL_SetWindowMinimumSize).

Fixes #5233.
2022-04-05 22:21:57 -04:00
Sam Lantinga 268c2fa882 Don't resize fullscreen windows when hiding or minimizing them (thanks @madewokherd!)
This has the benefit of window previews (mousing over the icon) having the correct size and contents.

Fixes https://github.com/libsdl-org/SDL/issues/5320
2022-04-05 18:42:17 -07:00
Esme Povirk def27267b5 Ignore focus change messages that contradict GetForegroundWindow.
On Wine, when a window is programmatically minimized in response
to losing focus, we receive a WM_ACTIVATE for the deactivation,
but GetForegroundWindow still indicates that our window is focused.
This causes an incorrect SDL_WINDOWEVENT_FOCUS_GAINED.

This is probably a Wine bug, but it may take a while to fix and
then for the fix to make its way to users.
2022-04-05 18:00:39 -07:00
Weng Xuetian ff5b67e5e0 IBus should use ev keycode instead of X keycode
See: 5a455b1ead/client/gtk2/ibusimcontext.c (L468)
2022-04-05 20:04:40 -04:00
Sam Lantinga 27fc582b59 Minor cleanup 2022-04-05 15:11:49 -07:00
Sam Lantinga 86acb1a347 Handle interaction between auto capture and the SDL_CaptureMouse() API
Fixes https://github.com/libsdl-org/SDL/issues/5457
2022-04-05 15:05:07 -07:00
Sam Lantinga 0e198a8799 Added a define VERBOSE_MOTION_EVENTS to show mouse and finger motion events 2022-04-05 15:03:18 -07:00
Ryan C. Gordon a5672b858e
x11: Wait a bit to see if window pos changes when changing fullscreen.
Helps prevent window from moving to 0,0 when leaving fullscreen.

Fixes #4749.
2022-04-05 11:10:41 -04:00
Cameron Gutman 45372b1c27 x11: Don't unload libGL.so to prevent a crash in XCloseDisplay()
libGL.so may register callbacks that can be invoked upon XCloseDisplay().
If XCloseDisplay() is called after libGL.so is unloaded, the callback pointer
will point at freed memory and invoking it will crash.

The texture framebuffer check optimized out in f37e4a9 was causing libGL.so to
never be unloaded as a side-effect. Skipping it exposed this bug by allowing
libGL.so to actually unload.
2022-04-04 21:39:41 -07:00
Sam Lantinga 7b3449b89f Minor cleanup 2022-04-04 20:46:56 -07:00
Cameron Cawley 57118fb7de render: Fix setting the scale mode for non-native textures 2022-04-02 09:51:28 -07:00
Ozkan Sezer 312c899f4f attempt to fix uwp build 2022-04-02 03:32:10 +03:00
Ozkan Sezer 575dadb11d fix build against older SDKs after commit 8ebef12. 2022-04-02 02:20:02 +03:00
Sam Lantinga 8ebef12d31 Use RoInitialize/RoUninitialize for Windows.Gaming.Input
Thanks @walbourn!

Fixes https://github.com/libsdl-org/SDL/issues/5270
2022-04-01 14:59:45 -07:00
Sylvain 78834b50d6
Add SDL_list.c/h 2022-04-01 08:01:44 +02:00
Sylvain ad6bc521bd
Move SDL_List functions to SDL_list.c to avoid more merge with eventual PR 2022-04-01 07:59:16 +02:00
Sam Lantinga 0d7edcb703 Fixed loading 32-bit BMP files 2022-03-31 16:15:51 -07:00
Ryan C. Gordon ea7d5307ac
emscripten: Proxy SDL_GetUsableDisplayBounds to the main thread. 2022-03-31 14:12:34 -04:00
Reinhold Gschweicher fe79eb2fbb emscriptenframebuffer: fix formatting 2022-03-31 14:11:41 -04:00
Reinhold Gschweicher 268cc2a49c emscriptenmouse: remove useless return statement 2022-03-31 14:11:41 -04:00
NeroBurner 3136a53070 fix formatting and cast warnings
Co-authored-by: Charlie Birks <charlie@daftgames.net>
2022-03-31 14:11:41 -04:00
Reinhold Gschweicher 404158595c emscriptenmouse: remove old extra `_INT` 2022-03-31 14:11:41 -04:00
Reinhold Gschweicher 4dca8f7fb4 SDL2 thread proxying fixes
This PR uses new APIs added in [emscripten-core/emscripten#9336](https://github.com/emscripten-core/emscripten/pull/9336)
to improve compatibility with USE_PTHREADS=1.

Original PR: https://github.com/emscripten-ports/SDL2/pull/127
By: @jakogut
Reviewed by: Daft-Freak
2022-03-31 14:11:41 -04:00
Ryan C. Gordon 1c7bf478ae
x11: Ignore BadValue for extremely small XRRSetScreenSize resolutions.
Reference Issue #4840.
2022-03-31 10:09:47 -04:00
Ivan Epifanov 95c0fec518 Vita: PVROGL: fix indentation and ifdef guards 2022-03-31 06:02:50 -07:00
Jaylon Gowie b5700ab31e Cleanup Spaces 2022-03-31 00:02:56 -04:00
Jaylon Gowie 8c542a3591 Desktop OpenGL 1.X/2.X PSVita Support 2022-03-31 00:02:56 -04:00
Cameron Gutman 2c04df8d65 joystick: Fix rumble issues on PS5 HIDAPI controllers
We were returning the report size from HIDAPI_DriverPS5_RumbleJoystick() rather
than 0 upon success, causing SDL_JoystickRumble() (and callers) to think that
rumbling failed.

This didn't cause major problems until 1868c5b, when it started preventing
rumble state from being persisted in the joystick core, even though it was
successfully sent to the hardware.

This led to all sorts of strangeness, including broken rumble duration and
attempts to stop rumble being discarded.
2022-03-30 18:33:38 -05:00
Ryan C. Gordon 7e15ad2fc4
x11: Catch X11 errors in X11_SetWindowPosition and X11_SetWindowSize.
The functions can go south if other operations are in progress, like
X11_SetWindowBordered, which might be doing something traumatic behind the
scenes of the window manager.

We can't make these tasks totally synchronous, which would fix the problem,
because not only can the window manager block however long it wants, it might
also decide to deny our requests without any notification, so we'd be waiting
forever for a window change that isn't coming.  :(

Fixes #5274.
2022-03-30 14:23:51 -04:00
Ivan Epifanov cbdb67b4f6 Vita: add SDL_GetPreferredLocales support 2022-03-29 15:02:21 -07:00
Ivan Epifanov 178ac19615 Vita: add audio capture support 2022-03-29 14:12:37 -07:00
Frank Praznik 4d1905c9b6 video: wayland: Use viewports for non-fullscreen windows with fractional scaling
Use viewports for non-fullscreen windows when the desktop uses fractional scaling and the window is flagged as DPI-aware to provide a backbuffer mapped as close to 1:1 output as possible.  In the cases of odd window sizes the backbuffer may be a pixel off of scaling perfectly into the window size due to its scaled size being rounded off, but a minute amount of scaling during output is likely preferable to the large amounts of overdraw needed with integer scaled buffers.
2022-03-29 15:00:07 -04:00
Frank Praznik fa4c51989d video: wayland: Expose more resolutions for mode emulation
Expose as many emulated display modes as possible.  They will currently display stretched to the display's native desktop aspect, but if an application requires a hardcoded resolution, it will work at minimum.

Aside from the change in the emulated display mode list, the Wayland event handling code had to be updated to support separate scaling for the x and y axes, as square pixels are no longer guaranteed.
2022-03-28 22:19:34 -04:00
Ethan Lee d875416ac4 wayland: Minor fix for old compilers 2022-03-28 15:32:30 -04:00
Frank Praznik 4d76c9cb46 video: wayland: Use wp-viewporter for fullscreen with non-native resolutions
Wayland doesn't support mode switching, however Wayland compositors can support the wp_viewporter protocol, which allows for the mapping of arbitrarily sized buffer regions to output surfaces.  Use this functionality, when available, for fullscreen output when using non-native display modes and/or when dealing with scaled desktops, which can incur significant overdraw without this extension.

This also allows for the exposure of arbitrarily sized, emulated display modes, which can be useful for legacy compatability.
2022-03-28 13:18:26 -04:00
Connor Clark aec86ba8bb emscriptenaudio: proxy calls to main thread 2022-03-28 12:04:04 -04:00
Ivan Epifanov 96be9cddcc Vita: add hint to select which touchpad generates mouse events 2022-03-28 08:36:32 -07:00
Mathieu Eyraud 1db47d468a Fix potential memory leak in QueueCmdFillRects 2022-03-28 08:34:32 -07:00
Ivan Epifanov 95ed83137f Vita: Use preallocated memory pool for textures 2022-03-27 10:07:49 -07:00
Ryan C. Gordon 7bc498d325
direct3d: Implement missing blend operations.
This is only for Direct3D 9; Direct3D 11 already had this implemented.

Fixes #5375.
2022-03-27 09:14:07 -04:00
Ethan Lee 713a675401 wayland: Relax the check for mismatching output scales 2022-03-26 22:26:15 -04:00
Ethan Lee 5655be1558 wayland: Avoid overwriting xdg_output position with wl_output position 2022-03-26 19:57:39 -04:00
Ethan Lee 40417b188a wayland: Work around a GNOME xdg_output scaling issue 2022-03-26 19:55:04 -04:00
Ethan Lee 7a1c45bd1c wayland: Optimize keyboard_handle_modifiers.
1. Mod index values are (mostly) constant, so can be done with xkb_state_new
2. Mods can change without the group changing, avoid remap events if possible

Lastly, as a bonus, I added braces to the locale check, because I was nearby.
2022-03-25 12:54:05 -04:00
Ivan Epifanov 69d0b6e3c6 Vita: Fix NULL-pointer dereference 2022-03-25 09:29:20 -04:00
Sylvain bf38fd4679
YUV: fix invalid read on last line when converting from SDL_PIXELFORMAT_YUY2 (see bug #4841) 2022-03-25 11:52:50 +01:00
Ethan Lee 2891f0821b wayland: Use xkb_keymap_mod to set mod state 2022-03-25 02:49:49 -04:00
Ethan Lee 6d9ca92626 wayland: Enforce text capitalization manually, for remapped keymods 2022-03-25 01:36:39 -04:00
Ethan Lee a75c6150e0 wayland: Add an xkb_keysym_t->SDL_Keycode mapping for backspace 2022-03-25 01:33:40 -04:00
Ethan Lee ab74b6a3c3 wayland: Remove some now-redundant casts 2022-03-24 15:34:29 -04:00
Ethan Lee ee52ad08cd wayland: Minor fixes for old compilers 2022-03-24 15:32:25 -04:00
Simon McVittie b4d28085bf wayland: Don't overwrite error message from SDL_EGL_CreateSurface
SDL_EGL_CreateSurface sets a more specific error message, so overwriting
it would lose information.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-03-24 14:59:25 -04:00
Simon McVittie d5bbbd3f73 Avoid depending on libwayland 1.20 unnecessarily
When using shared linking (linking in the normal way with
-lwayland-client) rather than loading Wayland libraries dynamically at
runtime, listing symbols that don't exist in the current version results
in a build failure. We don't actually call wl_proxy_marshal_flags() or
wl_proxy_marshal_array_flags() directly; the reason we need them is
that they're called by the code generated by wayland-scanner >= 1.20.

If we're building against an older Wayland library, then we'll have its
corresponding version of wayland-scanner (mismatched versions are not
supported), so we won't need those two symbols, and can avoid generating
a dependency on them.

Conversely, if we're building against a newer Wayland library, the
generated code will call them unconditionally, so we cannot treat them as
optional and gracefully fall back: that would result in a crash. Instead,
treat them as a mandatory part of the Wayland library, so that if they
are not found at runtime, we can fall back to X11 without crashing.

libwayland 1.18 is in several LTS distributions (Ubuntu 20.04,
Debian 11, RHEL 8) so avoiding a hard dependency on 1.20 is quite
useful.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Resolves: https://github.com/libsdl-org/SDL/issues/5376
2022-03-24 14:46:48 -04:00
Ryan C. Gordon d597a9b431
x11: Minor cleanups and corrections in X11_ShowMessageBox.
Reference issue #3254.
2022-03-24 14:25:34 -04:00
Sylvain 6c56193a2a
Fixed bug #1650: X11 doesn't set KMOD_NUM and KMOD_CAPS to system state 2022-03-24 18:09:45 +01:00
Kimplul 2398c43be2 add some Thrustmaster wheels 2022-03-24 08:33:37 -07:00
Ryan C. Gordon 4fe7b2cbd1
static analysis: Fixed several complaints from codechecker.
There are still some pending Objective-C specific issues.

Reference issue #4600.
2022-03-24 11:00:43 -04:00
Ivan Epifanov eadc064e2c Vita: add native YUV textures support.
* Fail if texture init fails.
* Refactor and cleanup.
2022-03-24 07:51:20 -04:00
Ivan Epifanov 0af2db6f29 Vita: support audio format fallback 2022-03-24 07:51:20 -04:00
Frank Praznik 0dae35bf3d video: wayland: Use xdg-output for retrieving the desktop dimensions
Using wl-output to get the desktop display dimensions and dividing by the integer scale factor will not return the correct result when using a desktop with fractional scaling (e.g. a 3840x2160 display at 150% will incorrectly report the scaled desktop area as 1920x1080 instead of 2560x1440).  Use the xdg-output protocol, if available, to retrieve the correct desktop dimensions and offset.

Versions 1 through 3 of the protocol are supported.
2022-03-23 19:43:11 -04:00
Florian "sp1rit"​ 9125b244e7 wayland: Basic support for zwp_tablet_*v2 protocol 2022-03-23 13:47:46 -04:00
Ethan Lee 13337e17a5 wayland: The rest of the wayland-client 1.18 requirement... Git, please 2022-03-23 13:27:01 -04:00
Sylvain Becker c23a7ad38a
Add SDL_RenderGetWindow() API to get the window associated with a renderer (#5440)
Add SDL_RenderGetWindow() API to get the window associated with a renderer
2022-03-23 17:07:56 +01:00
Sylvain f5a980448e
Android: add SetWindowResizable() implementation
- which also enable/disable the orientation lock status.

This is only provided when the window is not SDL_WINDOW_FULLSCREEN (see SDL_video.c).
Final orientation also depends on SDL_HINT_ORIENTATIONS.
2022-03-23 10:13:56 +01:00
Sam Lantinga 006aafabcf Fixed freeing a constant string (thanks @gnrlwart) 2022-03-22 20:24:17 -07:00
Ryan C. Gordon 8df045cc7d
stdlib: just cast iconv()'s 2nd arg to void *.
This makes the compiler happy (enough) regardless of whether the C runtime
headers think this argument should be const or not.

Fixes #4966.
2022-03-22 16:14:06 -04:00
Charlie Birks 4b8d69a416 Avoid trying to use texture framebuffers on emscripten 2022-03-22 12:18:45 -07:00
pionere 25203222f5 optimize the SDL_str(case)cmp functions 2022-03-22 12:17:50 -07:00
pionere aec58d8208 make SDL_strcasecmp standard compliant 2022-03-22 12:17:50 -07:00
pionere b59ca92e82 use != '\0' comparison instead of SDL_strlen in the functions of SDL_getenv 2022-03-22 12:17:50 -07:00
Jonatha Gabriel b944dc8f2e Also fix Android crash when SDL_HIDAPI_DISABLED set to 1
The Java code needs the native functions to be implemented, even if
they're not surfaced via the C API, therefore, a stub version of
functions were made only to the purpose of "fill the gaps" when
SDL_HIDAPI_DISABLED set to 1.
2022-03-22 12:12:16 -07:00
Egor 2302b2d5e5 Add mapping for Logitech Precision Gamepad 2022-03-22 10:04:03 -07:00
Sylvain 83df4a354e
SDL_render.c: remove unsused case, since renderer target has been forced to NULL previously (see bug #4213) 2022-03-22 15:25:01 +01:00
Ryan C. Gordon f782abe5f0
hints: Added SDL_HINT_QUIT_ON_LAST_WINDOW_CLOSE.
Fixes #2349.
2022-03-22 09:54:29 -04:00
Sam Lantinga 34fd83ca06 Don't try to hide foreign windows when destroying the SDL window representation
Fixes https://github.com/libsdl-org/SDL/issues/5432
2022-03-22 06:50:10 -07:00
Ozkan Sezer 74680f5c4c regenerated SDL_blit_auto.c. 2022-03-22 00:56:28 +03:00
pionere dd6c46cb34 blit-auto optimizations 2022-03-22 00:56:28 +03:00
Sylvain 9dc201d448
Fixed bug #2962 - when SDL_RenderReadPixels format = 0, used format of the target texture
include/SDL_render.h, format:
"0 to use the format of the rendering target "
2022-03-21 10:41:14 +01:00
Eddy Jansson 24ffcbd9ad audio: Set error message on dsp init failure.
if SDL_EnumUnixAudioDevices() fails to find any devices,
set an error message on the exit path. Without this,
SDL_Init() could fail without any message available
in SDL_GetError().
2022-03-20 10:31:19 -07:00
Sam Lantinga 8f964576da Fixed parameter operation ordering for ease of reading 2022-03-19 11:01:55 -07:00
Sam Lantinga 0517b61ed6 Relative mouse mode is tied to the window with keyboard focus
This isn't obvious, but makes sense when thinking about how games actually use it. This is also in line with how Windows mouse relative mode is implemented.

Fixes https://github.com/libsdl-org/SDL/issues/5340
2022-03-19 11:00:00 -07:00
Sam Lantinga b559a4accc Fixed Android crash when SDL_HIDAPI_DISABLED set to 1
The Java code needs the native functions to be implemented, even if they're not surfaced via the C API.

Fixes https://github.com/libsdl-org/SDL/issues/5326
2022-03-19 10:39:22 -07:00
Sam Lantinga a485ffc3c8 Fix "SDL_FALSE is not defined" runtime error for emscripten. 2022-03-19 09:50:22 -07:00
Ryan C. Gordon d81fee7623
SDL_Rect: Added floating point versions of all the rectangle APIs.
Fixes #5110.
2022-03-19 10:35:24 -04:00
Ryan C. Gordon 4d9bef604a
SDL_Rect: minor code cleanups. 2022-03-19 10:35:23 -04:00
Ryan C. Gordon c573ebe143
SDL_UnionRect: If both rects are empty, zero out the result struct. 2022-03-19 10:35:23 -04:00
Christian Kündig fbbd0270eb Fix "SDL_TRUE is not defined" runtime error for emscripten. 2022-03-18 16:42:12 -07:00
Sam Lantinga 6c96217727 Added the hint SDL_HINT_MOUSE_RELATIVE_MODE_CENTER, controlling whether the mouse should be constrained to the center of the window or the whole window in relative mode.
For further info about the pros and cons, check out the discussion in https://github.com/libsdl-org/SDL/issues/5271
2022-03-18 10:07:59 -07:00
Sam Lantinga 1868c5b521 Start rumbling once a raw input controller has been correlated
Fixes https://github.com/libsdl-org/SDL/issues/5351
2022-03-17 18:25:50 -07:00
Sam Lantinga 3167ba342d Fixed freeing the Windows blank cursor 2022-03-17 17:58:35 -07:00
Sam Lantinga 0387bf821a Fixed memory leak in WIN_CreateBlankCursor() 2022-03-17 17:55:28 -07:00
Sam Lantinga 5ff42438e3 Added a hint to capture the mouse when mouse buttons are pressed, defaulting on
Fixes https://github.com/libsdl-org/SDL/issues/5301
2022-03-17 17:39:46 -07:00
Sam Lantinga 09b8152fae Use SDL_Log instead of printf 2022-03-17 17:19:21 -07:00
Sam Lantinga b22ce2b5a8 Workaround for bug in Microsoft WGI support
Fixes https://github.com/libsdl-org/SDL/issues/5270
2022-03-17 17:10:40 -07:00
Sam Lantinga d406278513 Try not forcing activation when grabbing the mouse in fullscreen windows 2022-03-17 17:01:36 -07:00
Sam Lantinga 4e784fce43 When updating grab state, only activate windows that are grabbed, fullscreen, and shown.
Fixes https://github.com/libsdl-org/SDL/issues/5371
2022-03-17 16:57:33 -07:00
Sam Lantinga e5f45455c9 Added a hint to mark a foreign window as usable with OpenGL
Fixes https://github.com/libsdl-org/SDL/issues/2942
2022-03-17 14:44:34 -07:00
Sam Lantinga 4e49b78a11 Fixed compile warning and comment typo 2022-03-17 14:44:17 -07:00
Ethan Lee 0bf8ccfb60 video: Add a hint to allow Vulkan surfaces on foreign windows 2022-03-17 14:25:55 -07:00
Sam Lantinga ecaa22cbe6 Don't warn if anyone peeps for events after quitting the event subsystem
Fixes https://github.com/libsdl-org/SDL/issues/5013
2022-03-17 14:22:51 -07:00
Antoine Fontaine 3318590796 Fix relative mouse input for Unvanquished (unvanquished.net)
Here's an IRC dump that hopefully explains the issue this fixes:

> I'm debugging something odd where, for a libre game,
  unvanquished.net (a FPS), relative mouse input in fullscreen is
  buggy
> it's like, working mostly ok, but it has a weird
  performance/cleanup bug
> after some time in relative mouse input mode, some time as low
  as 15s, usually more, the SDL sends A LOT of relative mouse
  input per frame
> almost all of which have xrel==0 && yrel==0
> by A LOT, I mean that after ~1min, it's usually in the
  thousands per frame
> each frame, a while ( SDL_PollEvent( &e)) loop reads the
  inputs, but it seems SDL is not clearing the list.
> one way to clear the list is to open the in-game console or
  menu, which switches the input mode to absolute, then close it
  which gets a working relative input mode (for some time at least)
> I've shown the issue to be present with SDL2.0.20 but not with
  2.0.14 on my system
> some other players on Arch Linux (SDL2.0.20) report a possibly
  related issue, where some keys seem to be pressed at random
> I've did some bisection on SDL master, and I've found that
  there are actually two commits involved, one breaking it
  totally (no input at all), and one fixing it partially (with
  the problem described above)

First related commit that breaks it totally:

	commit 82793ac279
	Author: Sam Lantinga <slouken@libsdl.org>
	Date:   Thu Oct 14 14:26:21 2021 -0700

	    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

Second related commit, that halfway fixes it:

	commit 31f8c3ef44
	Author: Sam Lantinga <slouken@libsdl.org>
	Date:   Thu Jan 6 11:27:44 2022 -0800

	    Fixed event pump starvation if the application frequently pushes its own events

Reverting the first commit did fix the issue for me, but would
probably reintroduce the bug it was fixing(?). This patch should
fix it for everyone hopefully.

https://github.com/DaemonEngine/Daemon/issues/600 is the upstream
bug, and contains some early investigation.
2022-03-17 14:00:59 -07:00
Esme Povirk 829e15a490 Ignore unknown WM_SIZE types.
According to MSDN, we can also get SIZE_MAXHIDE and SIZE_MAXSHOW,
based on state changes to other windows. It's not clear under
what circumstances this will happen (I saw some docs indicating
it may require multiple application windows), but it doesn't seem
right to treat them as RESTORED.
2022-03-17 12:51:46 -07:00
uyjulian a164c9d245 SDL_cocoawindow.m: update fullscreen toggle when SDL_SetWindowResizable called 2022-03-17 12:35:57 -07:00
Sam Lantinga cc152103ba Fixed warnings when building with cygwin
Fixes https://github.com/libsdl-org/SDL/issues/5025
2022-03-17 11:37:08 -07:00
Sam Lantinga e8c3ff56e0 Removed problematic call to ISensor_SetEventSink()
Fixes https://github.com/libsdl-org/SDL/issues/5288
2022-03-17 10:01:13 -07:00
Sam Lantinga bcb0f1de23 Fixed build when events are disabled
Fixes https://github.com/libsdl-org/SDL/issues/5413
2022-03-17 08:52:31 -07:00
pionere 01bfde4520 simplify SetDSerror
- no need to keep the error in a static variable
- always print the error code
- reduce the required stack-size
- reduce the number of snprintf calls (and code size)
2022-03-17 08:44:06 -07:00
Ozkan Sezer dfbe1f7248 SDL_GetBasePath() fixes for OS/2 2022-03-17 03:50:02 +03:00
Sylvain b2db570ce9
SDL_triangle_blit_slow: sync code with SDL_blit_slow to handle ARGB2101010 2022-03-16 18:09:40 +01:00
Sylvain 93e7caab9a
SDL_blit_slow: remove one nested 'if()' because of ARGB2101010 handling 2022-03-16 18:08:20 +01:00
Sylvain 56568ffb38
Remove 'reserved identifier' warning 2022-03-16 18:04:40 +01:00
pionere 2c6a9c5194 minor optimization (SDL_audiocvt.c) 2022-03-16 07:58:28 -04:00
Ozkan Sezer 5905696e66 SDL_audiocvt.c: minor cleanup. 2022-03-15 23:10:04 +03:00
Ozkan Sezer d1e4367f58 SDL_windowskeyboard.c: fix build with SDL_DISABLE_WINDOWS_IME defined.
Fixes https://github.com/libsdl-org/SDL/issues/5408
2022-03-15 21:41:02 +03:00
Sylvain f3e86b9fd3
Fixed bug #2199: make SDL_blit_slow handles SDL_PIXELFORMAT_ARGB2101010, storing as RGBA 2022-03-15 17:46:12 +01:00
Sylvain Becker 3bebdaccb7 METAL: clip rect w/h must be <= render pass 2022-03-15 10:37:17 +01:00
Wohlstand 7c421fec16 SDL_audiocvt.c: Don't byteswap 8-bit streams
Otherwise, this results an assert on big endian machines when attenpting to use SDL_LoadWAV_RW function to load 8-bit WAV files.
2022-03-14 08:41:07 -07:00
Zach Reedy 363c36781d Fixed: Incorrect assumption that mouse button is released when window is allocated 2022-03-14 08:38:25 -07:00
Guus Waals 7495b98141 Make SDL_VIDEO_OPENGL_EGL optional on Android 2022-03-14 13:38:12 +01:00
Ozkan Sezer ee6bfcdd66 SDL_blit_N.c: removed duplicated const (fixes bug #5401) 2022-03-13 20:56:42 +03:00
Ozkan Sezer 072db7b005 SDL_windowskeyboard.c (IME_IsTextInputShown): remove unused local vars. 2022-03-12 01:56:40 +03:00
Zach Reedy d14a126383
IME Composition Truncation + SDL_IsTextInputShown + SDL_ClearComposition (#5398)
* Fixes for IME Composition Truncation + Addition of SDL_ClearComposition, SDL_IsTextInputShown

* Fixed: Documentation and code style issues raised during code review.
2022-03-11 14:45:17 -08:00
Charlie Birks 9de97e19cc emscripten: Don't prevent default on filtered key events 2022-03-11 11:55:41 +00:00
Ozkan Sezer afb0606f5a minor os/2 clean-ups. 2022-03-10 18:50:10 +03:00
Cameron Gutman 677dc1015c rawinput: Fix double detection of gamepads on some 3rd party X360 wireless receivers
The name that the Raw Input joystick driver pulls from the HID stack comes
from USB string descriptors contained on the device. For official wireless
receivers, this always contains "Xbox 360 Wireless Receiver for Windows"
which matches the friendly name that WGI provides.

3rd party Xbox 360 wireless receivers may have different strings in their
USB string descriptors (one uses "XBOX 360 For Windows" instead). This
fails to match WGI's name and causes Raw Input and WGI to both report the
same gamepad.

Since wireless Xbox 360 controllers seem to have a consistent VID/PID
regardless of the adapter enumerating them, we can also match on that to
catch these.

The duplicate case reported to me was:
Controller (XBOX 360 For Windows) - 030000005e040000a102000000007200
Xbox 360 Wireless Receiver for Windows - 030000005e0400000000000000007701
2022-03-09 21:19:53 -08:00
Ozkan Sezer bf69868924 reduced a few ifdefs, fixed an unused warning if built w/o SDL_HAVE_YUV. 2022-03-10 01:55:04 +03:00
Jo Bates 01d38e7ade Make Win32 fullscreen and borderless windows minimizable 2022-03-09 14:08:12 -08:00
Sam Lantinga 09b652b70a Make sure the string properties are actually strings (thanks Nat!) 2022-03-09 13:54:23 -08:00
Sam Lantinga c6eef542ab Removed dead code 2022-03-09 13:48:31 -08:00
pionere 911ba8d343
hide impossible branch in D3D_UnlockTexture 2022-03-09 20:17:55 +01:00
Sylvain ea5b482bff
Remove unused warning 2022-03-09 15:38:36 +01:00
Sylvain 45833a148d
Prevent shadowing static variable '_this' with local paramter '_this' of SDL_CreateWindowTexture 2022-03-09 15:33:45 +01:00
Sylvain a4a80c8607
Fix variable may be uninitialized when used here [-Wconditional-uninitialized] 2022-03-09 15:21:55 +01:00
Sylvain 04256a5372
Fix compilation (see #5313) 2022-03-09 15:12:25 +01:00
pionere 0983fcee5e
fix memory leak in D3D11_CreateRenderer 2022-03-09 15:03:49 +01:00
pionere 3f8b450de2
extend the code hidden by SDL_HAVE_YUV 2022-03-09 15:03:30 +01:00
pionere ce1883e1e7
fix compile error with disabled SDL_HAVE_YUV (vita)
- UpdateTextureYUV is not defined if SDL_HAVE_YUV is not defined/zero
+ calling SDL_free suffice if the VITA_GXM_RenderData was just allocated
2022-03-09 15:02:44 +01:00
Sam Lantinga 14db417e12 Reenable getting the serial number on macOS
We filter now on game controllers, so we shouldn't hit the crash bug on random devices that this was working around.
2022-03-08 21:32:27 -08:00
Sam Lantinga c3ca3445bd Prefer HIDAPI on macOS, as that has extended functionality 2022-03-08 18:56:49 -08:00
Sam Lantinga 6a787619e6 Allow reading background events for MFi controllers 2022-03-08 18:42:13 -08:00
Sam Lantinga b064ad6ac5 Allow GL_ARB_texture_non_power_of_two environment variable to override OpenGL 2.0 check 2022-03-08 18:14:10 -08:00
Sam Lantinga 1b7669374e Fixed the SDL controller type for USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 2022-03-08 09:58:24 -08:00
Mahyar Koshkouei 41e7d1baa6 Add SDL_GetDisplayDPI implementation on Emscripten
Signed-off-by: Mahyar Koshkouei <mk@deltabeard.com>
2022-03-07 07:18:45 -05:00
Cameron Gutman b2463a917c events: Add logging support for several missing event types 2022-03-06 15:02:53 -06:00
Sam Lantinga bdafe1e049 Fixed whitespace 2022-03-04 11:01:55 -08:00
Sam Lantinga 2e801b1ae7 Split long text input into multiple events if needed (thanks @zreedy!) 2022-03-04 10:50:16 -08:00
Cameron Cawley 2f7b885df9 Fix 'potentially uninitialized local pointer variable' error in UWP builds 2022-02-28 09:04:33 -08:00
Cameron Cawley 98353533e5 riscos: Report keyboard repeat events 2022-02-24 09:11:33 -08:00
Sam Lantinga af40cb6f00 Added support for the Razer Huntsman Analog keyboard in controller mode 2022-02-23 15:49:10 -08:00
Phillip Stephens 94d43186f2 GameCubeAdapter: Add suppport for all rumble modes
This adds support for all 3 of the gamecube controller's rumble modes
Rumble: 1
Stop: 0
StopHard: 2
This is useful for applications that need the full range of support
This also adds a hint to control rumble behavior, defaults 0 to maintain compatibility
2022-02-23 07:03:02 -08:00
Ryan C. Gordon b946e31ec8 video: Allow unaccelerated SDL_HINT_FRAMEBUFFER_ACCELERATION renderers.
If the app requested a specific renderer, even if it's not the optimal path,
let them have it, because they might want to render with a specific GPU API
on top of the framebuffer pixels.

This fixes DosBox-X crashing on startup, which forces the hint to "opengl".
2022-02-23 09:36:06 -05:00
Ryan C. Gordon 60ddb74cfe video: rework how we prepare a texture framebuffer.
Now we see if we can create an SDL_Renderer, and if that renderer reports
itself as "accelerated," and added some initial heuristics to the OpenGL
renderer to make better decisions about what qualifies as "accelerated."

This adds some FIXMEs that might be merely hypothetical, and removes the
old OpenGL checks from the video subsystem that probably weren't meaningful
in modern times. This will definitely need to improve the existing list
in the GL renderer, to catch things like llvmpipe, etc.

Reference issue #4624.
2022-02-23 09:36:06 -05:00
Wohlstand 08d27dfd7b SDL_openslES.c: Detect float support in runtime and use it
Allow using of the float output type on newer Android devices, but keep PCM16 output on older

Closes #5358
2022-02-22 08:31:14 -08:00
Ryan C. Gordon 293a0aa80e
opengl: If GL version >= 2.0, NPOT textures are supported, so favor them.
Fixes #5041.
2022-02-22 10:54:21 -05:00
Sam Lantinga 9299a3e796 Workaround for crash in CoUninitialize() 2022-02-21 16:24:45 -08:00
Sam Lantinga 978fbc3250 Fixed compile warnings 2022-02-21 12:02:44 -08:00
Sam Lantinga 6c531c4334 Correct handling of sentinel events when polling without removing events
Fixes https://github.com/libsdl-org/SDL/issues/5350
2022-02-21 11:35:31 -08:00
Cacodemon345 d90bd261f3 wscons: Make USB keyboard input layout independent 2022-02-18 09:30:04 -08:00
Sylvain 9d86ec8573
Palette format: software Render Jitter in rotation (see #5143)
- same fix applied for rotation with palette surfaces
- allow other 8bits format (eg 332)
2022-02-18 09:57:10 +01:00
Sylvain ceb09ee740
Fixed #5143 - software Render Jitter in rotation
better precision calculating rotated coordinates and interpolation
2022-02-17 23:11:02 +01:00
Sam Lantinga 18032979d8 Added the hint SDL_HINT_JOYSTICK_ROG_CHAKRAM to control whether ROG Chakram mice show up as joysticks
This hint defaults off, but when it is enabled the mice will have a game controller mapping set up for Profile 3 (set in the Armoury Crate software)
2022-02-15 13:07:51 -08:00
Sylvain 75ffa24e3a
Software Render Jitter in rotation (bug #5143)
The output surface doesn't necessarily to have even width and height.
2022-02-15 13:35:59 +01:00
Sylvain 61abc4e5b6
PSP: SDL_RenderCopyEx rotation and global scaling around the wrong way (see #bug 3070) 2022-02-15 11:34:50 +01:00
Sylvain 18b76fcc5d
Fixed bug #3070 - SDL_RenderCopyEx rotation and global scaling around the wrong way (software renderer) 2022-02-15 11:33:56 +01:00
Sylvain e366ad1288
Fixed bug #2308: SDL_RenderCopyEx rotation center precision (software renderer) 2022-02-15 10:02:34 +01:00
Wouter Wijsman 66ee79bd68 [PSP] Don't swizzle streaming textures
It was causing issues in the teststreaming demo and unswizzling
later is inefficient and causes issues.
2022-02-14 10:59:25 +01:00
Sam Lantinga f97a29f6e1 Use the real device VID/PID when seeing the Steam virtual controller 2022-02-11 22:10:33 -08:00
Sylvain 85e6500065
X11 Segmentation fault with multiple windows and renderers (see #5256) 2022-02-11 11:08:08 +01:00
Sylvain a75041e8dd
Fixed bug #2140: basic support to convert 16 colors palette PIXELFORMAT_INDEX4, to allow conversion to SDL_Texture 2022-02-10 13:44:59 +01:00
Wouter Wijsman abc8198a1f Render all sides when drawing rect on PSP 2022-02-09 09:36:19 -08:00
Frank Praznik 228db35287 audio: pipewire: Tidy up formatting 2022-02-08 14:33:34 -05:00
Frank Praznik 9da9e85cba audio: pipewire: Reset all hotplug values and pointers on shutdown
Ensure that all hotplug variables and pointers are reset to NULL or their original value when shutting down.
2022-02-08 14:33:34 -05:00
Frank Praznik 5b36a527ed audio: pipewire: Remove redundant locks
The io_list_check_add() and io_list_remove() functions are only ever called from within the Pipewire thread loop, so the locks are redundant.  io_list_sort() is called from within a lock in the device detection function, so those additional locks are redundant as well.
2022-02-08 14:33:34 -05:00
Frank Praznik 48b4d1c412 audio: pipewire: Convert atomic hotplug conditional variables to SDL_bool
The hotplug loop condition variables are always guarded by the loop mutex while the loop is running, so they don't need to be atomic.
2022-02-08 14:33:34 -05:00
Ozkan Sezer 67f12ede3b move bug #5333 fix to headers 2022-02-08 21:32:50 +03:00
Wouter Wijsman 54304b971d Fix rotation direction and center point on PSP 2022-02-08 09:47:10 -08:00
Wouter Wijsman 2b572dff88 Make RenderCopyEx rotate around center
This still isn't perfect. The rotation is the wrong way around and the
images are upside down.
2022-02-08 09:47:10 -08:00
Ozkan Sezer 7935cfacc5 SDL_mfijoystick.m: use __typeof instead of typeof.
Fixes https://github.com/libsdl-org/SDL/issues/5319
2022-02-08 18:55:10 +03:00
Ozkan Sezer 9b817248c5 SDL_spinlock.c: define HAVE_GCC_ATOMICS for windows/clang builds,
... if not already defined.
Fixes https://github.com/libsdl-org/SDL/issues/5333

diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index bdd347e..4f10741 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -28,6 +28,12 @@
 #include "SDL_mutex.h"
 #include "SDL_timer.h"

+#if defined(__WIN32__) && defined(__clang__)
+# ifndef HAVE_GCC_ATOMICS
+# define HAVE_GCC_ATOMICS 1
+# endif
+#endif
+
 #if !defined(HAVE_GCC_ATOMICS) && defined(__SOLARIS__)
 #include <atomic.h>
 #endif
2022-02-08 18:50:02 +03:00
Sylvain e7e44df039
Dynapi: add SDL_GetTouchName() entry 2022-02-08 11:34:41 +01:00
Sylvain 34d4f5b14e
Fixed bug #2032: add SDL_GetTouchName to expose the driver name of the device (Thanks @mgerhardy!) 2022-02-08 11:32:20 +01:00
Frank Praznik 53091e36a3 audio: pipewire: Remove the hard upper bound on rates and buffer sizes
Remove the hard upper limit of 8192 samples and instead use the buffer sizes provided by Pipewire to determine the size of the intermediate input buffer and whether double buffering is required for output streams. This allows for higher latency streams to potentially avoid double-buffering in the output case, and we can guarantee that the intermediate input buffer will always be large enough to handle whatever Pipewire may deliver.

As the buffer size calculations occur in a callback in the Pipewire processing thread itself, the stream readiness check has been modified to wait on two distinct flags set when the buffers have been configured and when the stream is ready and running.
2022-02-07 15:11:31 -05:00
Frank Praznik 66866249a2 audio: pipewire: Condition variable doesn't need to be atomic
The condition variable is guarded by a mutex, so no need for it to be atomic.
2022-02-07 15:11:31 -05:00
Sylvain b0dd4c7d36 SDL_Render OpenGL: do batching like in the GLES2 backend (with no VBO) 2022-02-07 14:02:20 -05:00
Sylvain 90f0d2ce49 Revert OpenGL point drawing performance, do to proper batching 2022-02-07 14:02:20 -05:00
waddlesplash 423feac69b haiku: Actually remove BDirectWindow and fix OpenGL handling.
This provides the other half of 05c72b113c830392f8b08532317ef07972b29a2e.
2022-02-06 19:19:21 -05:00
pionere 6d5592a201 minor cleanup of SDL_CreateRenderer 2022-02-05 10:05:25 -05:00
Ozkan Sezer e8c48981f9 pthread/SDL_systhread.c: always include errno.h
fixes build for several targets after commit 87b02d3 for bug #5283.
2022-02-05 08:56:56 +03:00
Sam Lantinga 5c4fff7f63 Don't fail to get battery status if the upower refresh call fails 2022-02-04 14:02:44 -08:00
Ozkan Sezer c8cee0b8ca OS2_HasClipboardText: store the boolean result before closing clipboard.
just in case..
2022-02-04 23:28:56 +03:00
Ozkan Sezer c93e552068 minor update to winrt/SDL_sysurl.cpp
from: https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/0006-Update-SDL_sysurl.cpp.patch
2022-02-04 20:03:50 +03:00
Ozkan Sezer 3b9e6c1cec SDL_os2video.c: fixed HasClipboardText() semantics.
Empty string in clipboard is expected to give FALSE by SDL_HasClipboardText.
Noticed in a commit by josch1710 in bitwiseworks' os/2 fork.
2022-02-04 19:50:20 +03:00
Joshua Ashton 86b7a0642f Add additional VID/PIDs for Anne Pro II
This thing changes its VID/PID on firmware revisions...
2022-02-04 08:45:19 -08:00
Sam Lantinga dd69c28d6f Added a mapping for the Xbox Series X controller, firmware version 5.11.3118.0, connected to Linux via Bluetooth 2022-02-03 18:01:34 -08:00
Temdog007 b59e75c259 Handle menu button press from controller 2022-02-02 21:21:44 -08:00
pionere 2cfc83eab7
sync D3D_RenderReadPixels with D3D11_RenderReadPixels
- use the result of SDL_ConvertPixels to propagate error
- get rid of the verbose error message of D3D11_RenderReadPixels in case SDL_ConvertPixels failed
2022-02-02 14:56:38 -05:00
pionere 3bef4a5da6
cleanup error-handling in SDL_egl.c
- always set error message in SDL_EGL_ChooseConfig / SDL_EGL_CreateContext
- assume SDL_EGL_DeleteContext does not alter the error message
- sync generic error message of SDL_EGL_MakeCurrent with SDL_EGL_Get/SetSwapInterval
- do not overwrite error message of SDL_EGL_ChooseConfig in WINRT_CreateWindow
2022-02-02 14:56:21 -05:00
pionere b5c5052608
cleanup error-handling in SDL_bmp.c
- add missing error-message in SDL_LoadBMP_RW
- check return value of SDL_RWtell in SDL_LoadBMP_RW
- use standard SDL_EFREAD error instead of custom strings
+ adjust return type of readRlePixels
2022-02-02 14:55:36 -05:00
pionere 19df4af2aa
simplify SDL_DUMMY/OFFSCREEN_CreateWindowFramebuffer 2022-02-02 14:45:48 -05:00
SonicMastr ecd922b5cf Fix touch holding detection after #5244 changes 2022-02-02 08:55:26 -08:00
Sylvain df0d696a62
RISCOS: attempt to fix compilation ERANGE 2022-02-02 15:22:14 +01:00
Sylvain 87b02d3795
Linux thread name limitation: test for ERANGE (see bug #5283) 2022-02-02 15:09:29 +01:00
Sylvain 220a9596f3
Remove testing instruction (see bug #5283) 2022-02-02 10:01:11 +01:00
Sylvain 9e46a512b1
Fixed bug #5283 - limit thread name to 16 characters when using pthread_setname_np() 2022-02-02 09:58:15 +01:00
Weng Xuetian b11dfd7611 Only generate key repetition for keys that should repeat on wayland.
This fix repetition on modifier keys, e.g. Control.
2022-02-01 17:56:04 -05:00
Weng Xuetian a90a2e7582 Fix text_input_v3 preedit string
For every batch of text_input_v3 updates, if there is no preedit in this
batch, preedit should be cleared.
2022-02-01 15:51:26 -05:00
Sam Lantinga 03c4405b3b Fixed D-Bus battery refresh call 2022-02-01 09:33:18 -08:00
Sylvain d224a63bda
Fix compilation for non Android 2022-02-01 11:34:01 +01:00
Sylvain fe2ed6cf6f
Fixed bug #5221 - Add SDL_AndroidSendMessage() 2022-02-01 11:30:43 +01:00
pionere 97269e143d adjustments to ime_candidates
- allocate ime_candidates on demand
- allow write to the whole allocated memory of ime_candidates
- ensure ime_candcount is set to zero in case the candidates can not be queried for any reason
2022-01-31 22:06:26 -05:00
pionere 6f404d0f04 cleanup IME_GetCandidateList / UILess_GetCandidateList
- move IME_ShowCandidateList, ImmGetContext and ImmReleaseContext to this function
- set ime_candpgsize to MAX_CANDLIST if dwPageSize is zero
- comment out deselection of ime_candsel in case of korean language for the moment (LANG_CHT does not work anyway)
2022-01-31 22:06:26 -05:00
Sam Lantinga ec8e3104c8 Refresh the battery state before we query it on Linux 2022-01-31 17:01:08 -08:00
Frank Praznik 0b34f18045 audio: pipewire: Don't double free properties on init failure
The context and stream creation functions will destroy the passed properties object on failure, so no need to do it manually.

The pw_properties_free() function pointer is no longer needed, so it can be removed.
2022-01-30 23:23:03 -05:00
Sylvain f7d3abddba
Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport.
Handle the case when there is blending
2022-01-29 10:19:08 +01:00
pionere a5c610b0a3 revert 'Changed to use 0xFE instead of 0xFF for better sound quality.' 2022-01-28 20:40:19 -05:00
Ryan C. Gordon 43f0271b4e Revert "fix compiler warnings in SDL_windows_gaming_input.c"
This reverts commit ca36cdb185f2f26241598068927821896f36b904.

The older Windows SDK's headers are wrong, and this change would crash if
you hotplug a device.
2022-01-28 20:40:19 -05:00
pionere a70bb259c7 drop handle parameter of OpenDevice 2022-01-28 20:40:19 -05:00
pionere 47ddb04e17 cleanup/sync the main loop of *_OpenDevice functions to pick audio format II. 2022-01-28 20:40:19 -05:00
pionere 2eafe4340c cleanup/sync the main loop of *_OpenDevice functions to pick audio format 2022-01-28 20:40:19 -05:00
pionere 3939ef72f8 cleanup SDL_GetAudioDeviceSpec
- drop unnecessary hascapture check
- call SDL_InvalidParamError and return -1 in case the index is out of range
- do not zfill SDL_AudioSpec
- adjust documentation to reflect the behavior
2022-01-28 20:40:19 -05:00
pionere 113109f839 cleanup SDL_GetAudioDeviceName
- drop unnecessary hascapture check
- call SDL_InvalidParamError in case the index is out of range
2022-01-28 20:40:19 -05:00
pionere f91211eb17 cleanup WASAPI_PrepDevice
- reorganize the loop which checks for the right wave-format
- use the return value of UpdateAudioStream
- ensure SetError is called in SDL_NewAudioStream
2022-01-28 20:40:19 -05:00
pionere c9e8d1573a re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory II. 2022-01-28 20:40:19 -05:00
pionere 1043dd8c0d adjust handling of iscapture
- drop iscapture parameter of OpenDevice
- use SDL_bool for iscapture
2022-01-28 20:40:19 -05:00
pionere e2f70a2dff cleanup SDL_EventState 2022-01-28 20:40:19 -05:00
pionere 32c7d5d352 cleanup IME_UpdateInputLocale
- do not store the HKL in a static variable
- always set the ime_candvertical value in case the HKL is changed
2022-01-28 20:40:19 -05:00
pionere 25aa7244dc cleanup IME_GetId
- use assert instead of a check (it is a static function with constant parameter)
- assume it is called with 0 first (simplifies the logic)
- reuse dwLang value instead of a new 'call' to LANG()
2022-01-28 20:40:19 -05:00
pionere 60deadba59 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory 2022-01-28 20:40:19 -05:00
pionere ebdd536676 use SDL_InvalidParamError or SDL_assert instead of custom SDL_SetError 2022-01-28 20:40:19 -05:00
pionere 4a17612bff get rid of BeginLoopIteration 2022-01-28 20:40:19 -05:00
pionere 0770c5829c get rid of PrepareToClose 2022-01-28 20:40:19 -05:00
Ryan C. Gordon e0236c02ce audio: Removed an unnecessary commented-out line. 2022-01-28 20:40:19 -05:00
pionere 0dda8a7f4c cleanup init functions of audio
- use SDL_bool if possible
- assume NULL/SDL_FALSE filled impl
- skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
2022-01-28 20:40:19 -05:00
pionere 6fcfcc3d6f get rid of SkipMixerLock 2022-01-28 20:40:19 -05:00
pionere 3c85cef46c cleanup SDL_RegisterApp
- fix memory leak when RegisterClassEx fails
- set style according to the documentation
- eliminate duplicated SDL_Instance setter
2022-01-28 20:40:19 -05:00
pionere 014e2bbdb2 use SDL_COMPILE_TIME_ASSERT instead of SDL_STATIC_ASSERT 2022-01-28 20:40:19 -05:00
pionere 95f30c7a48 fix compiler warnings in video/uikit 2022-01-28 20:40:19 -05:00
pionere 176941a4fb allow MacOS build without SDL_FILE 2022-01-28 20:40:19 -05:00
pionere eb80f2c65a sync handling of subsystems II. 2022-01-28 20:40:19 -05:00
pionere 942b01a54c do not use RWOps in WIN_SetWindowIcon 2022-01-28 20:40:19 -05:00
pionere bf66720a4d fix mixing of U16 audio 2022-01-28 20:40:19 -05:00
pionere 905e2e22ef cleanup of SDL_MixAudioFormat 2022-01-28 20:40:19 -05:00
pionere d7110b4490 fix compiler warnings in SDL_windows_gaming_input.c 2022-01-28 20:40:19 -05:00
pionere e11ba0f5d9 do not load/unload opengl library when SDL_WINDOW_METAL flag is changed 2022-01-28 20:40:19 -05:00
Sylvain f5911bdc59 GLES2: disable texcoord when not using it (see bug #5235)
similar to opengl backend code:
- glDisableVertexAttribArray doesn't need to depend on 'drawstate.texture' value
- move binding code to SetCopyState()
2022-01-28 19:25:40 +01:00
Sylvain 096fe37bb2 GLES2: revert 7bf8c5a388 2022-01-28 19:25:40 +01:00
Sylvain a988ce5544
Fixed bug #964 - SDL_RenderCopy stretch loses proportion on viewport boundaries 2022-01-28 17:24:59 +01:00
Sylvain 7bf8c5a388 GLES2: disable texcoord when not using it (see bug #5235) 2022-01-27 21:49:05 -05:00
Vitaliy Zhmurikov 5b74459255 Update SDL_joystick.c
Add Logitech Momo Racing Wheel VID & PID  to SDL_IsJoystickProductWheel function
2022-01-27 12:30:41 -08:00
Ryan C. Gordon 19ae71b2db
video: Don't add SDL_WINDOW_(METAL|OPENGL) to new windows if unsupported.
Fixes #4656.

(Better than the previous fix in 3044310518dbb2d4814b32c6521f332b8d69aae5.)
2022-01-27 11:49:15 -05:00
Ivan Epifanov d7e0c54dde PSVita: send initial SDL_JOYDEVICEADDED events 2022-01-27 08:47:53 -08:00
Cameron Gutman cc40f732f9 wayland: Round the refresh rate rather than truncating it
A 59999 mHz monitor should be reported as 60 Hz, not 59 Hz.
2022-01-26 21:27:13 -06:00
Ryan C. Gordon 3044310518 video: Don't add SDL_WINDOW_METAL to new windows if not using Cocoa or UIKit.
Fixes #4656.
2022-01-26 21:10:15 -05:00
Cameron Gutman 77a9ca6ba0 wayland: Fix SDL_SetWindowSize() being dropped right after exiting fullscreen
If we get a SDL_SetWindowSize() call right after SDL_SetWindowFullscreen() but
before we've gotten a new configure event from the compositor, the attempt to
set our window size will silently fail (when libdecor is enabled).

Fix this by remembering that we need to commit a new size, so we can do that
in decoration_frame_configure().
2022-01-26 19:48:16 -05:00
Cameron Gutman c6ec5a07f1 d3d11: Respect SDL_HINT_RENDER_DIRECT3D_THREADSAFE when creating device 2022-01-26 18:44:29 -06:00
Ryan C. Gordon f37e4a94d3
video: Don't check if we can use a "texture framebuffer" until needed.
This prevents SDL from making an OpenGL context and maybe throwing it away
immediately by default. It will now only do it when trying to request a
window framebuffer directly, or creating an SDL_Renderer with the "software"
backend, which makes that request itself.

The way SDL decides if it should use a "texture framebuffer" needs dramatic
updating, but this solves the immediate problem.

Reference Issue #4624.
2022-01-26 17:06:25 -05:00
Ethan Lee 8ceba27d62 video: Prefer Wayland over X11 2022-01-26 12:32:45 -05:00
Ethan Lee 68a71f91c6 wayland: Try to avoid committing before the window is shown 2022-01-25 17:19:19 -05:00
Sam Lantinga 84320266f2 Fixed the queue filling up with sentinel events when the WaitEvent call is passed NULL for the event
The use case is an application that waits for events on the main thread and dispatches them on a separate thread.
2022-01-25 12:37:43 -08:00
Ethan Lee f0e768da43 wayland: Call SetFullscreen directly in ShowWindow.
This cuts out an extra flush when getting the first configure event.
2022-01-25 13:07:00 -05:00
Sylvain 8c660ccb6f
Fixed bug #5256: X11 Segmentation fault with multiple windows and renderers
First window is created and it triggers and 'EnterNotify' event
which calls SDL_SetMouseFocus() and X11_ShowCursor() while the second
windows hasn't finished to be created  (eg window->driverdata isn't set)
Just check for a valid 'driverdata'
2022-01-25 17:18:40 +01:00
Ethan Lee e2d74bcbe5 wayland: Detach hidden surfaces in HideWindow, not ShowWindow 2022-01-25 11:16:09 -05:00
ulatekh 57bc90403e Add hint to optionally forcibly raise the window under MS Windows. 2022-01-24 11:10:57 -08:00
ulatekh d7873e656b Disable tablet flicks under MS Windows. 2022-01-22 08:52:46 -08:00
Charlie Birks 15ebad6e7d emscripten: Implement SDL_OpenURL 2022-01-22 13:31:11 +00:00
Charlie Birks 99af3281ee timer: Fix Emscripten declaration-after-statement error 2022-01-22 12:27:54 +00:00
ulatekh 53df0e6619 Fix the erroneous generation of mouse-down events from touch-move events.
The issue is that MS Windows synthesizes a mouse-move event in response
to touch-move events, and those mouse-move events are NOT labeled as
coming from a touch (e.g. GetMouseMessageSource() will not return
SDL_MOUSE_EVENT_SOURCE_TOUCH for those synthesized mouse-move events).

In addition, there seems to be no way to prevent this from happening;
https://gist.github.com/vbfox/1339671 claims to demonstrate a technique
to prevent it, but in my experience, it doesn't work.

Because of this, the "fallthrough" case can't test that the synthesized
mouse-move came from a touch-move, and starts erroneously pressing down
the mouse-button, leading to massive confusion in the client
application.
2022-01-21 17:23:59 -08:00
ulatekh 8f8b14cbb6 Synthesize a missing touch-up event.
If a touch-down event is received for an existing touch-ID, that
probably means the operating system lost it, and that the missing
touch-up should be synthesized, to keep the client state coherent.
2022-01-21 17:23:11 -08:00
Ozkan Sezer d2456b6e4c os2, geniconv: default functions pointers to Uni*() API,
In case they get accessed before SDL_Init() was called.
2022-01-21 11:50:40 +03:00
Sam Lantinga 67cb548bef Fixed build error with C90 compilers 2022-01-20 19:31:54 -08:00
Carl Glave a23b3c767f Add support for correlating trigger input 2022-01-20 17:43:35 -08:00
Ethan Lee e1b4761c62 wayland: Avoid calling SetFullscreen in libdecor ShowWindow.
This caused some weird stuff to happen in the libdecor path, probably because
the window hasn't actually been mapped yet. It ends up calling stuff that
should not yet apply, and so fullscreen in particular would have a really
messed up titlebar.

The good news is, libdecor is good about tracking fullscreen state, so we can
let the callback do this for us. Keep this for xdg_shell because we actually
map the window ourselves, so we know this call is valid for that path.
2022-01-20 14:10:58 -05:00
Ethan Lee ed3442d7a5 wayland: Fix building with SDL_OPENGL=OFF 2022-01-19 15:47:52 -05:00
Ryan C. Gordon 426c1f4b85
opengles2: fix comment about client-side arrays. 2022-01-19 14:28:30 -05:00
Frank Praznik b3984df1c6 audio: pipewire: Use client config files instead of module names
Pipewire, as of 0.3.22, uses client config files to load modules instead of explicitly specifying them (PW_KEY_CONTEXT_PROFILE_MODULES is deprecated).  Use the new method to load the realtime module to boost the audio thread priority.
2022-01-19 14:20:19 -05:00
Sam Lantinga a0e3c884d4 Updated to version 2.0.21 for development 2022-01-17 15:32:27 -08:00
Cameron Gutman d3952a8a2c wayland: Avoid spurious resize events 2022-01-17 11:30:03 -06:00
Sam Lantinga b06866ef97 Entirely remove Xbox axis filtering, we don't want this at all. 2022-01-16 09:44:28 -08:00
Sam Lantinga 09aed1020b Don't send output reports to the Victrix Pro FS v2
It'll hang on reboot if it gets output reports, and it doesn't have functionality that requires them, so skip it.
2022-01-16 09:23:58 -08:00
Sam Lantinga 85961b61a1 Disable Xbox axis deadzone handling by default
Fixes https://github.com/libsdl-org/SDL/issues/5227
2022-01-16 09:01:56 -08:00
Mathieu Eyraud 2a0cde8fd5 Always send SDL_WINDOWEVENT_SIZE_CHANGED when window is resized
SDL_WINDOWEVENT_SIZE_CHANGED is now sent even if the resulting size of the window does not match the requested size.
2022-01-16 08:49:48 -08:00
Sam Lantinga 1a50334c46 Fixed Xbox One trigger axis zero point 2022-01-14 15:04:26 -08:00
Ozkan Sezer e9511f7136 hidapi, libusb: don't use iconv on OS/2, it lacks wchar_t functionality.
Taken from a patch by Silvan Scherrer at bitwiseworks' OS/2 fork.
2022-01-14 14:39:04 +03:00
Ethan Lee 9a2bbd8acb wayland: Convert URI to local path for DropFile 2022-01-12 13:01:05 -05:00
Ozkan Sezer 0abc0a6f32 SDL_string.c: tidy-up gcc2 va_copy defines after previous haiku commit. 2022-01-12 20:37:32 +03:00
kenmays d37c9777b9 haiku: updated for Haiku 2022-01-12 09:32:56 -08:00
kenmays bff867013e haiku: updated for Haiku 2022-01-12 09:32:56 -08:00
kenmays 094e94402d haiku: Remove BDirectWindow, fix OpenGL handling.
From e6cc4e7f4b8189be55dd3b0e13e54e59f73d7672 Mon Sep 17 00:00:00 2001
From: X512 <danger_mail@list.ru>
Date: Thu, 30 Jan 2020 04:01:58 +0900
Subject: libsdl2: Remove BDirectWindow, fix OpenGL handling.

* BDirectWindow changed to BWindow.
* Implemented fullscreen.
* Introduced view for non-OpenGL drawing.
* Drawing thread removed, window thread is used instead.
* Use BGLView as OpenGL context. Implement proper context switching and OpenGL
  locking. Only one context per window is supported. BGLView should be not
  deleted when window is closed, it deleted when deleting context.
2022-01-12 09:32:56 -08:00
Ozkan Sezer 5b6e2d69a5 SDL_os2messagebox.c (_makeDlg): remove unnecessary casts 2022-01-12 11:01:02 +03:00
Ryan C. Gordon 42302d0a59
x11: Let apps specify a custom _NET_WM_WINDOW_TYPE.
Fixes #5185.
2022-01-11 21:17:21 -05:00
Ryan C. Gordon f9b918ff40 opengles2: Use client-side arrays on everything but Emscripten.
Turns out they're much faster!

Fixes #5206.
2022-01-11 19:41:41 -05:00
Ozkan Sezer ea0bca573d SDL_cocoamodes.m: fix build against older SDKs.
Fixes https://github.com/libsdl-org/SDL/issues/5208
2022-01-11 14:56:56 +03:00
Ozkan Sezer 7527c8d3d7 hidapi, libusb: provide a wcsdup implementation if it is not available.
similar to mac and android versions..
2022-01-11 11:33:02 +03:00
Ozkan Sezer c6c4d4211b pthread: disable SetThreadPriority for OS/2 too 2022-01-11 11:33:02 +03:00
Sam Lantinga d8129c5698 Mark internal function as static 2022-01-10 10:50:59 -08:00
Ethan Lee 3e1b3bc344
wayland: Horizontal wheel values do not need to be inverted 2022-01-10 10:07:44 -05:00
Sam Lantinga a29d3acc9e Updated Bresenham line drawing to match software renderer output 2022-01-09 11:12:13 -08:00
Ozkan Sezer b9d98331c5 os2joystick: fix uninitialized use of local var 'maxdevs' 2022-01-09 20:33:32 +03:00
Ozkan Sezer 17da60068d os2joystick: fix -Wsequence-point issues. 2022-01-09 20:33:32 +03:00
Ozkan Sezer f14c7bb443 added missing hidapi stuff for os/2 with libusb 2022-01-09 20:33:32 +03:00
Sam Lantinga 1f32dd8edc Fixed overdraw with duplicate points, fixed not drawing single point lines 2022-01-09 06:36:18 -08:00
Ryan C. Gordon 5d07c03613
psp: Force channels to stereo if user requested anything other than mono.
Before it would only clamp to stereo if it also had to resample, which would
fail if the app specified 44100Hz and surround sound.
2022-01-09 08:13:34 -05:00
Ryan C. Gordon c275436f56
opengles2: Batching lines/points used wrong var for summing vertex counts.
Fixed this in the vitagxm backend too, but I don't know what the state of
that code is otherwise.

Reference Issue #5061.
2022-01-09 00:39:02 -05:00
Joan Bruguera 9e6249fa54 wayland: Avoid spurious key repeats when not pumping events
Previous to this commit, key repeats events were typically generated when
pumping events, based on the time of when the events are pumped. However,
if an application doesn't call `SDL_PumpEvents` for some seconds, this time
can be multiple seconds in the future compared to the actual key up event time,
and generates key repeats even if a key was pressed only for an instant.

In practice, this can happen when the user presses a key which causes the
application to do something without pumping events (e.g. load a level).
In Crispy Doom & PrBoom+, when the user presses the key bound to "Restart
level/demo", the game doesn't pump events during the "screen melt" effect,
and the level is restarted multiple times due to spurious repeats.

To fix this, if the key up event is among the events to be pumped, we generate
the key repeats there, since in the Wayland callback we receive the time when
the key up event happened. Otherwise, we know no key up event happened and we
can generate as many repeats as necessary after pumping.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Joan Bruguera 461724d287 wayland: Refactor time fields in SDL_WaylandKeyboardRepeat
Refactorization with no functional changes.

Instead of `next_repeat_ms` containing a timestamp based on SDL ticks, we make
it zero-based relative to the key press time, and we store the key press time in
SDL ticks in a new field.

This refactorization is groundwork for future commits which need to use the
key press and release timestamps provided by the Wayland API, which are also
expressed in milliseconds, but whose base does not match the one for SDL ticks.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Joan Bruguera fb0c3040c0 wayland: Avoid infinite loop in keyboard_repeat_handle
If `repeat_info->next_repeat_ms` overflows, many key presses will be generated.
In the worst case, `now = 0xFFFFFFFFU` and the loop will never terminate.

Rearrange the comparison in order to gracefully handle the overflow case.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2022-01-08 14:10:22 -08:00
Sam Lantinga 3b083b9911 Fixed compile warning 2022-01-08 14:07:42 -08:00
Sam Lantinga b82af9dfbf Improved OpenGL point drawing performance (thanks @slime73!)
We'll do proper call batching for the SDL 2.0.22 release
2022-01-08 14:05:50 -08:00
Sam Lantinga 1a73c45a08 Fixed incorrect color in the OpenGL driver 2022-01-08 13:35:17 -08:00
Sylvain 3cdda8f8ab
PSP: use 'data' variable which is alread the driver data 2022-01-08 21:58:26 +01:00
Sam Lantinga 4ef2529bf9 More efficient calculation of render_count 2022-01-08 12:37:57 -08:00
Sam Lantinga 5346c93b62 Fixed assertion on number of points rendered 2022-01-08 12:28:43 -08:00
Sam Lantinga 4b71962031 Prevent overdraw with connected line segments 2022-01-08 12:02:30 -08:00
Sam Lantinga 09ece861d1 Added the hint SDL_HINT_RENDER_LINE_METHOD to select the line rendering method 2022-01-08 11:36:52 -08:00
Sam Lantinga c1e6079836 As an optimization, draw horizontal and vertical lines using rectangles 2022-01-08 11:09:11 -08:00
Sam Lantinga 3da7c6305a Assert that we have drawn the expected number of points 2022-01-08 11:07:03 -08:00
Sam Lantinga 9f56faeedc Added line drawing using Bresenham's line algorithm (thanks @rtrussell!) 2022-01-08 10:59:31 -08:00
Sam Lantinga fe3a33a092 Use RenderGeometry for drawing lines at all scales 2022-01-08 10:10:18 -08:00
Sam Lantinga 1694782b2a Remove redundant work when render scale is 1.0 2022-01-08 09:32:23 -08:00
Sam Lantinga 2026a78dc2 Don't flush in RenderDraw*WithRects()
This allows these functions to be reused in the future for other primitives
2022-01-08 09:23:58 -08:00
Sam Lantinga 18e4d9fed1 Re-enable line drawing path in render drivers
This is still used for scaled line drawing in RenderDrawLinesWithRects()
2022-01-08 09:02:25 -08:00
Sam Lantinga dca281e810 Fixed getting different results for SDL_PollEvent(NULL) and SDL_PollEvent(&event) 2022-01-08 08:49:34 -08:00
Ozkan Sezer 4472b83129 PSP_RunCommandQueue: fix argument to PSP_SetBlendState()
src/render/psp/SDL_render_psp.c: In function 'PSP_RunCommandQueue':
src/render/psp/SDL_render_psp.c:1200: warning: passing argument 1 of 'PSP_SetBlendState' from incompatible pointer type
2022-01-08 11:56:56 +03:00
Ozkan Sezer df1474b46e psp/SDL_sysfilesystem.c: fixed a minor compiler warning.
src/filesystem/psp/SDL_sysfilesystem.c: In function 'SDL_GetPrefPath':
src/filesystem/psp/SDL_sysfilesystem.c:71: warning: passing argument 1 of 'free' discards qualifiers from pointer target type
2022-01-08 11:55:10 +03:00
Sam Lantinga 9294634840 Updated to version 2.0.20 for release 2022-01-07 18:29:40 -08:00
Ryan C. Gordon cc2013378d
render: Fixed some compiler warnings.
Fixes #5197.
2022-01-07 20:22:51 -05:00
Sam Lantinga 289c3fbb64 Revert "We only need to add the sentinel at the top of SDL_WaitEventTimeout()"
This reverts commit c477768e6f.

We want to add the sentinel anytime we pump inside SDL_WaitEventTimeout() to avoid pumping again the next time through, as a performance optimization.
2022-01-07 17:07:22 -08:00
Sam Lantinga 1085c317a5 Use the requested cursor size instead of the default cursor size
CopyImage() will scale based on the system accessibility settings automatically.

Fixes https://github.com/libsdl-org/SDL/issues/5198
2022-01-07 16:45:18 -08:00
Ryan C. Gordon 6d3b5d66cd
psp: draw lines with RenderGeometry, same as with the other renderers. 2022-01-07 18:18:53 -05:00
Sylvain 9cb2c549fa Remove QueueDrawLines from D3D, D3D11 2022-01-07 14:10:23 -08:00
Sylvain b88b6b3c23 Remove QueueDrawLines from METAL 2022-01-07 14:10:23 -08:00
Sylvain 9aac55317d Remove QueueDrawLines from GL, GLES, GLES2 2022-01-07 14:10:23 -08:00
Sylvain 8ea8b2e697 Use QueueDrawLine if provided, otherwise use RenderGeometry 2022-01-07 14:10:23 -08:00
Sylvain Becker c498727471
render: Use RenderGeometry to draw lines
This patch is from @1bsyl

Fixes #5061.
2022-01-07 16:14:28 -05:00
Sam Lantinga 4b38d4c96b Leave the Metal view active on the window when recreating the Metal renderer
Fixes https://github.com/libsdl-org/SDL/issues/5140

Also move the metal tag definition to SDL_syswm.h so it can be used by applications
2022-01-07 12:38:45 -08:00
Ryan C. Gordon 88ac517df0
opengles2: Fix point drawing. 2022-01-07 15:04:04 -05:00
Sam Lantinga 957c48b4c7 Fixed detecting focus change to child dialogs
Fixes https://github.com/libsdl-org/SDL/issues/5157
2022-01-07 10:58:04 -08:00
Sam Lantinga c477768e6f We only need to add the sentinel at the top of SDL_WaitEventTimeout() 2022-01-06 18:58:30 -08:00
Cameron Gutman e9134b045a events: Only add sentinels for pumping done inside SDL_WaitEventTimeout()
We don't want to catch explicit SDL_PumpEvents() calls by the application with
our polling check to avoid stale data. If the call to SDL_PumpEvents() produced
no events, there will be a sentinel sitting in the queue that will cause
SDL_PollEvent() to immediately return 0 next time it is called.

Our SDL_WaitEventTimeout() implementation avoids this issue by always popping
an event after calling SDL_PumpEvents(). This will remove the new sentinel if
we didn't get any new events.
2022-01-06 18:35:23 -08:00
Sam Lantinga 954858846d Move special sentinel handling inside SDL_PeepEvents() 2022-01-06 14:05:22 -08:00
Sam Lantinga 2592e6219b Clarify that timeout == 0 is handled at the top of SDL_WaitEventTimeout() 2022-01-06 14:05:22 -08:00
Sam Lantinga 8ff2166855 Only return from SDL_PollEvent() if the last sentinel is consumed 2022-01-06 14:05:22 -08:00
Sam Lantinga c9ff90b949 Clarify comment
Co-authored-by: Simon McVittie <smcv@debian.org>
2022-01-06 14:05:22 -08:00
Sam Lantinga 31f8c3ef44 Fixed event pump starvation if the application frequently pushes its own events 2022-01-06 14:05:22 -08:00
Wouter Wijsman 515b5f2a39 Fix build errors in PSP port 2022-01-06 10:17:05 -08:00
Wouter Wijsman 34e34ad5a5 Remove debug code from PSP renderer 2022-01-06 10:17:05 -08:00
stdgregwar 520c89a00a cleaning 2022-01-06 10:17:05 -08:00
stdgregwar 09f4711f40 Fix LRU when destroying texture. 2022-01-06 10:17:05 -08:00
stdgregwar c3ec62d6a6 PSP lazier blend states, display mode report with 16bit option 2022-01-06 10:17:05 -08:00
stdgregwar 0f5368fe11 PSP cached blending and texturing state, ABGR1555 stencil hack 2022-01-06 10:17:05 -08:00
stdgregwar fe405eb27b fixed LRU cache code 2022-01-06 10:17:05 -08:00
stdgregwar c1f152292b Spill render targets to ram on PSP 2022-01-06 10:17:05 -08:00
stdgregwar 77d874e3c0 Attempt to make render to texture work on PSP 2022-01-06 10:17:05 -08:00
Francisco Javier Trujillo Mata f3255df9c0 Improve audio compatibility in PSP. Now it supports more formats and frequencies 2022-01-05 19:15:41 -05:00
Sam Lantinga 16f5b9e3c3 Filter jitter on Xbox One controllers when using raw input reports 2022-01-05 11:07:52 -08:00
Wouter Wijsman 6d46e30fed Remove extra / in PSP GetPrefPath 2022-01-05 08:29:35 -08:00
Wouter Wijsman 33dccbb381 Make sure GetPrefPath also works without org 2022-01-05 08:29:35 -08:00
Cameron Gutman 419ae29d90 joystick: Move WGI driver initialization after Windows driver
WGI calls SDL_DINPUT_JoystickPresent() so we need to be sure DInput remains
initialized for the lifetime of the WGI driver to avoid a crash or duplicated
joysticks between DInput and WGI.
2022-01-04 15:53:39 -08:00
Cameron Gutman d73bd0d2f6 dinput: Don't crash in SDL_DINPUT_JoystickPresent if DInput init failed
The WGI driver will call this regardless of whether our init succeeded.
2022-01-04 15:53:39 -08:00
Ozkan Sezer 565ef63873 SDL_rwops.c: simplify `foo <= 0` checks to `!foo` with unsigned types. 2022-01-04 11:40:04 +03:00
Cameron Gutman 8f924b82d9 kmsdrm: Remove gbm_bo_get_offset()
It is not present on some older libgbm versions that we still
support and has been unused since 85e8adf.
2022-01-03 16:41:03 -06:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain 8622eda9e9
SDL_RenderGeometry / software: TRIANGLE_GET_TEXTCOORD interpolates up to the max values included, so reduce by 1 2022-01-02 22:34:56 +01:00
Ozkan Sezer 4b112620a3 SDL_cocoamodes.m (Cocoa_GetDisplayDPI): fix build using older toolchains
Fixes https://github.com/libsdl-org/SDL/issues/5162
2022-01-02 19:11:50 +03:00
Francisco Javier Trujillo Mata 13a9cd4797 Adding sysfilesystem driver to PSP 2022-01-02 08:06:04 -08:00
rohlem 0403fa8aa6 X11_WaitEventTimeout: remove unreachable return
If that condition was reachable, the return value should be negative to indicate that waiting for the timeout failed.
Otherwise, SDL_WaitEventTimeout would incorrectly return early.
2022-01-02 08:04:13 -08:00
e d0de4c625a Android: fixes build NDK 21d 2021-12-31 11:12:21 -08:00
Sam Lantinga 8f81699868 Only clear IME display options if SDL_HINT_IME_SHOW_UI is off (thanks opxdo!)
Fixes https://github.com/libsdl-org/SDL/issues/5153
2021-12-31 08:49:28 -08:00
Ryan C. Gordon e4000c0284
video: SDL_GL_GetAttribute needs to operate on FBO 0.
If a different FBO is bound, this would return incorrect results.

Fixes #5082.
2021-12-31 10:32:39 -05:00
Sam Lantinga ab6d0d4d50 Fixed undefined behavior in SDL_memset() (thanks andrewrk!)
Fixes https://github.com/libsdl-org/SDL/issues/5147
2021-12-28 15:58:15 -08:00
shinyquagsire23 6a7b63802c Fix macOS cursor jumping to corner on first titlebar click 2021-12-28 13:38:23 -08:00
Edward Li a35a7d2507 Fix SigSegV from displayInfoInvalidate when changing resolution 2021-12-28 09:33:44 -08:00
Edward Li 1c41b53551 macOS: Calculate correct DPI by not using backingScaleFactor 2021-12-28 09:33:44 -08:00
Alex Szpakowski 724468ae2c GL renderer uses glDrawArrays instead of glBegin/glEnd.
Also change internal colors sent to GL to use unorm8 components instead of float, for improved performance.
2021-12-27 10:52:47 -05:00
Sylvain a1e992b110
Fixed bug #5118 - [Android] PointerIcon leak in Cursor API 2021-12-21 22:07:17 +01:00
Ozkan Sezer 840339c49d SDL_utf8strlcpy: store trailing_bytes explicity as unsigned type. 2021-12-18 14:01:02 +03:00
Ozkan Sezer 507d4bcd68 SDL_utf8strlen: run bit-test explicitly on unsigned char 2021-12-18 14:01:02 +03:00
Ozkan Sezer 82fc67ae4d SDL_joystick.c: cast the arguments to nibble() to unsigned char. 2021-12-18 14:01:02 +03:00
Ozkan Sezer 47d3e96b43 SDL_joystick.c: (unsigned char) cast to SDL_tolower() parameters. 2021-12-18 14:01:02 +03:00
Sam Lantinga c31a40246d Fix audio memory leaks due to invalid init (thanks Janiszewski!)
SDL_Init(SDL_INIT_AUDIO) did not take into account that functions like
SDL_AddAudioDevice do register events, which will need final cleanup
and only gets fired when events were actually initialised.

Sample call stack of a malloc missing its free (Linux + PA):
    SDL_malloc_REAL (SDL_malloc.c:5328)
    SDL_AddEvent (SDL_events.c:445)
    SDL_PeepEvents_REAL (SDL_events.c:531)
    SDL_PushEvent_REAL (SDL_events.c:762)
    SDL_AddAudioDevice (SDL_audio.c:443)
    SourceInfoCallback (SDL_pulseaudio.c:681)
    context_get_source_info_callback (introspect.c:534)
    run_action (pdispatch.c:288)
    pa_pdispatch_run (pdispatch.c:341)
    pstream_packet_callback (context.c:349)
    do_read (pstream.c:1012)

Fixes https://github.com/libsdl-org/SDL/issues/3005
2021-12-17 19:04:39 -08:00
Erik Soma 71e3998d6c Make SDL_VideoInit cleanup when errors occur before video driver creation. 2021-12-17 18:55:49 -08:00
Francisco Javier Trujillo Mata 8ed0cc4300 Fix wrong value for thread priorities following official PSP Docs 2021-12-17 13:57:22 -08:00
Sylvain 44c84c0d8e
GLES2/Big-endian: don´t swap datas for yuv textures (Thanks 0x1F9F1 !) 2021-12-17 17:44:34 +01:00
Sylvain 3a69828e87
Fixed GLES2 back-end on Big Endian Platform (see #5093) 2021-12-17 13:15:39 +01:00
Ozkan Sezer 61107494a1 SDL_gamecontroller.c: (unsigned char) cast to SDL_isdigit() parameters. 2021-12-17 07:40:02 +03:00
Ozkan Sezer ced442cd38 SDL_test_common.c: (unsigned char) cast to SDL_isdigit() parameter. 2021-12-17 07:33:10 +03:00
Ozkan Sezer 48d1ef8fad another unsigned char cast in os2cp.c. code clean-up in os/2 geniconv. 2021-12-17 07:33:10 +03:00
Ozkan Sezer dac6516057 os2iconv.c (_createUconvObj): cast to unsigned char, to be safe. 2021-12-17 02:50:40 +03:00
Ozkan Sezer 2052b5bc3e os2messagebox: use proper UCHAR* typecast in assignment, just in case. 2021-12-17 01:10:10 +03:00
Sam Lantinga ca18bf11ee Don't compare raw mouse button state with windows message button state
When mouse buttons are swapped, right mouse button down is the same value as raw mouse button up, and conceptually the two systems use different button masks, so never cache state between the two.

Fixes https://github.com/libsdl-org/SDL/issues/5108
2021-12-16 12:01:18 -08:00
Sylvain 3d5fcb5da6 Fix warning 2021-12-16 09:19:53 -08:00
Sylvain 4342e6bd21 SDL_render.c: lighten the cast syntax 2021-12-16 09:19:53 -08:00
Sylvain 50d49c63ed GLES2 backend: cast with SDL_Vertex and SDL_VertexSolid 2021-12-16 09:19:53 -08:00
Ethan Lee 4c9966eed6
wayland: Add a note for why we check 0,0 for fullscreen configurations 2021-12-16 10:22:27 -05:00
Sylvain 6101499c7c
BigEndian: fix code that generates illegal instruction with gcc-4.9.2 on powerpc
Program received signal SIGILL, Illegal instruction.
X11_InitKeyboard (_this=0x1001f8f0)
    at /home/sdl/SDL_git/src/video/x11/SDL_x11keyboard.c:273
273	    XKeyboardState values = { .global_auto_repeat = AutoRepeatModeOff };
2021-12-16 09:07:31 +01:00
stdgregwar 0b7b0977fc fix PSP texure artifacts 2021-12-15 18:00:28 -08:00
Francisco Javier Trujillo Mata 996f30b0e4 Use lightweight mutex 2021-12-15 13:59:08 -08:00
Francisco Javier Trujillo Mata 0341ec93fe Improve performance when vsync is enabled and the game is not reaching the 60 FPS 2021-12-15 11:29:49 -08:00
Sam Lantinga 67c4b99639 Fixed enabling udev hotplug detection on Linux 2021-12-15 10:39:42 -08:00
Sam Lantinga c326ff7c6f Re-enabled the O_CLOEXEC definition so config headers can be fixed 2021-12-14 12:42:39 -08:00
Alex Szpakowski 3a5e148b13 Renderer backends use SDL_Color instead of int for geometry colors. 2021-12-14 12:19:16 -08:00
Sam Lantinga 086c74556d Fixed build warning on iOS 2021-12-14 12:08:36 -08:00
Sam Lantinga b08e57e926 Don't try to create a vbo if we aren't using any vertices 2021-12-14 09:32:05 -08:00
Sylvain b7885abc44
Fixed bug #5087: SDL_RenderGeometryRaw() passes colors as int* instead of SDL_Color* 2021-12-14 10:31:55 +01:00
Alex Szpakowski 323ba6c008 d3d11 renderer: reduce vertex bandwidth and calculations. 2021-12-13 15:14:33 -08:00
thfrwn 2b6b69fb12 fix assertion failure in sndio audio caused by the recent hotplugging support 2021-12-13 11:26:35 -08:00
Sylvain 8927d73b1c
RenderGeometry: simplify casting (Thanks Daniel Gibson) 2021-12-12 09:55:23 +01:00
Sylvain d7f66ba1ec
Remove strict aliasing warning in opengles2 backend 2021-12-11 20:04:53 +01:00
Sylvain 3e43d6e34b
SDL_RenderGeometry: remove some warning "dereferencing type-punned pointer might break strict-aliasing" 2021-12-11 17:19:00 +01:00
David Redondo e2ade2bfc4 Fix build against wayland 1.20
Fixes #5088
2021-12-10 08:59:20 -08:00
David Gow 9da93d074b video: x11: Set XImage's byte_order field (fix #5081)
If the X server's byte order is different from the client, things might
display in the wrong colour.

Apparently we can just set the byte_order field to the client's byte
order, and the X server will adjust everything automatically:
https://xorg.freedesktop.narkive.com/GbSD1aPq/ximage-s-byte-order-field
2021-12-09 20:40:12 -08:00
Hanseul Jun e7f84c20bc Fix a typo in comment. 2021-12-09 11:05:23 -08:00
Hanseul Jun 66fbf00e7d Temporarily ignore gl_config.driver_loaded check in Cocoa_GLES_SetupWindow. 2021-12-09 11:05:23 -08:00
Valentin Hăloiu cb8fa5f9c3 wayland: fix keycodes of swapped xkb modifier keys 2021-12-09 09:30:58 -08:00
Ozkan Sezer 615f7b4453 more updates to os2 makefile for libiconv 2021-12-08 23:51:56 +03:00
Ozkan Sezer 8d14e6ea44 replaced use of _MAX_PATH with CCHMAXPATH in os/2 code,
it now compiles without HAVE_LIBC
2021-12-08 14:01:02 +03:00
Sylvain 1940d289bf
SW Renderer: fix invalid read if VSYNC hint is initially set with an empty value (eg "")
because:
- GeHint return a value pointer.
- SetHint free internally the pointer
- The -now invalid- pointer is re-read

==9363== Invalid read of size 1
==9363==    at 0x4946860: SW_CreateRenderer (SDL_render_sw.c:1044)
==9363==    by 0x48F0EC3: SDL_CreateRenderer_REAL (SDL_render.c:938)
==9363==    by 0x48C5921: SDL_CreateRenderer (SDL_dynapi_procs.h:332)
==9363==    by 0x401584: main (main.c:421)
==9363==  Address 0x9c24040 is 0 bytes inside a block of size 1 free'd
==9363==    at 0x484621F: free (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==9363==    by 0x494E403: SDL_free_REAL (SDL_malloc.c:5432)
==9363==    by 0x48A6153: SDL_SetHintWithPriority_REAL (SDL_hints.c:76)
==9363==    by 0x48A6254: SDL_SetHint_REAL (SDL_hints.c:101)
2021-12-08 09:41:33 +01:00
Ozkan Sezer 9409642e08 fix some warnings from vita builds (missing includes)
also some tidy-up to whitespace.
2021-12-07 21:24:24 +03:00
stdgregwar 21d46b7e0c PSP renderer fixed 2021-12-07 20:55:04 +03:00
Sergio Padrino 6f6382f8d0 Fix SDL_GameController API for PSP (#3)
- Add missing mapping
- Make sure the only window has the keyboard focus (so no `SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS` is needed)
2021-12-07 09:04:05 -08:00
Cameron Gutman da0f76de6d cocoa: Don't round scroll deltas from trackpads
Rounding the scroll deltas from trackpads causes jerky scrolling behavior
by artificially amplifying the effects of very small scroll movements.

We should only round events from devices with discrete scroll wheels,
because we know the smallest unit of movement there is a single tick.
2021-12-07 09:02:35 -08:00
Ozkan Sezer 8cee50eea5 removed stdlib.h from SDL_psp_main.c now that exit() is gone. 2021-12-07 19:32:56 +03:00
Ozkan Sezer 00014dc2ac fix some warnings from psp builds (missing includes.) 2021-12-07 18:47:10 +03:00
Wouter Wijsman da5dbb4763
Fix SDL2main on PSP (#5076)
- Fix SDL2main on PSP
  SDL2main was not working for PSP, because it wasn't being activated and
  it wasn't unsetting the main. Besides that a debug screen being started
  was causing issues with joystick input and the sceKernelExitGame calli
  is no longer needed with the current PSPDEV SDK.
- Clean up imports in PSP main
- Set PSP GPU and user modes in main
- Fix exit callback in PSP main
2021-12-07 18:43:50 +03:00
Cameron Gutman 2d673e5b56 evdev: Add support for REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES
If supported, these come alongside the regular REL_WHEEL and REL_HWHEEL
events so it's important that we only process one or the other.
2021-12-07 07:00:31 -08:00
Ozkan Sezer f266d92286 psp/SDL_sysjoystick.c: fix -Wshadow warnings. 2021-12-07 14:04:32 +03:00
Ozkan Sezer 801dcbc5ef SDL_render_sw.c: fix -Wshadow warnings. 2021-12-07 14:04:10 +03:00
Wouter Wijsman e17a3154ed Fix build issue 2021-12-07 14:03:00 +03:00
Wouter Wijsman 7266cf66c7 Clean up PSP render code to fit C standard used better 2021-12-07 14:03:00 +03:00
Wouter Wijsman 07608bf45f Fix ISO C90 violations in psp render code 2021-12-07 14:03:00 +03:00
Wouter Wijsman a79b642638 Make SDL2 able to build or PSP with cmake 2021-12-07 14:03:00 +03:00
Wouter Wijsman 21fd0047e3 Initial for building PSP version with CMake 2021-12-07 14:03:00 +03:00
Sylvain d09f80ef18
SDL_DrawPointsF: fix error message typo 2021-12-07 11:31:57 +01:00
Sylvain 6dafc85017
SDL_DrawLines: minor simpification:
- scale is  1.0f, don't need to multiply
- typo in error message
- remap SDL_DrawLines to SDL_DrawLinesF
2021-12-07 10:44:12 +01:00
Sylvain a0818a63e3
Fixed bug #5071 - Float conversion warnings in SDL_render.c (see also #5003) 2021-12-07 10:07:15 +01:00
Cameron Gutman 9ae56cb353 events: Add logging for SDL_MOUSEWHEEL preciseX/Y fields 2021-12-06 21:18:23 -06:00
Ozkan Sezer 03019c912a autotools, cmake: tighten Xfixes check && explicitly test BarrierEventID
Apparently the older versions of libXi doesn't have it.  Fixes the build
break issue reported at:
4b42c05ba1 (commitcomment-61427659)
2021-12-06 20:37:52 +03:00
David Gow a709b5b602 video: wayland: Handle 0x0 xdg_toplevel_configure in fullscreen
The xdg_shell spec seems to state[1] that xdg_toplevel_configure events can
always provide a 0×0 width/height to signal that the compositor doesn't
care. SDL previously assumed the provided width/height was always valid
for fullscreen windows, and so applied it as-is.

This broke SDL applications on KDE/KWin 5.23, which now sends 0×0
configure events (and, in 5.23.3, 1×1 events for some reason), breaking
all SDL applications in fullscreen[2].

[1]: https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/6
[2]: https://bugs.kde.org/show_bug.cgi?id=444962#c6
2021-12-06 09:09:37 -08:00
ALittleDruid 2f0edc2906 IAudioClient::SetEventHandle Parameter eventHandle Should not be NULL 2021-12-06 09:02:31 -08:00
Ozkan Sezer a887b8e28b SDL_test_common.c: replaced all printf() calls with SDL_Log()
Otherwise, if one builds libSDL2_test using a new mingw but builds
the test programs using an older mingw, a link failure happens:

/opt/local/x86_64-w64-mingw32/lib/libSDL2_test.a(SDL_test_common.o): In function `printf':
/opt/local/x86_64-w64-mingw32/include/stdio.h:372: undefined reference to `__imp___acrt_iob_func'
collect2: ld returned 1 exit status
2021-12-03 20:03:10 +03:00
Weng Xuetian 5056b29b0f Fix the wrong int size for fcitx capability. 2021-12-03 04:31:24 -08:00
Sylvain e14d10263c Change viewport and cliprect to float version: from SDL_Rect to SDL_FRect 2021-12-02 10:01:50 +01:00
Sylvain 7828362da9 SDL_Renderer software, D3D11: don't use "renderer->viewport" in back-ends, but use the one from SETVIEWPORT cmd 2021-12-02 10:01:50 +01:00
Ozkan Sezer a2b13e585c SDL_iconv_string: avoid memory leak if realloc() fails. 2021-12-02 02:28:24 +03:00
Ozkan Sezer f14a8bfa4e fix whitespace. 2021-12-01 21:33:02 +03:00
Ozkan Sezer b71bfdaafb SDL_iconv.c (encodings): mark "WCHAR_T" as ENCODING_UTF16LE for OS/2 too
whcar_t is unsigned short in os/2, like windows
2021-12-01 20:50:40 +03:00
Davis Mosenkovs 66b0a6ee15 workaround for libmali gbm_device_get_fd()
gbm_device_get_fd() in at least some libmali versions duplicates handle.
Other implementations do not do duplication. To prevent handle leak save
drm_fd in SDL_DisplayData.
2021-11-30 16:20:24 -08:00
Ozkan Sezer 662ea5abe4 minor correction after previous patch and minor tidy-up. 2021-12-01 01:40:24 +03:00
Ozkan Sezer 70c5e91d0f os/2 optionally builds against libiconv. 2021-12-01 01:20:10 +03:00
Ozkan Sezer b20484e803 minor os/2 reorganization for iconv 2021-12-01 01:20:02 +03:00
Sam Lantinga 8c91cf7dba Always create a full 256-entry map in case color values are out of range
Fixes https://github.com/libsdl-org/SDL/issues/5042
2021-11-30 12:37:39 -08:00
Sam Lantinga a4c04ad230 Fixed building with iOS SDK prior to 13.0
Fixes https://github.com/libsdl-org/SDL/pull/5045
2021-11-30 10:32:39 -08:00
Sam Lantinga 8589134f16 Fixed potential buffer overflow in YUV conversion
Fixes https://github.com/libsdl-org/SDL/issues/5043
2021-11-30 10:23:21 -08:00
Ozkan Sezer 09465a9083 hidapi, windows: replace a strncpy() with plain memcpy()
mainstream has a similar change, already.
2021-11-30 21:10:10 +03:00
Sam Lantinga 5fc901d4f3 Updated to version 2.0.19 for development 2021-11-30 09:58:21 -08:00
Cameron Gutman 715d481271 windows: Fix GUI key state when grabbing the keyboard
When our keyboard grab hook is installed, GetKeyState() will return 0 for the
GUI keys even when they are pressed. This leads to spurious key up events when
holding down the GUI keys and the inability to use any key combos involving
those modifier keys.
2021-11-29 20:07:19 -08:00
Sam Lantinga b6bc3a6b0e Added a mapping for the PS4 touchpad button on Windows
Fixes https://github.com/libsdl-org/SDL/issues/5035
2021-11-29 09:00:54 -08:00
David Gow f6fdbc1e37 video: x11: Fix an invalid SDL_LogError() call
This fixes a compile warning — and possible invalid memory read —
introduced in 9c03d255 ("Add back X11 legacy WM_NAME encodings"), which
was part of PR #5029, fixing Bug #4924.

The issue is with one of the added warnings in X11_GetWindowTitle().
Basically, the "title" variable passed to SDL_LogError() hasn't been
initialised yet: we could pass propdata in directly, but it's better to
move the SDL_LogError() call until after title is set, IMHO.

This fixes the following warning from gcc (SUSE Linux) 11.2.1:
In file included from /home/david/Development/SDL/src/video/x11/../../SDL_internal.h:45,
                 from /home/david/Development/SDL/src/video/x11/SDL_x11window.c:21:
/home/david/Development/SDL/src/video/x11/SDL_x11window.c: In function 'X11_GetWindowTitle':
/home/david/Development/SDL/src/video/x11/../../dynapi/SDL_dynapi_overrides.h:33:22: warning: '%s' directive argument is null [-Wformat-overflow=]
   33 | #define SDL_LogDebug SDL_LogDebug_REAL
/home/david/Development/SDL/src/video/x11/SDL_x11window.c:720:13: note: in expansion of macro 'SDL_LogDebug'
  720 |             SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title);
      |             ^~~~~~~~~~~~
2021-11-29 07:13:25 -08:00
Sam Lantinga 3ba9276aff Don't fail the sensor init if we couldn't create a sensor manager (i.e. we're running on Wine)
Fixes https://github.com/libsdl-org/SDL/issues/5031
2021-11-28 21:14:02 -08:00
Sam Lantinga 6872cb12e6 null-terminate the message buffer if FormatMessage() fails 2021-11-28 21:10:46 -08:00
Fredrick Brennan b5d47aa297 Fix comment style for old compilers (`//`⇒`/**/`) 2021-11-28 21:00:29 -08:00
Fredrick Brennan 367684b0c2 Add patches suggested by @slouken in round 1 review 2021-11-28 21:00:29 -08:00
Fredrick Brennan 9c03d25543 Add back X11 legacy WM_NAME encodings
Closes #4924.

Based on patches of the past, such as this work by James Cloos in July
2010:
d7d98751b7,
as well as code comments in the Perl module X11::Protocol::WM
(https://metacpan.org/pod/X11::Protocol::WM) and even the code to Xlib
itself, which taught me that we should never have been using
`XStoreName`, all it does is call `XChangeProperty`, hardcoded to
`XA_STRING`!

What can I say, when the task is old school, the sources are too 😂
2021-11-28 21:00:29 -08:00
Ethan Lee 72e53e4b87 wayland: Clear driverdata before calling ResetDisplayModes 2021-11-28 19:25:22 -05:00
Sam Lantinga 942973dd86 Use mouse ID 0 for raw mouse events
We don't track state for each mouse individually, so we should just use the global mouse ID for all events.

Fixes https://github.com/libsdl-org/SDL/issues/5026
2021-11-28 09:27:28 -08:00
Sam Lantinga dd2f91118e Fixed warnings with Windows SDK 10.0.19041
Fixes https://github.com/libsdl-org/SDL/issues/4998
Also breaks https://github.com/libsdl-org/SDL/issues/4998 for older SDKs, but we're going to ignore them, they're just incorrect.
2021-11-27 20:18:29 -08:00
Sam Lantinga c2904c8ce7 Fixed compile warnings and errors
Fixes https://github.com/libsdl-org/SDL/issues/4998
2021-11-27 11:16:15 -08:00
Ozkan Sezer 8f17af5e21 hidapi: mark libusb function pointers with LIBUSB_CALL. 2021-11-27 11:02:04 -08:00
Sam Lantinga a6cbe0ab87 Controllers are always centered at zero using XInput and WGI 2021-11-27 10:58:12 -08:00
Sam Lantinga 09b7ca27d6 Get the current WGI controller list at startup
On Win32 this list is empty and we always get controller added events. On UWP, this list is populated and we don't get controlle added events for currently connected controllers.
2021-11-27 10:53:20 -08:00
Sam Lantinga 12895eca1a Fixed WGI initialization on Win32 2021-11-27 10:52:58 -08:00
Sam Lantinga 110e4e1334 Use WGI instead of XInput for Windows 10 UWP apps
Fixes https://github.com/libsdl-org/SDL/issues/5017
2021-11-27 10:24:32 -08:00
Sam Lantinga e04a0221e3 Fixed crash running SDL test programs on UWP 2021-11-27 10:22:37 -08:00
Ozkan Sezer 5a0ea7fb17 Check for O_CLOEXEC definition in fcntl.h at configuration time,
If not available, define it internally as 0 (in SDL_internal.h).
Define it as available for macOS >= 10.7 in SDL_config_macosx.h.
2021-11-27 19:23:10 +03:00
Cameron Gutman f903a39e13
haptic: Fix SDL_MouseIsHaptic() always returning SDL_TRUE on Android 2021-11-27 19:18:41 +03:00
Sam Lantinga 11a9cd6344 Fixed building SDL on UWP 2021-11-27 08:14:50 -08:00
Mathieu Eyraud 02021ae753 Return capabitlities from RawInput joystick 2021-11-27 07:26:10 -05:00
Eric Wasylishen b786c10013 SDL_render_gl.c: GL_RunCommandQueue: always set viewport_dirty on macOS
Without this, moving the window changes the viewport and causes contents
to render stretched.

Fixes #1504
2021-11-27 07:12:34 -05:00
Sam Lantinga 4f683f01d4 Fixed potentially truncated entry in stack trace 2021-11-26 17:27:07 -08:00
Sam Lantinga 4e5839a5f4 Fixed compiling for Raspberry Pi 2021-11-26 13:45:08 -08:00
Ryan C. Gordon 86c0cf2bb1
software: Draw a single pixel for a line with the same start/end point.
Otherwise it would drop it, which seems like a bug to me, as it normally
fills the endpoint on lines.

Reference #2006.
2021-11-26 14:34:51 -05:00
Sam Lantinga a2e8565230 The Google Pixel fingerprint sensor isn't actually a joystick
Fixes https://github.com/libsdl-org/SDL/issues/4971
2021-11-26 11:04:15 -08:00
Sam Lantinga 67b5de5b41 Fixed build warnings 2021-11-26 10:18:08 -08:00
Sam Lantinga 2ca2ad76da Fixed build warnings 2021-11-26 10:13:45 -08:00
Sam Lantinga f90164a62f Fixed mapping for the G-Shark GS-GP702
Fixes https://github.com/libsdl-org/SDL/issues/5006
2021-11-26 09:02:12 -08:00
Sam Lantinga 7242075b2b Updated version to 2.0.18 for release 2021-11-26 08:12:45 -08:00
Sam Lantinga d861820465 SDL_JoystickGetAttached() doesn't need to be noisy for NULL joystick
Fixes https://github.com/libsdl-org/SDL/issues/5008
2021-11-26 07:57:48 -08:00
Sam Lantinga 30f04d63e6 HIDAPI is only reliable on Android 4.3 and newer
Fixes https://github.com/libsdl-org/SDL/issues/4955
2021-11-26 07:15:46 -08:00
Ryan C. Gordon d713a68071
pulseaudio: wait until at least 1/8th (!) of the mixbuffer is available.
This is to workaround systems where we hang in playback because the buffer
does not report the space for whatever reason. The system will instead block
in PlayDevice, which always immediately follows WaitDevice in modern times
so this works out, and it seems to keep the device moving forward.

For a future revision, we are either going to clean this up more properly,
or attempt to move to PulseAudio's pa_stream_set_write_callback() API, but
this will do for SDL 2.0.18.

Reference #4387 for discussion and further information.
2021-11-25 22:32:40 -05:00
Ozkan Sezer 53aa8eec5f minor cleanup for watcom _inline keyword. 2021-11-25 17:00:24 +03:00
Sylvain d5813776db Release UDEV ressources 2021-11-25 07:24:18 -05:00
Cameron Gutman b99510836e SDL_mfijoystick.m: Fix -Wshadow warning 2021-11-24 13:04:50 -06:00
DarkContact e77cfb9a11 Fixed d3d11 renderer creation 2021-11-24 10:11:35 -05:00
Sam Lantinga 57366285d8 Only send display events for hotplugged displays, not the initial state 2021-11-23 20:14:18 +00:00
Sam Lantinga a3c05d2f34 Added debug output for display connect/disconnect events 2021-11-23 19:43:01 +00:00
Ozkan Sezer f8900583e5 removed windows winmm joystick driver 2021-11-23 17:04:40 +03:00
Sylvain 381f99a3fd
Fix warnings: re-add enum forward declaration 2021-11-23 10:58:04 +01:00
Sylvain dd6817b3b7
Fix warnings: static function, {} initializier, un-needed enum forward declaration 2021-11-23 10:47:34 +01:00
Sylvain fae7034901
Fix warnings: static, include, un-initialized vairables 2021-11-23 10:33:12 +01:00
Sylvain 2a24418bd3
More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995) 2021-11-23 09:44:37 +01:00
Sylvain 9c72adc86c
More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995) 2021-11-23 09:41:01 +01:00
Sylvain 8dd6edec00
Fixed bug #3232 - Integer overflow generates Illegal instruction under sanitizers + see bug #4995 2021-11-23 09:30:42 +01:00
Ozkan Sezer e18be04bc6 Fixed undefined behavior in QueueCmdSetDrawColor()
Fixes https://github.com/libsdl-org/SDL/issues/4995
Patch from Andrew Kelley
2021-11-23 08:01:02 +03:00
Sylvain c878d9a0aa Haiku: comment this should not be SDL_free() 2021-11-22 08:38:46 -08:00
Sylvain aef7105408 Use SDL_free 2021-11-22 08:38:46 -08:00
Sylvain 2004aaf3bb SDL_wave: use SDL_free 2021-11-22 08:38:46 -08:00
Sylvain 0445c13aae Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 155db97d14 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain c3633d2c99 Haiku: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 79b37cc55f Pandora: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 10ffcbb115 QNX: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain e72beeb2a0 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 38cfe25bc5 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00
Sylvain 4d566e5d5d VITA, PSP: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 9fcc630fb3 X11: use SDL_malloc 2021-11-22 08:38:46 -08:00
Sylvain 19bf36db15 DirectFB: use SDL_malloc 2021-11-22 08:38:46 -08:00