Commit Graph

5767 Commits

Author SHA1 Message Date
Sam Lantinga
b0e827fb65 Enable improved rumble emulation on DualSense(tm) Wireless Controllers with firmware version 2.24 and newer 2022-06-17 07:55:53 -07:00
Sam Lantinga
1eb247fa2e Fixed building D3D12 renderer with latest mingw-64 2022-06-16 15:44:18 -07:00
Sam Lantinga
b004133f08 Updated to version 2.23.1 for pre-release checkpoint 2022-06-16 12:50:19 -07:00
Sam Lantinga
a5949d7b03 Fixed crash on Windows
These functions really are WINAPI
2022-06-15 23:00:28 -07:00
Sam Lantinga
16f55fbdb4 Separate the controller protocol from the controller style
This allows us to handle controllers that use the Xbox protocol but look like Nintendo Switch or Playstation controllers, like the Qanba Dragon Arcade Stick in PC mode
2022-06-15 20:46:01 -07:00
Sam Lantinga
017e237005 Removed the Qanba Obsidian Arcade Joystick from the unknown controller list 2022-06-15 17:32:46 -07:00
Sam Lantinga
a9cf313eef Added the Qanba Obsidian and Dragon Arcade Sticks to the arcade stick list 2022-06-15 17:28:29 -07:00
Sam Lantinga
bfe81a0c05 Added the name of the Qanba Obsidian Arcade Joystick in PC mode 2022-06-15 17:28:20 -07:00
Sam Lantinga
a6a2cdbd7c Added the name of the Qanba Dragon Arcade Joystick in PC mode 2022-06-15 17:28:18 -07:00
Francisco Javier Trujillo Mata
6b03c1adf6 Add filesystem driver 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
52f00833b0 Add Thread drivers 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
217d3a6dab Add systimer support 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
7343ece806 Define available PS2 RAM 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
e4409f6733 Include SDL_Log driver 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
f0a05ed476 Add some PS2 flags 2022-06-15 15:15:26 -07:00
Francisco Javier Trujillo Mata
273d9e4640 Fix atomic support for PS2 2022-06-15 15:15:26 -07:00
Anonymous Maarten
ae7446a959 stlib: Extract SDL_memcpy and SDL_memset to its own file respectively
This is done such that we can disable LTO for these 2 functions when
building with MSVC.

This is due to a limitation of Link Time Code Generation (LTCG).
Code generation might generate a new reference to memset after linking
has started. The LTCG must make assumptions about where memset is
defined which is normally the C runtime.
2022-06-15 14:17:35 -07:00
Sam Lantinga
a5d338bd2d Added support for the Qanba Dragon Arcade Joystick (PS3) on macOS 2022-06-15 14:11:00 -07:00
Sam Lantinga
7d7c48302b Use python3 for sort_controllers.py 2022-06-15 14:10:22 -07:00
Sam Lantinga
72fea0ed6f Added support for the Qanba Dragon Arcade Joystick 2022-06-15 13:58:28 -07:00
takase1121
f8ae3ef1eb wayland: use libdecor resize edge enums for libdecor 2022-06-15 10:21:18 -04:00
Ozkan Sezer
960b86dcb5 update SDL_render_d3d12.c after DPI scaling/highdpi support patch.
See https://github.com/libsdl-org/SDL/pull/5778#issuecomment-1153006938
2022-06-14 21:03:31 -07:00
Ryan C. Gordon
ded6c22efb
render: Corrected wrong SDL_memcpy() sizes for viewport, cliprect.
Fixes #5786.
2022-06-14 14:10:14 -04:00
Frank Praznik
e427e80bfe wayland: Use the output descriptions from xdg-output when available
Some compositors will provide 'nicer' / 'human readable' output descriptions via the xdg-output protocol. Use these description strings, when available, instead of the model name provided by wl-output.  On compositors such as GNOME where this is provided, the display names provided to applications by SDL will now match those in the desktop display settings panel.  On compositors where this data isn't provided, the old behavior of using the model string provided by wl-output will remain unchanged.

