Commit Graph

3966 Commits

Author SHA1 Message Date
Stephan Vedder
fa367cdd5c emscripten: Fix alt key being a nav key 2021-02-13 11:56:01 -05:00
Alon Zakai
20be1d634b emscripten: Automatically resume audio contexts
This uses the mechanism added in emscripten-core/emscripten#10843
which was applied to SDL1 and OpenAL. This adds the same for SDL2.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

I think SDL_STRINGIFY_ARG should be removed.

#define SDL_COMPOSE_ERROR(str) __FUNCTION__ ", " str

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

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

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

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

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

Consider adding support for Stadia Controller haptics.

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

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

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

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

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

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