Commit Graph

5909 Commits

Author SHA1 Message Date
Ryan C. Gordon
fe16084075 audio: LOG_DEBUG_CONVERT should use SDL_Log, not fprintf(stderr). 2022-07-20 18:41:53 -04:00
Ryan C. Gordon
257277903e audio: first attempt at rewriting the channel converters.
This is not ready for production use!
2022-07-20 18:41:53 -04:00
Sam Lantinga
be3a945a8b Added support for the 8BitDo Ultimate Wired Controller for Xbox 2022-07-20 11:05:55 -07:00
Ozkan Sezer
b700a32630 audio, pipewire: fix signatures of pw_get_library_version and pw_init.
Reference issue: https://github.com/libsdl-org/SDL/issues/5938
2022-07-20 07:01:10 +03:00
Ozkan Sezer
6e210d3797 audio, pipewire: pipewire_version_xx globals out of dynamic loading
Fixes build with --disable-pipewire-shared
Reference issue: https://github.com/libsdl-org/SDL/issues/5938
2022-07-20 07:01:10 +03:00
David Gow
78bad66773 video: wayland: Resize the window before sending the SDL_RESIZE event
Currently, the SDL_WINDOWEVENT_RESIZED event is sent before the actual
window is resized (and various internal state, such as the desired
GL/Vulkan backbuffer size, are updated). This makes sense, as SDL will
discard a no-op resize, which would be the case if we had resized before
sending the event (indeed, there are existing hacks to prevent this).

However, this means that SDL_{GL,Vulkan}_GetDrawableSize() will still
use the old size in the SDL_WINDOWEVENT_RESIZED handler. In the case of
SDL_Renderer, this means the drawable size it uses will be wrong, and
the viewport will get "updated" to the old value.

This then results in bug #5899.
2022-07-18 09:21:15 -07:00
Sam Lantinga
53e685168d Fixed declaration-after-statement warning 2022-07-18 07:31:23 -07:00
Sam Lantinga
6ad7fdecce Fixed infinite loop for values bigger than 0x40000000
Fixes https://github.com/libsdl-org/SDL/issues/5930
2022-07-18 07:26:29 -07:00
Sam Lantinga
2be9301410 Fixed comment (thanks @pionere!) 2022-07-18 07:18:56 -07:00
Sam Lantinga
cef1514b01 Fixed some Xcode warnings 2022-07-17 09:07:04 -07:00
Sam Lantinga
b299cb3d3c Added a utility function to calculate the next power of 2 for a value 2022-07-17 08:31:16 -07:00
Ethan Lee
90b86b132a audio: Handle non-power-of-two spec.samples when unsupported
Fixes #3685
2022-07-17 10:36:15 -04:00
Ethan Lee
a09d62e4d8
directsound: Remove redundant SubFormat copy 2022-07-15 23:45:56 -04:00
Ethan Lee
c5e408ae98 directsound: For channel counts > 2, generate a dwChannelMask for CreateSoundBuffer 2022-07-15 13:59:46 -04:00
Ethan Lee
fff34f6304 windows: SDL_IMMDevice needed more deinit code from the Win32 path.
Fixes #5919
2022-07-15 09:49:29 -04:00
Frank Praznik
37aecda2c1 pipewire: Use PW_KEY_TARGET_OBJECT to specify stream connection nodes
Pipewire 0.3.44 introduced PW_KEY_TARGET_OBJECT, which is to be used to specify target connection nodes for streams.  This parameter takes either a node path (PW_KEY_NODE_NAME) or serial number (PW_KEY_OBJECT_SERIAL) to specify a target node.  The former is used in this case since the path is already being retrieved and stored for other purposes.