Additionally, per the protocol spec, output data provided by xdg-output should supersede wl-output data, so this is the recommended behavior in general.
2022-06-14 11:02:20 -04:00
Ozkan Sezer
714502d373 minor windows warning fixes. 2022-06-13 22:15:56 +03:00
Simon McVittie
507ce36d80 video: Note unused SDL_surface creation parameters for removal in SDL 3
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie
535fdc3adc video: Detect and reject nonsense SDL_surface dimensions
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie
8c9f7104e3 video: Harden calculation of SDL_surface pitch and size against overflow
If the width is sufficiently ludicrous, then the calculated pitch or
the image size could conceivably be a signed integer overflow, which
is undefined behaviour. Calculate in the unsigned size_t domain, with
overflow checks.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 11:53:53 -07:00
Simon McVittie
63b3b9a558 Fix some typos in diagnostic messages
Detected by Debian's packaging QA tool, Lintian.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 08:33:27 -07:00
Ryan C. Gordon
9a0367675f
windows: Get better name for the physical display, for Vista and later.
Fixes #5321.
2022-06-12 15:28:49 -04:00
Cameron Cawley
fd8cafc72e Rename variables in SDL_egl.c to be more intuitive 2022-06-11 14:20:18 -07:00
Eric Wasylishen
e09551bc80 Fix WinRT build 2022-06-11 14:19:01 -07:00
Eric Wasylishen
ab81a559f4 Windows DPI scaling/highdpi support
Adds hint "SDL_WINDOWS_DPI_SCALING" which can be set to "1" to
change the SDL coordinate system units to be DPI-scaled points, rather
than pixels everywhere.

This means windows will be appropriately sized, even when created on
high-DPI displays with scaling.

e.g. requesting a 640x480 window from SDL, on a display with 125%
scaling in Windows display settings, will create a window with an
800x600 client area (in pixels).

Setting this to "1" implicitly requests process DPI awareness
(setting SDL_WINDOWS_DPI_AWARENESS is unnecessary),
and forces SDL_WINDOW_ALLOW_HIGHDPI on all windows.
2022-06-11 14:19:01 -07:00
Eric Wasylishen
448e05e3c8 add DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED define 2022-06-11 14:19:01 -07:00
Eric Wasylishen
1b797957c1 SDL_windowsvideo.c: add HIGHDPI_DEBUG ifdef, print DPI awareness at startup if defined
document some additional quirks
2022-06-11 14:19:01 -07:00
Eric Wasylishen
1488c40812 WM_DPICHANGED: remove some dead code, add comment 2022-06-11 14:19:01 -07:00
Eric Wasylishen
60ef11b3cb Fix Watcom compile errors 2022-06-11 14:19:01 -07:00
Eric Wasylishen
d3b970d4d5 HighDPI: remove SWP_NOSIZE in WIN_SetWindowPosition
If the move results in a DPI change, we need to allow the window to resize (e.g. AdjustWindowRectExForDpi frame sizes are different).

- WM_DPICHANGED: Don't assume WM_GETDPISCALEDSIZE is always called for PMv2 awareness - it's only called during interactive dragging.

- WIN_AdjustWindowRectWithStyle: always calculate final window size including frame based on the destination rect,
not based on the current window DPI.

- Update wmmsg.h to include WM_GETDPISCALEDSIZE (for WMMSG_DEBUG)

- WIN_AdjustWindowRectWithStyle: add optional logging

- WM_GETMINMAXINFO: add optional HIGHDPI_DEBUG logging

- WM_DPICHANGED: fix potentially clobbering data->expected_resize

Together these changes fix the following scenario:
- launch testwm2 with the SDL_WINDOWS_DPI_AWARENESS=permonitorv2 environment variable
- Windows 10 21H2 (OS Build 19044.1706)
- Left (primary) monitor: 3840x2160, 125% scaling
- Right (secondary) monitor: 2560x1440, 100% scaling

- Alt+Enter, Alt+Enter (to enter + leave desktop fullscreen), Alt+Right (to move window to right monitor). Ensure the window client area stays 640x480. Drag the window back to the 125% monitor, ensure client area stays 640x480.
2022-06-11 14:19:01 -07:00
Eric Wasylishen
51ebefeeee Support PMv2 DPI awareness, add SDL_HINT_WINDOWS_DPI_AWARENESS
The hint allows setting a specific DPI awareness ("unaware", "system", "permonitor", "permonitorv2").