The target_id parameter in pw_stream_connect() is now deprecated and should always be PW_ID_ANY when PW_KEY_TARGET_OBJECT is used.
2022-07-14 12:23:50 -04:00
Ozkan Sezer
2201d80255 avoid -Werror=declaration-after-statement after last commit. 2022-07-14 02:40:00 +03:00
freebsd
24b3efd08d (OpenBSD) Exe Path: Use PWD instead of CWD and use CWD as fallback 2022-07-13 16:24:20 -07:00
Sam Lantinga
883409ea07 Added support for the misc1 button on the Nintendo Switch Pro Controller
when using hid_nintendo kernel driver
2022-07-13 11:26:42 -07:00
SuperSamus
9a4f200d44 gamecontrollerdb: Linux, add mappings for hid-nintendo driver and more
Taken from https://github.com/gabomdq/SDL_GameControllerDB/blob/master/gamecontrollerdb.txt
2022-07-13 11:23:15 -07:00
Sam Lantinga
06c7d22653 Added mappings for the HORI Fighting Stick mini 4 on Linux and macOS 2022-07-12 18:53:53 -07:00
Sam Lantinga
e24b971a34 Added support for the NVIDIA Shield controller guide button 2022-07-12 17:53:03 -07:00
Cameron Gutman
b321eae51a joystick: Fix spurious battery empty events when opening a Shield controller 2022-07-11 19:43:25 -05:00
Cameron Gutman
a0d8848baa joystick: Plumb SDL_JoystickSendEffect() for the Shield HIDAPI driver
The effect data format consists of one command byte followed by zero or more
payload bytes.
2022-07-11 19:38:26 -05:00
Frank Praznik
36d8460c9e pipewire: Dynamically allocate the buffer for node strings
Calculate and allocate the buffer for the IO node name and path strings dynamically instead of using arbitrary sized static buffers.
2022-07-11 18:03:56 -04:00
Frank Praznik
996cea31ee pipewire: Update default audio devices during runtime
Make the default device metadata node persist for the lifetime of the hotplug loop so the default source/sink devices will be updated if they change during runtime.
2022-07-11 18:03:56 -04:00
Frank Praznik
60da11f0e2 pipewire: Remove deprecated configuration key
With Pipewire now requiring a minimum version 0.3.24, the PW_KEY_CONTEXT_PROFILE_MODULES value is no longer required for legacy compatability and can be safely removed.
2022-07-11 18:03:56 -04:00
Ozkan Sezer
4fa2653394 SDL_GetJoystickGUIDInfo: byte-swap vendor, product and version values.
Reference issue: https://github.com/libsdl-org/SDL/issues/5907
2022-07-12 00:55:00 +03:00
Ethan Lee
ecfbdce64b pipewire: Require version 0.3.24 or newer at runtime 2022-07-11 13:34:35 -04:00
Ethan Lee
2f0816adb7 Add SDL_GetDefaultAudioInfo.
This API is supported on pipewire, pulseaudio, wasapi, and directsound.

Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
2022-07-11 13:34:35 -04:00
Ethan Lee
15d0618083 SDL_IMMDevice: Fix a WASAPI-specific leak, clean up Add() 2022-07-11 12:54:34 -04:00
Ethan Lee
ae105ae1c7 windows: Move IMMDevice work to common file, implement DirectSound enumeration support 2022-07-11 12:54:34 -04:00
Sam Lantinga
2373da5d94 Exposed SDL_ResetKeyboard() as a public function
This will be used by Source 2 titles to reset keyboard state before showing assertion dialogs
2022-07-11 09:49:00 -07:00
Cameron Gutman
6e712d2440 joystick: Add HIDAPI driver for NVIDIA SHIELD 2017 controller
Basic input already works using the OS HID driver, but this enables
force feedback and battery state reporting.
2022-07-10 10:53:26 -07:00
Cameron Gutman
3242265ff1 joystick: Fix endianness issues in Xbox HIDAPI drivers 2022-07-10 10:49:38 -07:00
Ozkan Sezer
2f21648528 SDL_os2video.c: silenced -Wempty-body warning, along with minor tidy-up. 2022-07-08 20:56:40 +03:00
285424336
4aad594a8b Update SDL_qsa_audio.c
Fix qnx platform compile error, change SDL_Bool to SDL_bool.
2022-07-08 12:15:00 +03:00
Eric Curtin
c0eada2019
Fix assumption that DRI_DEVNAME begins at 0 (#5865)
* Fix assumption that DRI_DEVNAME begins at 0

The existing logic of the code was to count every possible entry in
KMSDRM_DRI_PATH. After this a for loop would start trying to open
filename0, filename1, filename2, etc. In recent Linux kernels (say
5.18) with simpledrm, the lowest KMSDRM_DRI_DEVNAME is often
/dev/dri/card1, rather than /dev/dri/card0, causing the code to fail
once /dev/dri/card0 has failed to open. Running:

modprobe foodrm && modprobe bardrm && rmmod foodrm

before you try to run an application with SDL KMSDRM would have also
made this fail.

* Various changes from review

- Removed newline and period from SDL error
- Explicitely compare memcmp to zero (also changed to SDL_memcmp)
- Changed memcpy to strncpy
- Less aggressive line wrapping

* Various changes from review

- strncpy to SDL_strlcpy
- removed size hardcodings for KMSDRM_DRI_PATHSIZE and
  KMSDRM_DRI_DEVNAMESIZE
- made all KMSDRM_DRI defines, run-time variables to reduce bugs caused
  by these defines being more build-time on Linux and more run-rime on
  OpenBSD
- renamed openbsd69orgreater variable to moderndri
- altered comment from "if on OpenBSD" to add difference in 6.9

* Various changes from review

- Use max size of destination, rather than max size of source
- Less hardcodings
2022-07-06 09:00:16 -07:00
Sam Lantinga
adf3ce7c01 Don't drop mouse focus on WM_MOUSELEAVE if the mouse is in relative mode; mouse-level is not meaningful for that case.
Do drop mouse focus when keyboard focus is lost if the mouse is in relative mode.
2022-07-05 21:42:24 -07:00
Sam Lantinga
0253a45029 Fix format specifiers for WPARAM/LPARAM values, they are UINT_PTR. 2022-07-05 21:42:20 -07:00
Eddy Jansson
ad0b91302d android: Add missing entries to SDL_category_prefixes table.
Add static assert so this shouldn't happen in the future.

Fixes #5883
2022-07-05 17:50:19 -07:00
Chris Mumford
98411c0d33 Added include: libkern/OSAtomic.h
When building on macOS without gcc (e.g. clang) where HAVE_GCC_ATOMICS
is not defined, `SDL_AtomicTryLock` will call
`OSAtomicCompareAndSwap32Barrier` which is not yet declared.
Including OSAtomic.h on OSX resolves this error/warning:

    SDL_spinlock.c:125:12: error: implicit declaration of function
      'OSAtomicCompareAndSwap32Barrier' is invalid in
      C99 [-Werror,-Wimplicit-function-declaration]
        return OSAtomicCompareAndSwap32Barrier(0, 1, lock);

This was reported in issue #3885 but marked Invalid and closed - possibly
because the default CMake build uses gcc instead of clang.
2022-07-05 07:50:57 -07:00
Ryan C. Gordon
fdb86b8266
x11: Don't try to use XInput2 multitouch if not supported.
Fixes #5889.
2022-07-04 12:48:32 -04:00
rohlem
b085c18251 make SDL_SetTextInputRect take a pointer to const
The documentation doesn't state that the argument is ever modified,
and no implementation does so currently.
This is a non-breaking change to guarantee as much to callers.
2022-07-04 09:38:01 -07:00
Dav999-v
51f75b8b30 Fix fallback implementations of SDL_strchr and SDL_strrchr for '\0'
strchr and strrchr return a pointer to the first/last occurrence of a
character in a string, or NULL if the character is not found. According
to the C standard, the final null terminator is part of the string, and
it should thus be possible to get a pointer to the final null with
these functions. The fallback implementations of SDL_strchr and
SDL_strrchr would always return NULL if trying to find '\0', and this
commit fixes that.
2022-07-04 11:10:26 -04:00
chalonverse
85bbf8eec9 Fixed coment after #endif 2022-07-03 15:22:30 -04:00
Francisco Javier Trujillo Mata
7d7c5b803c Improving mkdir creating parents folder 2022-07-03 09:23:34 -07:00
chalonverse
f317d619cc
Xbox GDKX support (#5869)
* Xbox GDK support (14 squashed commits)

* Added basic keyboard testing

* Update readme

* Code review fixes

* Fixed issue where controller add/removal wasn't working (since the device notification events don't work on Xbox, have to use the joystick thread to poll XInput)
2022-07-01 13:59:14 -07:00
Sam Lantinga
89624485cc Updated the test bitmap font to cover the Latin-1 character set
Based on Marcel Sondaar's font8_8.asm, in the public domain
2022-07-01 13:32:56 -07:00
Sam Lantinga
e9d5060c4c checkkeys will now render text that is input
Also added test functions for multi-line debug text display

Currently this only supports ASCII, as the font doesn't have the correct Latin-1 characters
2022-07-01 12:56:47 -07:00
Sam Lantinga
bdbf90e3fc on-screen keyboard newline is reported as an Enter key 2022-07-01 09:17:30 -07:00
Sam Lantinga
7ac5d616f3 Fixed backspace being delivered after committed text on Android 12
Testing:
Enter "hello ", followed by "?" - the events generated are:
: commitText hello
: Key pressed :  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key released:  scancode 11 = H, keycode 0x00000068 = H  modifiers: (none)
: Key pressed :  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key released:  scancode 8 = E, keycode 0x00000065 = E  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key released:  scancode 15 = L, keycode 0x0000006C = L  modifiers: (none)
: Key pressed :  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key released:  scancode 18 = O, keycode 0x0000006F = O  modifiers: (none)
: Key pressed :  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: Key released:  scancode 44 = Space, keycode 0x00000020 = Space  modifiers: (none)
: INPUT Text (\x68\x65\x6c\x6c\x6f\x20): "hello "
: finishComposingText
: deleteSurroundingText 1 / 0
: Key pressed :  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: Key released:  scancode 42 = Backspace, keycode 0x00000008 = Backspace  modifiers: (none)
: commitText ?
: Key pressed :  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: LSHIFT
: Key pressed :  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 56 = /, keycode 0x0000002F = /  modifiers: (none)
: Key released:  scancode 225 = Left Shift, keycode 0x400000E1 = Left Shift  modifiers: (none)
: INPUT Text (\x3f): "?"
: setComposingText , at 1
: EDIT Text (): ""

Previously, the backspace would be delivered after the "?"
2022-07-01 08:58:08 -07:00
Cameron Cawley
78089e6598 Remove unused internal header SDL_sysevents.h 2022-07-01 07:39:48 -07:00
Cameron Gutman
3e114872e8 joystick: Fix redetection of HIDAPI joysticks after reinitializing
The HIDAPI joystick driver doesn't properly reset the change counter
it uses to track if re-enumeration is needed when the joystick
subsystem is quit and then reinitialized.

The first SDL_Init(SDL_INIT_JOYSTICK) will result in the expected
HIDAPI joysticks appearing, but subsequent calls will result in no
joysticks being enumerated until another HIDAPI joystick is added
or removed from the system.
2022-06-30 20:43:14 -07:00
chalonverse
4f73219794 Fixed D3D12 renderer not working with batching, and got rid of the vertex buffer size limit 2022-06-30 03:41:17 -07:00
Sam Lantinga
0ad65277ce Refactored code to send scancodes for an ASCII on-screen keyboard key 2022-06-29 17:26:09 -07:00
Francisco Javier Trujillo Mata
a054a5f7f2 Improve SDL2 main, adding memory card and usb drivers 2022-06-29 03:15:00 +03:00
Jade Macho
6a2e6c82a0 Add SDL_HINT_DIRECTINPUT_ENABLED (on by default) 2022-06-28 15:59:05 -07:00
Sam Lantinga
1d1fb95a61 Removed double va_end() 2022-06-28 06:21:45 -07:00
Sylvain
f815580dde
Fix SIGSEV in SDL_error. Re-apply same pattern on this uncompiled code (see #5795) 2022-06-28 13:09:38 +02:00
Sylvain
d4e6047e3c
Fix SIGSEV in SDL_error (After removing the limit on the size of the SDL error message) (see #5795) 2022-06-28 09:46:12 +02:00
Sourcery AI
cddf095a16 'Refactored by Sourcery' 2022-06-27 17:55:47 -07:00
Sam Lantinga
b6f1c91862 Fixed Watcom C build 2022-06-27 17:44:55 -07:00
Sam Lantinga
cbd0187475 Removed the limit on the size of the SDL error message
Also added SDL_GetOriginalMemoryFunctions()

Fixes https://github.com/libsdl-org/SDL/issues/5795
2022-06-27 16:59:50 -07:00
Pierre Wendling
f25b4b2774 Style: Flip if statement. 2022-06-27 15:19:40 -07:00
Pierre Wendling
6c536afdb7 Fix C89 declaration for macOS modules.
Since Clang 14, `-Wdeclaration-after-statement` is enforced on every
standard.
2022-06-27 15:19:40 -07:00
Francisco Javier Trujillo Mata
e4a8087551 Initial Audio driver 2022-06-27 15:18:48 -07:00
Brad Smith
9723917637 Use proper header for OpenBSD PPC CPU detection 2022-06-27 11:01:34 -07:00
chalonverse
3b191580c3
Windows GDK Support (#5830)
* Added GDK

* Simplfied checks in SDL_config_wingdk.h

* Added testgdk sample

* Added GDK readme

* Fixed error in merge of SDL_windows.h

* Additional GDK fixes

* OpenWatcom should not export _SDL_GDKGetTaskQueue

* Formatting fixes

* Moved initialization code into SDL_GDKRunApp
2022-06-27 10:19:39 -07:00
Sylvain
314bb5a1ed
Fixed bug #5850: Android EGL_BAD_ACCESS because of viewport command while turning the screen off/on. 2022-06-27 14:45:14 +02:00
Francisco Javier Trujillo Mata
7fd46ec581 Initial PS2_Joystick implementation 2022-06-27 00:32:43 -07:00
Francisco Javier Trujillo Mata
84d69da4e1 Initial SDL_ps2_main implementation 2022-06-27 00:32:43 -07:00
Ivan Epifanov
b2f07d94d2 Vita: create rendertarget color surface with same format as texture. Fixes #5844 2022-06-26 15:41:14 -07:00
unknown
ebe4f47f2b Fixed __VA_ARGS__ in gcc when no args 2022-06-26 15:35:18 -07:00
unknown
51c6488f97 Add support for SDL_render_d3d12.c to compile in C++ mode 2022-06-26 15:35:18 -07:00
Francisco Javier Trujillo Mata
2b41f497db Improve Joystick removing semaphores 2022-06-22 15:08:41 +02:00
Francisco Javier Trujillo Mata
c3a5e4aa7b Adding GetGamepadMapping to Vita Joystick driver 2022-06-22 02:23:00 +03:00
Ozkan Sezer
7adb08a79a fixed SDL_BlitMap typedef redefinition errors 2022-06-22 01:37:00 +03:00
Ryan C. Gordon
12b371ee0f
x11: Don't send diplay-add events for displays connected at init time.
Reference Issue #4977.
2022-06-21 14:49:21 -04:00
Frank Praznik
c11bdeeb69 wayland: Round fractional backbuffer sizes halfway away from zero
Use SDL_lroundf() to round fractional backbuffer sizes halfway away from zero, as this is the rounding method recommended by the forthcoming Wayland fractional scaling protocol.
2022-06-21 14:01:29 -04:00
Pieter-Jan Briers
9914e87faa Also send DPI change when expected resize. 2022-06-20 06:54:40 -07:00
Pieter-Jan Briers
af733c7a32 Fix DPI-raised SDL_WINDOWEVENT_SIZE_CHANGED with event callback.
Move the sending of this event down so stuff like calling SDL_GL_GetDrawableSize() from a callback reports the new size instead of the old one.
2022-06-20 06:54:40 -07:00
Ozkan Sezer
2316e5682e SDL_windows.h: match WINVER value to _WIN32_WINNT. 2022-06-19 08:33:28 -07:00
Ozkan Sezer
22a29321e9 tweak _WIN32_WINNT value for shellscalingapi.h present but no d3d12 2022-06-19 08:33:28 -07:00
Sam Lantinga
abe38bca3e Support SDL_AUDIODRIVER set to "dsound", which was used by SDL 1.2
Fixes https://github.com/libsdl-org/SDL/issues/5818
2022-06-18 13:08:58 -07:00
Ozkan Sezer
a8d41b3b45 check for shellscalingapi.h presence instead of WINVER >= 0x0603 2022-06-18 13:00:44 -07:00
Sam Lantinga
5f6d0abebe SDL_SendEditingText() has int parameters, so use that type for parameter calculation
We might want to use ssize_t as @Guldoman suggested, but that's a larger internal API change, and still requires casting of the SDL_utf8strnlen() result.

Fixes https://github.com/libsdl-org/SDL/pull/5821
2022-06-18 12:59:28 -07:00
Mathieu Eyraud
00b95e989b Fix read of uninitialised variable
If the condition (dbus->message_iter_get_arg_type(&sub) == DBUS_TYPE_STRING) is false, subtext is not initialised.
2022-06-18 18:23:50 +03:00
Sam Lantinga
12f14bdbeb Fixed digit count in sscanf, e.g. "%1x" 2022-06-18 07:02:38 -07:00
Sam Lantinga
53e307050b List the available tests if the filter didn't match 2022-06-18 06:52:16 -07:00
Sam Lantinga
eb7e29a8b2 Fixed crash when the joystick product name isn't available 2022-06-17 17:43:14 -07:00
Sam Lantinga
adc6875870 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!)
Closes https://github.com/libsdl-org/SDL/pull/5811
2022-06-17 10:22:28 -07:00
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