This is the first part of High-DPI support on Windows ( https://github.com/libsdl-org/SDL/issues/2119 ).
It doesn't implement a virtualized SDL coordinate system, which will be
addressed in a later commit. (This hint could be useful for SDL apps
that want 1 SDL unit = 1 pixel, though.)

Detecting and behaving correctly under per-monitor V2
(calling AdjustWindowRectExForDpi where needed) should fix the
following issues:

https://github.com/libsdl-org/SDL/issues/3286
https://github.com/libsdl-org/SDL/issues/4712
2022-06-11 14:19:01 -07:00
Cameron Gutman
81d3adddbf events: Fix spurious early returns from SDL_WaitEvent()/SDL_WaitEventTimeout()
Fixes #5780
2022-06-11 14:18:45 -07:00
Nhalrath
b3260e7eb3 Remove macro definition for SDL_ERRBUFIZE
I was looking at how errors are handled by SDL and came across this #define SDL_ERRBUFIZE which looks like a typo for SDL_ERRBUFSIZE, but either way, it looks like this isn't being used anywhere anymore because it was getting reported whenever I compile SDL with -Wunused-macros, and the last time it was mentioned in the code was from commit 09ca66b.
2022-06-11 08:42:59 -07:00
Frank Praznik
4a3277b0f9 wayland: Always commit window constraints before entering fullscreen
XDG-toplevel min/max size values are double-buffered data and must be committed before entering the fullscreen state, or a max window size value smaller than the display dimensions may cause the compositor to incorrectly configure the fullscreen window size.  This fixes windowed->fullscreen transitions on GNOME, where, previously, certain combinations of window flags and min/max size values could cause entering fullscreen mode to fail with odd window sizes and/or offsets due to the new max size values not being committed before entering fullscreen, causing the compositor to clamp to the old values.

In the case of libdecor, it has its own layer of buffering on top of the xdg-toplevel surface for the min/max window dimensions, so both a frame commit and surface commit are required to set the state properly.
2022-06-10 14:24:12 -07:00
Frank Praznik
78698a0ba2 wayland: Use a separate frame callback for setting the surface damage region
Previously, the surface damage region was being set in the same callback used for preventing render hangs in the GL backend when the surface was not visible.  This was not ideal, as the callback was never fired in the case of using a different render backend or having a swap interval of 0.  Use a separate frame callback for setting the surface damage region to ensure that it fires reliably, regardless of the backend being used or swap interval.
2022-06-10 14:24:12 -07:00
Frank Praznik
146ea9b0e1 wayland: Only set the surface opaque region if EGL transparency is disabled
Check if the "SDL_VIDEO_EGL_ALLOW_TRANSPARENCY" hint is enabled and don't mark surfaces as opqaue if it is.
2022-06-10 14:24:12 -07:00
Frank Praznik
a20516d4f3 wayland: Swap emulated mode dimensions in more cases
Some compositors (GNOME for example) don't set the transform flag when dealing with portrait mode displays, so the video modes won't have the width/height swapped in all cases where they should be.  Check for both the 90/270 degree transform flag and if the display is taller than it is wide when determining whether to swap the width and height of the emulated video modes, and adjust the comparison logic when size testing against the native mode to account for this.
2022-06-10 14:24:12 -07:00
Frank Praznik
e1c8350439 wayland: Add a hint to disable video mode emulation under Wayland
Add the hint "SDL_VIDEO_WAYLAND_MODE_EMULATION", which can be used to disable mode emulation under Wayland. When disabled, only the desktop and/or native display resolution is exposed.
2022-06-10 14:24:12 -07:00
Frank Praznik
e9d3dcea73 wayland: Unify integer and fractional output scaling
Previously, scale values used by the displays and surfaces were always integers, with fractional scale values only being calculated when the backbuffer and viewport sizes were being determined. Now, if xdg-output is available, the fractional scale of output displays is calculated when the displays are enumerated and the true scale values of the output devices are used whenever possible.

This unifies the integer and fractional scaling systems, allows for the use of more accurate scale values that minimize overdraw when windows straddle multiple outputs, and lays the groundwork for the pending Wayland scaling protocols that will report the preferred scale values per-surface instead of per-output.
2022-06-10 14:24:12 -07:00
Frank Praznik
4fde7dd830 wayland: Refactor the Wayland mode emulation and viewport logic
Compartmentalize the fullscreen mode emulation code blocks, unify the windowed/fullscreen viewport logic, consolidate all window geometry code into a central function to eliminate blocks of duplicate code and rename related variables and functions to more explicitly reflect their purpose.
2022-06-10 14:24:12 -07:00
Sam Lantinga
ce5763230b The backlight event is "change", not "add" or "remove" 2022-06-10 12:42:45 -07:00
Sam Lantinga
68544be44b Added support for the Nintendo Online controllers 2022-06-10 11:31:59 -07:00
Ryan C. Gordon
b75cd2b36d
x11: Force window back to expected size after SDL_SetWindowBordered.
This helps if the window manager decided to let it fill the space that
an existing border was using before its removal.

Fixes #5718.
2022-06-10 14:13:07 -04:00
Ozkan Sezer
51db775442 updated windows watcom exports file after last commit. 2022-06-10 06:23:20 +03:00
Sam Lantinga
9202df0472 Implemented SDL_GameControllerGetFirmwareVersion() for HIDAPI PS5 controllers 2022-06-09 18:11:34 -07:00
Guldoman
e5a3acd6bd ime: fcitx: Retrieve cursor position and selection
Also, if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, make use of
`SDL_TEXTEDITING_EXT` by sending the full preedit string.
2022-06-09 15:18:50 -07:00
Guldoman
dd7bed9ebc ime: ibus: Retrieve cursor position and selection
Also, if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, make use of
`SDL_TEXTEDITING_EXT` by sending the full preedit string.
2022-06-09 15:18:50 -07:00
Guldoman
d11702ce29 ime: wayland: Make use of SDL_TEXTEDITING_EXT
Because we were sending multiple chunks of preedit strings,
`SDL_SendEditingText` was using the old `SDL_TEXTEDITING` event only.

Now if `SDL_HINT_IME_SUPPORT_EXTENDED_TEXT` is enabled, we send the full
string and correctly set the cursor position and selection size.
2022-06-09 15:18:50 -07:00
Guldoman
74bcc5a0a3 stdlib: Add SDL_utf8strnlen 2022-06-09 15:18:50 -07:00
Sam Lantinga
c7f4103807 Special case for k_eControllerType_XInputSwitchController in the raw input path 2022-06-09 13:47:29 -07:00
Sam Lantinga
e6cb082232 Fixed the default mapping on Windows for the HORI Fighting Commander 2022-06-09 13:20:38 -07:00
Cameron Cawley
0a93ac1294 Work around the lack of clock() on PS Vita 2022-06-09 11:07:06 -07:00
chalonverse
6f69bbc541 D3D11: Fix SDL_TEXTUREACCESS_TARGET not working if SDL_HAVE_YUV was 0
Added a couple of missing SDL_zeros in CreateTexture
2022-06-08 12:51:09 -07:00
chalonverse
8303c5d0a3 Added missing SDL_zero for renderTargetViewDesc 2022-06-08 12:51:09 -07:00
Sam Lantinga
d58d637ac6 Added support for the Qanba Obsidian Arcade Joystick on Linux 2022-06-08 11:07:36 -07:00
Charlie Birks
0fcfaf9e94 emscripten: use MAIN_THREAD_EM_ASM for the fb/cursor proxying
This is how everything else was handled and fixes undefined symbol
errors in non-threads builds.
2022-06-08 08:09:46 -07:00
chalonverse
7a335df9cf Updated CMakeLists.txt and configure.asc/script so that it checks for the required Windows SDK version before it enables the d3d12 renderer. Also fixed reported warnings in some builds. 2022-06-07 17:07:33 -07:00
Sylvain
2cc2260435
Fixed bug #5768 - SDL_RenderGeometry's software backend failed to render when texture coordinates are reversed
handle flip vertical/horizontal when reconstructing rects from triangles
2022-06-07 16:30:01 +02:00
chalonverse
4082821822
DirectX 12 Renderer (#5761)
* DirectX 12 Renderer (27 squashed commits)

* Add missing SDL_hidapi.h of merge of SDL.vcxproj.filters

* Fixed OpenWatcom build failure

* Dynapi fix

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
2022-06-06 17:42:30 -07:00
Ozkan Sezer
63e12cf601 SDL_windows_main.c: replace CopyMemory() with SDL_memcpy() 2022-06-06 22:55:56 +03:00
Ryan C. Gordon
ec0204d243
x11: Don't use GetXftDPI() when XRandR can tell us the DPI per-output.
Fixes #5764.
2022-06-06 14:39:58 -04:00
Ozkan Sezer
61115aebd3 update dynapi after the loongarch support patch 2022-06-06 19:29:56 +03:00
yuanhecai
50d8642fa3 Add optimiztion function with LSX in LoongArch
1. yuv420_rgb24_lsx
1. yuv420_rgba_lsx
2. yuv420_bgra_lsx
3. yuv420_argb_lsx
4. yuv420_abgr_lsx
2022-06-06 08:49:09 -07:00
yuanhecai
17f63e53f8 Add loongarch support
LSX and LASX are enabled by default if compiler supports them.
2022-06-06 08:49:09 -07:00
Ryan C. Gordon
9703f23663
SDL_SetHintWithPriority: actually, this test is good.
Otherwise, we end up calling the callback if both the old and new value
are NULL.

This reverts commit 5f25a6ea78 (and also
trims some whitespace).
2022-06-06 10:55:29 -04:00
Ryan C. Gordon
5f25a6ea78
Revert "SDL_SetHintWithPriority: better test if hint value has changed."
Actually, the original test was fine, disregard.

This reverts commit c391bdc160.
2022-06-06 09:36:20 -04:00
Ryan C. Gordon
c391bdc160
SDL_SetHintWithPriority: better test if hint value has changed. 2022-06-06 09:31:35 -04:00
Ryan C. Gordon
55a07d91fa
SDL_SetHintWithPriority: Allow setting NULL hints.
Fixes #5120.
2022-06-06 09:30:43 -04:00
Ryan C. Gordon
a236bf4f25
x11: Hook up display hotplug notifications.
Obviously this needs XRandR support.

Fixes #4977.
2022-06-06 02:13:37 -04:00
Ryan C. Gordon
6b4bd5a759
test_harness: Report if zero tests to run.
Fixes static analysis complain about a potential malloc(0) call.
2022-06-05 09:34:54 -04:00
Christoph Reichenbach
3a20274ddf Refactoring: move GUID operations out of Joystick
- SDL_JoystickGUID -> SDL_GUID (though we retain a type alias)
- Operations for GUID <-> String ops are now in
  src/SDL_guid.c and include/SDL_guid.h
- The corresponding Joystick operations delegate to SDL_guid.c
- Added test/testguid.c
2022-06-04 17:22:13 -07:00
Sam Lantinga
423141bfca Added a function to get the controller firmware version 2022-06-03 18:50:00 -07:00
Sam Lantinga
17410887d0 Separated controller type data into a C file 2022-06-03 15:03:08 -07:00
Sam Lantinga
ae2cc29f8b Make sure initial state is set correctly for the D3D renderer
Fixes https://github.com/libsdl-org/SDL/issues/5749
2022-06-03 09:44:34 -07:00
David Gow
847539afeb wayland: Only call libdecor_dispatch() if we've loaded libdecor
As of #5703, we call libdecor_dispatch() in Wayland_WaitEventTimeout(),
but this will crash if we don't load libdecor, as
SDL_VideoData::shell.libdecor will be NULL.

Since we don't load libdecor if we don't intend to use it (i.e., if
should_use_libdecor returns false), this results in a crash under KDE in
almost all circumstances.
2022-06-01 08:32:13 -07:00
Sam Lantinga
7fa46ec40b The Google Pixel fingerprint sensor also shows up on Linux when running on the phone 2022-05-31 11:11:19 -07:00
Ethan Lee
964e979d06 hidapi: Allow disabling libusb support at runtime 2022-05-30 13:45:24 -07:00
Sam Lantinga
c87b0142fe Fixed building with C89 compiler 2022-05-30 12:02:25 -07:00
Guldoman
f78f775238 ime: windows: allocate space for null terminator 2022-05-28 08:57:29 -07:00
Sam Lantinga
fd2a2eea10 Fixed declaration-after-statement warning 2022-05-28 07:49:18 -07:00
Sam Lantinga
d2c4d74dd0 Fixed build with MinGW-64 windows.devices.power.h
The MinGW-64 header defines the parameters as ABI::Windows::Foundation::IReference<INT32 > **, but the Windows header defines the parameters as __FIReference_1_int**
2022-05-27 15:49:35 -07:00
Sam Lantinga
bd22ca762e Revert "Workaround for compiling with MinGW-w64"
This reverts commit efdf43aa9b.

The broken mingw headers aren't in an official release yet, so reporting this upstream.
2022-05-27 15:40:50 -07:00
Sam Lantinga
efdf43aa9b Workaround for compiling with MinGW-w64
Fixes bug https://github.com/libsdl-org/SDL/issues/5589
2022-05-27 15:34:45 -07:00
Sam Lantinga
bef9f2b2c4 Don't trigger device notifications when Steam Deck backlight changes 2022-05-26 20:45:48 -07:00
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