Commit Graph

3912 Commits

Author SHA1 Message Date
Sam Lantinga
a7dede7e36 Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons 2020-11-27 10:44:51 -08:00
Sam Lantinga
ce77966da8 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers 2020-11-27 10:44:49 -08:00
Sam Lantinga
8a449de20d Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT 2020-11-27 10:44:47 -08:00
Sam Lantinga
37c9e4afa3 Fixed processing WM_INPUT_DEVICE_CHANGE at startup 2020-11-27 06:03:15 -08:00
Sam Lantinga
248fc75bd2 Correlate just based on buttons, joystick axes are not as precise and could potentially cause incorrect uncorrelation.
It's okay if the triggers aren't precise until someone presses a button on their controller.
2020-11-27 05:53:56 -08:00
Sam Lantinga
e7e615de26 Removed extraneous windows message pumping
Most of the raw input events are dispatched in the main windows message loop. We only dispatch device change messages separately when we need them to be completely up to date.
2020-11-27 05:53:54 -08:00
Sam Lantinga
2931eccd84 Fixed detecting Bluetooth raw input devices, which have device names longer than 128 characters 2020-11-27 05:53:52 -08:00
Sam Lantinga
849ce80376 Renamed SDL_JOYSTICK_RAWINPUT_GAMING_INPUT to SDL_JOYSTICK_RAWINPUT_WGI 2020-11-27 05:53:50 -08:00
Sam Lantinga
219a28dd8a Fixed D-pad uncorrelating raw input controllers (thanks Jimbly!) 2020-11-27 03:45:05 -08:00
Sylvain Becker
2c079a2f6c SDL_FillRects: prevent empty SDL_surface from raising an error message
It's legitimate to have a surface with 0 width or height (null 'pixels' pointer).
But calling SDL_FillRects would wrongly set the error "You must lock the surface".
2020-11-27 09:42:14 +01:00
Ozkan Sezer
3fbff2a45b SDL_rawinputjoystick.c: fix ambiguous 'else' warning
src/joystick/windows/SDL_rawinputjoystick.c: In function 'RAWINPUT_HandleStatePacket':
src/joystick/windows/SDL_rawinputjoystick.c:1343:9: warning: suggest explicit braces to avoid ambiguous 'else'
2020-11-26 10:47:33 +03:00
Sam Lantinga
845b903324 Implemented trigger rumble for raw input controllers 2020-11-25 16:46:42 -08:00
Sam Lantinga
517be80822 Implemented battery status for Bluetooth Xbox One controllers
Also switched the rumble loop count to 0xEB (one hour) to match Windows driver
2020-11-25 16:05:19 -08:00
Sam Lantinga
6a7f29cdbb Fixed compiling on tvOS 2020-11-25 11:31:17 -08:00
Sam Lantinga
9ec2cf5629 Fixed building with Windows.Gaming.Input enabled 2020-11-25 10:31:59 -08:00
Sam Lantinga
3c07dd12f0 Strip an extra '.' off of the HORI manufacturer name 2020-11-25 10:28:48 -08:00
Sam Lantinga
159d1b3df5 Don't set the serial number after the controller is opened
We'll use the USB value instead so it's available as soon as it's opened.
2020-11-25 01:35:45 -08:00
Sam Lantinga
7d92b14f46 Simplified Xbox One controller initialization state, and don't query for the serial number. 2020-11-25 01:18:18 -08:00
Sam Lantinga
9fc4a4c92c Revamped Xbox One HIDAPI init sequence
Added support for querying the controller serial number on newer firmware
2020-11-24 22:25:26 -08:00
Sam Lantinga
46a844786b Added SDL_wcscasecmp() and SDL_wcsncasecmp() 2020-11-24 12:43:01 -08:00
Sam Lantinga
e4b7d9a221 Removed usage of TARGET_OS_OSX for building with older SDKs 2020-11-24 07:56:59 -08:00
Ethan Lee
a7d91ebaa5 winrt: Add EffectiveLocation support for newer Win10 releases 2020-11-09 17:05:21 -05:00
Sam Lantinga
a5cde4cb0c Fixed trying to use @available() on older SDK 2020-11-24 07:29:55 -08:00
Sam Lantinga
97782e6c64 Don't try to call IOS_SupportedHIDDevice() if it's not defined 2020-11-24 07:11:49 -08:00
Sam Lantinga
a063b9fbfb Fixed compiler warning 2020-11-24 07:06:31 -08:00
Sam Lantinga
c63bbb06e9 Including SDL_config_iphoneos.h enables MFI controller code 2020-11-24 06:55:33 -08:00
Sam Lantinga
7a05dbf4b9 Fixed building on FreeBSD
Alex S

Looks like we have a collision with https://hg.libsdl.org/SDL/rev/cd774daff9f6. (Again, the headers in the base system are intended for drivers and should not be used for compiling non-base applications. At least that's the policy for now: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240964#c19.)
2020-11-24 06:42:53 -08:00
Sam Lantinga
feab9d42c1 5363 - Memory leak of joystick->sensors in SDL_JoystickClose
Mathieu Eyraud

Joystick->sensors is never freed.
2020-11-24 06:40:13 -08:00
Sam Lantinga
34bea84a54 Fixed bug 5335 - Patch: enable joystick/haptic/evdev support by default on FreeBSD
Alex S

Ah, that's not quite enough. You need to:
  1. rename src/joystick/bsd/SDL_sysjoystick.c to something;
  2. regenerate configure.
2020-11-23 23:03:55 -08:00
Sam Lantinga
1e943e2ad2 Fixed building with an older SDK and macOS target 2020-11-23 22:59:22 -08:00
Sam Lantinga
4121ab6200 Fixed bug 5354 - DirectFB: Add Vulkan support
Nicolas Caramelli

This patch adds Vulkan support for the DirectFB video driver.
A screenshot with SDL tests running on DirectFB is available on the HiGFXback project:

https://github.com/caramelli/higfxback/wiki/DirectFB#sdl
2020-11-23 21:25:07 -08:00
Sam Lantinga
e44bf8a080 Fixed bug 5359 - Incorrect sensor data from DualShock4
multiply gyro values by sensitivity

When the hardware calibration fails, values read from sensors need to be multiplied by default sensitivity (16 for gyro, 1 for accelerometer).
2020-11-23 21:18:37 -08:00
Sam Lantinga
c8c818d7a4 Fixed bug 5360 - non-libudev joystick detection doesn't see controllers that were already connected
Simon McVittie

When watching for hotplug events we can poll the inotify fd, but we
still need to scan /dev/input once per process, otherwise we'll fail
to detect devices that were already connected.
2020-11-23 21:14:37 -08:00
Simon McVittie
8e2746cfb6 joystick: Don't use udev in Flatpak or pressure-vessel container
Flatpak[1] and pressure-vessel[2] are known to use user namespaces,
therefore udev event notification via netlink won't work reliably.
Both frameworks provide a filesystem API that libraries can use to
detect them. Do that, and automatically fall back from udev-based
device discovery to the inotify-based fallback introduced in Bug #5337.

[1] <https://flatpak.org/>
[2] <https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/tree/master/pressure-vessel>

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-23 21:10:48 -08:00
Sam Lantinga
e9869e07bf Fixed bug 5335 - enable joystick/haptic/evdev support by default on FreeBSD
Alex S

Evdev headers aren't actually included in the base system (well, it has a private copy), they are available through the devel/evdev-proto port instead. We also have devel/libinotify and devel/libudev-devd shims, I didn't verify whether they work with SDL.
2020-11-23 21:08:19 -08:00
Sam Lantinga
62e39b5fa7 Fixed building with an older SDK and macOS target 2020-11-23 20:57:14 -08:00
Sam Lantinga
268aa45645 Fixed compiling with SDL_JOYSTICK_RAWINPUT disabled 2020-11-23 20:26:28 -08:00
Ryan C. Gordon
eaa53a1979 joystick: On Linux, don't try to close an invalid inotify file descriptor. 2020-11-23 22:16:07 -05:00
Ryan C. Gordon
5c9577476f joystick: Fix up Linux joystick code to (mostly) compile on FreeBSD. 2020-11-23 22:14:22 -05:00
Sam Lantinga
179bd66581 Don't enable PS5 controller support if DS4Windows is running - they conflict. 2020-11-23 18:27:43 -08:00
Sam Lantinga
5b3616c325 Generalized the raw input controller driver and moved XInput/WGI detection into it for XInput devices
This fixes bad report parsing for various newer Xbox controllers, and this driver is now preferred over XInput, since it handles more than 4 controllers.
2020-11-23 18:24:05 -08:00
Ryan C. Gordon
0ff5d55a07 x11: Don't try to grab the pointer on an unmapped window (thanks, Lee!)
Fixes Bugzilla #5352.
2020-11-23 21:07:28 -05:00
Sam Lantinga
fd89446782 Fixed building on Mac OS X on the command line and with an older macOS SDK 2020-11-21 14:13:26 -08:00
Sam Lantinga
1df593fb16 Fixed bug 5355 - Add GameController Framework support to macOS
C.W. Betts

This patch adds support to the GameController framework on macOS Big Sur and later, adding support for MFi controllers as well as rumble support for PS4 and Xbox One. There is some code to make sure that the IOKit joystick handler doesn't include two controllers at once.

While the GameController framework is present in earlier versions of macOS, there was no public, approved way of checking if a specific IOHIDDevice is a controller that GameController could handle. This was changed in Big Sur.
2020-11-21 13:15:33 -08:00
Sam Lantinga
870841c414 Reset the LED state after Bluetooth connection has completed on the PS5 controller 2020-11-21 11:59:01 -08:00
Sam Lantinga
a94fe009c6 Moved comment with the code it covers 2020-11-21 18:40:27 -08:00
Sam Lantinga
49f7be6d0d Fixed compile warning C4127: conditional expression is constant 2020-11-21 18:37:56 -08:00
Sam Lantinga
63b52e8e67 Remove SDL dependency in Windows code 2020-11-21 18:34:32 -08:00
Sam Lantinga
d4954eb090 Removed debug code 2020-11-21 18:26:43 -08:00
Sam Lantinga
b442e617e9 Fixed adding an extra zero byte for feature reports
At least with PS4 and PS5 controllers DeviceIoControl() returns the correct value
2020-11-21 18:15:55 -08:00
Sam Lantinga
2e8e3854b8 Fixed compile warning 2020-11-21 17:59:15 -08:00
Sam Lantinga
6b56b98fc3 Fixed is_BLE() return value 2020-11-21 09:26:11 -08:00
Sam Lantinga
65c9f1d2cc Fixed upstream bug: FD 0 is a valid file descriptor
https://github.com/libusb/hidapi/issues/199
2020-11-21 09:06:48 -08:00
Sam Lantinga
549010f2a0 It takes 2 packets to stop audio haptics and start emulated rumble on the PS5 controller 2020-11-20 13:24:49 -08:00
Ozkan Sezer
082558db33 SDL_os2messagebox.c (_makeDlg): fix crash if title and/or message is NULL.
c.f.: bug #5253.
2020-11-20 12:20:02 +03:00
Sam Lantinga
bf7d198d48 The HORI Fighting Commander should only show up as an XInput Switch Controller on Windows 2020-11-19 19:09:42 -08:00
Sam Lantinga
6cb7f9e39a Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for Nintendo Switch Pro controllers using the HIDAPI driver 2020-11-19 19:09:40 -08:00
Sam Lantinga
9980766533 Respect SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS for the Nintendo Switch Pro controller on Linux 2020-11-19 19:09:38 -08:00
Sam Lantinga
7366693f3b Added support for a few more controllers on Linux 2020-11-19 19:09:36 -08:00
Sam Lantinga
ffb4d960b2 Disabled Xbox protocol debugging 2020-11-19 19:09:34 -08:00
Sam Lantinga
c9b097e659 Clarify the meaning of the rumble enable bits for the PS5 controller 2020-11-19 13:31:16 -08:00
Sam Lantinga
c85623d790 Re-enable haptic audio after rumble on PS5 controller
Also make sure we don't set any other state when we're not intending to, and added more interesting effects which are currently not exposed via API
2020-11-19 13:10:14 -08:00
Sam Lantinga
b0b76a61c7 Fixed rumble on PS5 controllers connected to Windows over Bluetooth 2020-11-19 07:12:53 -08:00
Sam Lantinga
8c3196da60 Fixed some compiler warnings 2020-11-18 21:33:11 -08:00
Sam Lantinga
45f1437549 Experimenting with requesting the serial number on an Xbox One controller 2020-11-18 20:34:12 -08:00
Sam Lantinga
963d8b3f40 Fixed bits in the initial Xbox One protocol ack 2020-11-18 20:34:10 -08:00
Sam Lantinga
cd51a51f00 Updated with a better understanding of the Xbox One controller protocol 2020-11-18 20:34:08 -08:00
Ryan C. Gordon
335cfa107b x11: Don't crash if a messagebox has a NULL title string.
Fixes Bugzilla #5253.
2020-11-18 11:24:08 -05:00
Sam Lantinga
51ea6a6d44 Don't send controller gyro and accelerometer updates if the values haven't changed.
This keeps SDL_PollEvent() from returning data continuously when polling controller state.
2020-11-17 22:09:52 -08:00
Sam Lantinga
463d84a860 Added support for the PS5 controller gyro and accelerometer 2020-11-17 10:56:56 -08:00
Sam Lantinga
fcb21aa883 Added API for sensors on game controllers
Added support for the PS4 controller gyro and accelerometer on iOS and HIDAPI drivers

Also fixed an issue with the accelerometer on iOS having inverted axes
2020-11-17 10:30:20 -08:00
Sam Lantinga
d140d88744 Added SDL_JoystickGetSerial() and SDL_GameControllerGetSerial() 2020-11-16 17:36:47 -08:00
Ryan C. Gordon
55e59a4f33 crc32: Fixed include path. 2020-11-16 18:48:13 -05:00
Sam Lantinga
7bbea0bb94 Fixed build warning 2020-11-16 15:10:02 -08:00
Sam Lantinga
71e32f5e1b Added SDL_crc32() 2020-11-16 15:00:15 -08:00
Sam Lantinga
3d48fc05c3 Added notes about the pad lights on the PS5 controller 2020-11-16 13:21:02 -08:00
Sam Lantinga
4514ad573e Fixed updating LED state when starting application with Bluetooth PS5 controller connected 2020-11-16 13:07:11 -08:00
Sam Lantinga
a37e3ae218 Implemented PS5 effects over Bluetooth 2020-11-16 11:21:58 -08:00
Sam Lantinga
c6c116e847 Implemented setting the LED color on the PS5 controller 2020-11-16 10:51:13 -08:00
Sam Lantinga
aa7c3eae19 Fixed size of rumble packet 2020-11-16 09:16:01 -08:00
Sam Lantinga
f28c01a4fb Fixed rumble order on PS5 2020-11-16 09:11:15 -08:00
Sam Lantinga
eb94c19a63 SDL: fix iOS build 2020-11-16 08:09:15 -08:00
Sam Lantinga
8243bd1dc6 SDL: Plumb PS5 rumble to output report 2020-11-16 08:09:13 -08:00
Ozkan Sezer
c0f7325b85 SDL_PrivateJoystickForceRecentering: fix wrong loop counter usage.
The typo seems to have been added by commit c7782fd6142b
2020-11-15 17:10:15 +03:00
Sam Lantinga
5c34c973e6 Clarify that we're using button indices, not using gamepad button names 2020-11-13 19:40:25 -08:00
Sam Lantinga
9f51fad361 Added support for the touchpad on PS4 and PS5 controllers 2020-11-13 18:01:29 -08:00
Sam Lantinga
78422fa3c8 Added more detail on the PS5 controller state packet and enable full reports over Bluetooth 2020-11-13 13:17:07 -08:00
Sam Lantinga
30371f2d4d Fixed doubled report ID for Bluetooth Classic devices on Linux 2020-11-13 13:17:04 -08:00
Sam Lantinga
8cd4f364db Mapped the touchpad click as SDL_CONTROLLER_BUTTON_MISC1 on the PS5 controller 2020-11-12 20:02:31 -08:00
Sam Lantinga
8e312a6a59 Fixed detecting Bluetooth XInput controllers on Windows 2020-11-12 15:56:33 -08:00
Sam Lantinga
8b29aaddbd Fixed warning when building on Windows 2020-11-12 14:34:11 -08:00
Sam Lantinga
e0018d0869 Fixed Windows build 2020-11-12 14:23:56 -08:00
Sam Lantinga
0500c04468 Fix SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL also applying to HIGH priorities
As the name suggests, the hint should only apply to SDL_THREAD_PRIORITY_TIME_CRITICAL

The resulting priorities for my current distro result in these values:

     | High         | Time Critical
Hint |--------------|-----------------
 0   |  P=10 N=-10  | P=5   N=-15
 1   |  P=10 N=-10  | P=-21 N=0
2020-11-12 07:53:05 -08:00
Sam Lantinga
5b0d432942 Implemented trigger rumble in the HIDAPI Xbox One driver 2020-11-12 07:53:03 -08:00
Ozkan Sezer
c122e9b9ce linux/SDL_sysjoystick.c (MaybeRemoveDevice): remove SDL_USE_LIBUDEV guards
fixes bug #5349.
2020-11-12 14:11:50 +03:00
Sam Lantinga
83b653d55d Fixed build warning 2020-11-11 20:09:56 -08:00
Sam Lantinga
76bd6cd2d9 Fixed bug 5326 - Logitech Extreme 3D joystick is listed as gamepad in linux section of SDL_gamecontrollerdb.h
Spooky

For some reason the Logitech Extreme 3D joystick was added to SDL_gamecontrollerdb.h  in the linux section only.

This breaks the joystick in linux as it is not a gamepad.  I am unable to correctly use or map the Logitech Exteme 3D joystick in games that use SDL2 in linux.

Please remove Logitech Extreme 3D from SDL_gamecontrollerdb.h  Linux section.  It is a joystick not a gamepad.
2020-11-11 19:45:56 -08:00
Sam Lantinga
3160c7d66f Fixed bug 5327 - When direct input fails to load, but a controlller is plugged in through another api, an access violation happens.
Bart van der Werf

When directinput fails to load, but a controlller is plugged in, an access violation happens.
This is due to IEventHandler_CRawGameControllerVtbl_InvokeAdded calling SDL_DINPUT_JoystickPresent which does not check if dinput is assigned signalling initialization of directinput.
2020-11-11 19:43:02 -08:00
Sam Lantinga
502cfe314a Fixed bug 5332 - WGI: Fix wrong level of indirection and implicit truncating cast.
Joel Linn

This fixes two types of MSVC compiler warnings.

- One parameter in the function signatures of two WGI event handlers had one level of indirection too much (and did not match Windows SDK headers). The indirection was cast away so it still worked.
- size_t was implicitly cast to UINT32 for a number of (constant) string lengths.
2020-11-11 19:39:46 -08:00
Sam Lantinga
1822f97e5f Fixed bug 5346 - Add FreeBSD evdev KBIO keyboard input driver
wahil1976

This patch adds the KBIO text input driver for FreeBSD, which allows text input to fully work without text spilling out into the console. It also supports accented input, AltGr keys and Alt Lock combinations.

Tested with US accent keys layout and various AltGr layouts.
2020-11-11 19:37:47 -08:00
Sam Lantinga
320a7587d7 Fixed compiler warnings 2020-11-11 19:26:59 -08:00
Simon McVittie
b0eba1c55d joystick: Use inotify to detect joystick unplug if not using udev
This improves SDL's ability to detect joystick hotplug in a container
environment.

We cannot reliably receive events from udev in a container, because they
are delivered as netlink events, which are authenticated by their uid
being 0. However, in a user namespace created by an unprivileged user
(for example bubblewrap, as used by Flatpak and Steam's
pressure-vessel-wrap), the kernel does not allow us to map uid 0, and
the netlink events appear to be from the kernel's overflowuid (typically
65534/nobody), meaning libudev cannot distinguish between genuine uevents
from udevd and an attack by a malicious local user.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:15:32 -08:00
Simon McVittie
aae53d5972 evdev: Detect whether input devices are accelerometers
Anything with X, Y and Z axes but no buttons is probably an
accelerometer (this is the assumption made in udev).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:15:09 -08:00
Simon McVittie
fdd945f2af joystick: Use a better heuristic to guess what is a joystick
Previously we only checked for at least one button or key and at least
the X and Y absolute axes, but this has both false positives and false
negatives.

Graphics tablets, trackpads and touchscreens all have buttons and
absolute X and Y axes, but we don't want to detect those as joysticks.
On normal Linux systems ordinary users do not have access to these
device nodes, but members of the 'input' group do.

Conversely, some game controllers only have digital buttons and no
analogue axes (the Nintendo Wiimote is an example), and some have axes
and no buttons (steering wheels or flight simulator rudders might not
have buttons).

Use the more elaborate heuristic factored out from SDL's udev code path
to handle these cases.

In an ideal world we could use exactly the same heuristic as udev's
input_id builtin, but that isn't under a suitable license for inclusion
in SDL, so we have to use a parallel implementation of something
vaguely similar.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:52 -08:00
Simon McVittie
8db3171b98 udev: Factor out SDL_EVDEV_GuessDeviceClass
This works on capability bitfields that can either come from udev or
from ioctls, so it is equally applicable to both udev and non-udev
input device detection.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:34 -08:00
Simon McVittie
13e7d1a958 joystick: Allow libudev to be disabled at runtime
Device enumeration via libudev can fail in a container for two reasons:

* the netlink protocol between udevd and libudev is considered private,
  so there is no API guarantee that the version of libudev in a container
  will understand netlink messages from a dissimilar version of udevd
  on the host system;
* the netlink protocol between udevd and libudev relies for security on
  being able to check the uid of each message, but in a container with
  a user namespace where host uid 0 is not mapped, the libudev client
  cannot distinguish between messages from host uid 0 and messages from
  a different, malicious user on the host

To make this easier to experiment with, always compile the fallback
code path even if libudev is disabled. libudev remains the default if
enabled at compile time, but the fallback code path can be forced.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-11-11 19:14:11 -08:00
Cameron Gutman
72379ba510 windows: Fix handling of swapped mouse buttons
GetAsyncKeyState() and GetRawInputData() report the state of the physical
buttons without applying the user's primary/secondary mouse button swap
preference. Swap the buttons returned from these functions, so we expose a
consistent view of the buttons to SDL callers. This new behavior also matches
the behavior of macOS and X11 backends.

See the Remarks section of the GetAsyncKeyState() function on MSDN.
2020-08-25 21:22:00 -07:00
Cameron Gutman
771732ed32 windows: Fix numpad arrow key scancodes with numlock off
We should only perform the VK_LEFT, VK_UP, etc. mapping if none of the other
special mappings apply. This allows the scancode normalization for the number
pad to take place as intended.
2020-08-27 17:54:52 -07:00
Sam Lantinga
1e2caac58b Added SDL_JoystickRumbleTriggers() and SDL_GameControllerRumbleTriggers() 2020-11-11 18:57:37 -08:00
John "Nielk1" Klein
067630aef3 Fix hidapi for unhandled DS4 headset microphone data corrupting controller state 2020-11-11 03:47:08 -06:00
Sam Lantinga
b6238c87e4 Don't try to build the RAWINPUT driver if HIDAPI is disabled 2020-11-11 14:48:23 -08:00
Sam Lantinga
d1e10c313e Removed debug output 2020-11-11 14:38:14 -08:00
Sam Lantinga
07eae7d670 Fix process randomly getting killed when SDL_THREAD_PRIORITY_HIGH/TIME_CRITICAL is set
When we request realtime priority from rtkit, we have a rttime limit. If we exceed
that limit, the kernel will send SIGKILL to the process to terminate it.

This isn't something that most high priority processes will want, only processes
that selectively opt into SCHED_RR/FIFO through SDL_HINT_THREAD_PRIORITY_POLICY
should be subject to this level of scrutiny.

This change:
  * Switches non-apple posix OSs to use SCHED_OTHER instead of SCHED_RR
for SDL_THREAD_PRIORITY_HIGH/SDL_THREAD_PRIORITY_TIME_CRITICAL.
  * Fixes using a hardcoded RLIMIT_RTTIME, instead queries it from rtkit
  * Only sets RLIMIT_RTTIME for MakeRealtime rtkit requests
  * Adds a note regarding the possible SIGKILL with SDL_HINT_THREAD_PRIORITY_POLICY
  * Introduces SDL_HINT_THREAD_FORCE_REALTIME_TIME_CRITICAL to allow apps to acquire realtime scheduling policies on Linux
2020-11-11 08:47:18 -08:00
Ozkan Sezer
59795822d0 make SDL_SensorGetDeviceNonPortableType match its prototype. 2020-11-11 12:33:55 +03:00
Ozkan Sezer
53b166797d SIZE_MAX need not be defined in limits.h
it can be in limits.h (windows) or stdint.h.
2020-11-11 12:33:55 +03:00
Sam Lantinga
e12457d8bf Added support for the Xbox Series X controller to the HIDAPI driver 2020-11-10 12:26:30 -08:00
Ryan C. Gordon
7b5a0a9f97 uikit: Don't implement main() twice for iOS static libs.
I think this was a leftover from before the two Xcode projects were merged.
2020-11-10 13:12:10 -05:00
Ryan C. Gordon
940419b0a6 uikit: Fixed a typo in a comment. 2020-11-10 13:09:59 -05:00
Sam Lantinga
c3dea23120 Added support for reading the paddles on a Xbox Elite Series 2 controller in Bluetooth mode 2020-11-09 22:39:33 -08:00
Dylan Fan
02de820008 Add Zhaoxin processor support
CPU Vendor ID "Shanghai" and "CentaurHauls" belongs to Zhaoxin.

Background:
Shanghai Zhaoxin Semiconductor Co., Ltd ("Zhaoxin") , established in 2013,
headquartered in Zhangjiang, Shanghai, China. Zhaoxin aims at providing
general-purpose x86 processors.

Related Zhaoxin Linux Kernel patch can be found at
https://lore.kernel.org/lkml/01042674b2f741b2aed1f797359bdffb@zhaoxin.com
Best regards.
2020-11-09 20:36:35 -08:00
Sam Lantinga
fb4a406af2 Don't put 'm' in the GUID for Xbox and PS4 controllers on iOS 2020-11-09 18:45:22 -08:00
Sam Lantinga
f8b8bd0ba1 ControllerList: recategorize controller as swtich pro and not switch input-only controller 2020-11-09 10:12:02 -08:00
Sam Lantinga
f76ca05729 ControllerList: add unknown xbox controller from minidumps 2020-11-09 10:11:59 -08:00
Sam Lantinga
94924f012b Fix failing to set high priority for threads on Linux desktop.
Debugging inside rtkit showed we were failing the RLIMIT_RTTIME check, now that we're asking for realtime and not just high-priority due to a change in SDL.

Between that and the DBus code in SDL being wrong in previous changelist I'm not sure how this could have ever worked.
2020-11-09 10:11:55 -08:00
Sam Lantinga
abf9dfd5c2 Fix MakeThreadRealtime DBus method call on Linux, type mismatch due to copy paste.
Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32"
Nov 02 20:34:15 redcore rtkit-daemon[2825]: Failed to parse MakeThreadRealtime() method call: Argument 1 is specified to be of type "uint32", but is actually of type "int32"

Docs:

http://git.0pointer.net/rtkit.git/tree/README

CLIENTS:
        To be able to make use of realtime scheduling clients may
        request so with a small D-Bus interface that is accessible on
        the interface org.freedesktop.RealtimeKit1 as object
        /org/freedesktop/RealtimeKit1 on the service
        org.freedesktop.RealtimeKit1:

                void MakeThreadRealtime(u64 thread_id, u32 priority);

                void MakeThreadHighPriority(u64 thread_id, s32 priority);
2020-11-09 10:11:38 -08:00
Sam Lantinga
1577366c36 Fixed duplicated switch statement processing Xbox controller dpad state 2020-11-08 23:49:03 -08:00
Bart van der Werf
3d92e8c742 hidapi: Also parse data[12] with dpad values on the xb1s controller 2020-10-21 10:43:46 -04:00
Sam Lantinga
1ef45c1801 Fixed bug 5339 - Minor memory leak in SDL_x11events.c
wcodelyokoyt

The atom name that X11_GetAtomName() returns never gets freed, which result in a minor memory leak (14 bytes?) every time the user drops a file on a window.
You can see the line in question here:
6b6170caf6/src/video/x11/SDL_x11events.c (L1350)

Fix: call XFree on name after the while loop.
2020-11-08 23:40:17 -08:00
Sam Lantinga
723d76c8ec Fixed bug 5333 - Replace character of legacy code page with utf-8 one.
Joel Linn

This patch fixes a MSVC warning, which is dependent on the regional settings of the build system. Although the character is inside a comment and harmless, it is undesirable to disable the warning for this.
2020-11-08 23:34:59 -08:00
Ryan C. Gordon
0e4ce84801 opengl: Make diagonal lines match the software renderer.
OpenGL leaves the final line segment open, SDL's software renderer does not,
so we need a tiny bit of trigonometry here to move one more pixel in the right
direction.
2020-11-08 20:57:17 -05:00
Ryan C. Gordon
da49f79500 opengles: use glDrawArrays() correctly with GL_LINE_STRIP. 2020-11-08 19:56:12 -05:00
Ryan C. Gordon
de6d0ac55a uikit: Patched to compile on older iOS SDKs. 2020-11-08 18:11:42 -05:00
Ryan C. Gordon
93a2c58c7e opengl: Use GL_LINE_STRIP instead of breaking down into seperate GL_LINES.
Surely GL drivers have improved in the last seven years. I hope...?
2020-11-08 12:37:09 -05:00
Ryan C. Gordon
731a5d1c53 metal: Fix line drawing, again. 2020-11-08 03:18:05 -05:00
Sam Lantinga
4ea1a10bd2 Added stub controller LED functions for WGI and RAWINPUT (thanks meyraud!) 2020-11-07 02:49:22 -08:00
Sam Lantinga
009b62f1c2 Be explicit about mapping the new game controller paddle buttons 2020-11-07 02:22:15 -08:00
Sam Lantinga
749062e72b Implemented SDL_GameControllerSetLED() for iOS/tvOS 2020-11-06 16:53:13 -08:00
Sam Lantinga
faeac6e86c Added additional game controller button support on iOS/tvOS 2020-11-06 16:42:46 -08:00
Sam Lantinga
3a3aaac221 Added 4 auxiliary buttons to the game controller API
Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver
PS4 and PS5 controllers use AUX1 to represent the touchpad button
Nintendo Switch Pro controllers use AUX1 to represent the capture button
2020-11-06 11:30:52 -08:00
Sam Lantinga
a22beef402 Moved the PS5 controller driver to a separate file, as the advanced feature protocol is very different from that of the PS4 2020-11-05 17:03:28 -08:00
Sam Lantinga
bd2dd3f6bb Added Android mapping for the Sony PS5 Controller 2020-11-05 15:36:15 -08:00
Sam Lantinga
4d79f9662f Added initial support for the Sony PS5 Controller 2020-11-05 15:02:54 -08:00
Sam Lantinga
e555d45331 Added SDL_JoystickHasLED
Currently, this is only supported by the PS4 HIDAPI driver.
2020-11-05 11:07:54 -08:00
Ethan Lee
83cddd2ebc Add SDL_JoystickSetLED.
Currently, this is only supported by the PS4 HIDAPI driver.
2020-04-30 11:57:29 -04:00
Ryan C. Gordon
1b8dee7caf coreaudio: Remove unnecessary include of CoreServices.h 2020-10-31 11:32:40 -04:00
Sam Lantinga
ddc0727bba Fixed implicit memcpy() when building for ARM64 on Windows (thanks Seigo!) 2020-10-27 09:00:42 -07:00
Ryan C. Gordon
010d5fba93 kmsdrm: Make this build with significantly older system libraries.
This allows one to build Raspberry Pi versions on an ancient version of
Raspbian and get both the KMSDRM and RPI video targets built into SDL, giving
maximum binary compatibility from linking against an older glibc, etc, but
also making one library that can access video on all RPi models and OS
releases.
2020-10-26 09:49:09 -04:00
Ozkan Sezer
f0c5841714 SDL_shape_internals.h: forward-declare struct SDL_ShapeTree. 2020-10-25 10:10:10 +03:00
Ozkan Sezer
a4040293dd os2: misc build fixes 2020-10-25 10:10:02 +03:00
Ozkan Sezer
bfc80d83c2 minor coding style cleanup 2020-10-25 03:55:02 +03:00
Ryan C. Gordon
ba36eb0437 metal: Make line drawing match software renderer.
Partially fixes Bugzilla #2711.
2020-10-21 00:03:33 -04:00
Ryan C. Gordon
c33f808354 render: Restoring line rendering fixes that were previously put on hold.
(Backed out hg changeset 7a4240daba46)
2020-10-20 11:12:49 -04:00
Sam Lantinga
5dc6c3c951 Updated Vulkan headers to version 1.2.158
https://github.com/KhronosGroup/Vulkan-Headers
2020-10-24 10:46:18 -07:00
Manuel Alfayate Corchete
5682b066e9 kmsdrm: Add comment about KMSDRM_VideoQuit() changes. 2020-10-22 19:51:57 +02:00
Manuel Alfayate Corchete
63b7827709 kmsdrm: properly exit with an error when ATOMIC interface is not yet available, instead of just segfaulting. 2020-10-22 19:44:38 +02:00
Manuel Alfayate Corchete
a3262205b5 kmsdrm: rearrange init function so we try ATOMIC compatibility first. 2020-10-22 17:55:45 +02:00
Manuel Alfayate Corchete
b1ea0be865 kmsdrm: Add missing checks after SDL_calloc() calls. 2020-10-22 17:06:34 +02:00
Manuel Alfayate Corchete
ad9ec8b363 kmsdrm: Small fix, missing bracket. 2020-10-22 16:15:34 +02:00
Manuel Alfayate Corchete
87a86675ed kmsdrm: Always use spaces for indentation. Always use SDL_calloc() for calloc. 2020-10-22 16:01:51 +02:00
Ozkan Sezer
cfc1362011 os2 video: updates to my_gradd.h 2020-10-21 23:28:02 +03:00
Sam Lantinga
f1b603ac6a Fixed bug 5323 - SDL_SetWindowMaximumSize fails if Width or Height is equal to minimum Height or Width
batyastudios

Basicly there is problem and somewhat a solution: https://discourse.libsdl.org/t/setwindowmaximumsize-bug/28267

If you SDL_SetWindowMaximumSize() after SDL_SetWindowMinimumSize() with one of axes have the same value, function will have no effect.

This: (line 2144@SDL_video.c)
if (max_w <= window->min_w || max_h <= window->min_h) {
    SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
    return;
}

May be changed to this:
if (max_w < window->min_w || max_h < window->min_h) {
    SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size");
    return;
}
2020-10-20 11:51:23 -07:00
Ozkan Sezer
cbadd1e380 geniconv/os2iconv.c: make it build correctly against os2tk headers. 2020-10-20 20:32:20 +03:00
Manuel V?gele
554037a6f7 audio: fix popping sounds caused by signed/unsigned conversion
When converting audio from signed to unsigned values of vice-versa
the silence value chosen by SDL was the value of the device, not
of the stream that the data was being put into. After conversion
this would lead to a very high or low value, making the speaker
jump to a extreme positon, leading to an audible noise whenever
creating, destroying or playing scilence on a device that reqired
such conversion.
2020-09-26 09:30:08 +02:00
Sam Lantinga
f311e0a826 Removed debug log message 2020-10-19 17:29:16 -07:00
Yiding Jia
f31ad57fde Implement keyboard repeat in wayland video driver 2020-10-05 19:17:52 -07:00
Alberts Muktup?vels
73010da4dc x11events: ignore UnmapNotify events from XReparentWindow
UnmapNotify event does not mean that window has been iconified. It
just reports that window changed state from mapped to unmapped.

XReparentWindow can unmap and remap window if it was mapped. This
causes unnecessary events - HIDDEN, MINIMIZED, RESTORED and SHOW.

These events are problematic with Metacity 3.36+ which started to
remove window decorations from fullscreen windows.

- SDL makes decorated window fullscreen
- Metacity removes decorations
- SDL gets UnmapNotify and exits from fullscreen
- Metacity re-adds decorations

As SDL will also get MapNotify event it will try to restore
window state causing above steps to repeat.

https://bugzilla.libsdl.org/show_bug.cgi?id=5314
2020-10-19 17:26:33 -07:00
Sylvain Becker
ffb307e4dc Fixed bug 5304 - add SDL_HasSurfaceRLE() (Thanks Rene Dudfield and Dan Lawrence) 2020-10-18 09:52:56 +02:00
Sylvain Becker
19a65a46a6 Fixed bug 5321 - crash in SDL_ConvertSurface with RLE surfaces
keep RLE information in flags when converting the surface
2020-10-17 21:47:05 +02:00
Ozkan Sezer
c70191d2b7 SDL_os2video.c (OS2_CreateDevice): remove duplicated assignment. 2020-10-17 07:37:00 +03:00
Ozkan Sezer
77d0f043e5 os2video.c: add missing FOURCC_R666 define, enable FOURCC_R666 case in _getSDLPixelFormatData(). 2020-10-16 23:50:00 +03:00
Sam Lantinga
99ed0d7ab9 Map the guide button by default on Android 11 2020-10-16 12:40:12 -07:00
Sam Lantinga
3755f6920f Added mapping for Xbox One S controller and PS4 controller on Android 11, including guide button 2020-10-16 12:40:10 -07:00
Sam Lantinga
58976bda31 Allow more than one window on iOS as long as they're on different displays 2020-10-15 12:00:15 -07:00
Ozkan Sezer
a90f0400a5 os2: a _lot_ of coding style cleanup, sot that they match the SDL style.
also renamed the 'debug' macro to debug_os2: the former was dangerously
a common name.

the binary (dll) output is precisely the same as before.
2020-10-15 21:37:30 +03:00
Sam Lantinga
bdc5129f13 Use a high priority dispatch queue for GCKeyboard and GCMouse events for the lowest latency possible
This appears to reduce latency between 1-4 ms on an iPad Pro.
2020-10-15 10:13:46 -07:00
Sam Lantinga
a3a0ef7527 Added support for low latency mouse and keyboard handling in iOS 14
The mouse support in iOS 14.0 has a bug with accumulating duplicate mouse deltas that won't be fixed until iOS 14.1, so we don't enable it until then.
2020-10-15 10:13:44 -07:00
Sam Lantinga
d9aea0c3a0 Update the existing haptic player when we rumble on iOS 2020-10-15 10:13:42 -07:00
Manuel Alfayate Corchete
cca16c9cb1 kmsdrm: merge GetDisplayDPI implementation by bms20 <brett@mynah-software.com> 2020-10-15 17:56:19 +02:00
Ozkan Sezer
d27238751f os2: integrate the port into main tree. 2020-10-14 23:01:06 +03:00
Ozkan Sezer
5807cb3d31 os2: remove dependency to gradd.h from IBM's ddk which is non-free:
Add a minimal my_gradd.h containing structures and constants only used
by SDL_os2vman.c -- based on public knowledge from around the internet
including pages from http://www.osfree.org and http://www.edm2.com .
2020-10-14 23:01:06 +03:00
Ozkan Sezer
b6965a1774 os2: Andrey Vasilkin agreed that his code to be put under Zlib license:
add SDL license headers to geniconv sources.
2020-10-14 23:01:05 +03:00
Ozkan Sezer
1d9cf23e4c os2: updated copyright dates for 2020. header guard fixes. 2020-10-14 23:01:05 +03:00
Ozkan Sezer
a3d7913c07 SDL_os2audio.c (OS2_OpenDevice): change spec->samples assignment:
Original code assigned MCIMixSetup.ulSamplesPerSec value to it, but it
is just the freq... We now change spec->samples only either if it is 0
or we changed the frequency, by picking a default of ~46 ms at desired
frequency (code taken from SDL_audio.c:prepare_audiospec()).

With this, the crashes I have been experiencing are gone.
2020-10-14 23:01:05 +03:00
Ozkan Sezer
e112b776fc SDL_os2audio.c (OS2_OpenDevice): change {0} initializers to SDL_zero() 2020-10-14 23:01:05 +03:00
Ozkan Sezer
72594e255a SDL_os2audio.c (OS2_OpenDevice): remove assignment to wrong spec member
Correct assignment to 'format' member is done below, already.
2020-10-14 23:01:04 +03:00
Ozkan Sezer
fe2cc8d86c OS2_VideoQuit(): avoid double free()ing of displays.
Our caller SDL_VideoQuit() already frees display_modes, driverdata, etc.
Noticed in bitwiseworks' version at https://github.com/bitwiseworks/SDL2-os2
2020-10-14 23:01:04 +03:00
Ozkan Sezer
fba32ee21f OS2_VideoInit: zero the stSDLDisplay and stSDLDisplayMode variables
Fixes testdisplayinfo.exe crashing in SDL2-2.0.13.  (How it did work before?..)
2020-10-14 23:01:04 +03:00
Ozkan Sezer
54ced668c4 port from 2.0.12 to 2.0.13 / current SDL-hg repository.
- video:  VideoBootStrap->available() is gone.
- thread: all important SDL_CreateThread internal data now put into
          struct SDL_Thread: changes to SDL_SYS_CreateThread().
2020-10-14 23:01:04 +03:00
Ozkan Sezer
5da796fe52 os/2: port from SDL2-2.0.5 to SDL2-2.0.12
- events / video: SDL_SetDoubleClickTime() removed -- functionality
         moved to SDL_mouse.c:SDL_MouseDoubleClickTimeChanged().
- video: struct SDL_VideoDevice-> CreateWindow and CreateWindowFrom
         members renamed to CreateSDLWindow and CreateSDLWindowFrom
2020-10-14 23:01:03 +03:00
Ozkan Sezer
5d89217f6b os2/SDL_sysfilesystem.c: fix crash if one of the parameters is NULL
Has been happening with testfilesystem from 2.0.6 and newer because
of commit 572a721879ef.

Also set error strings in certain error conditions.

Also applied coding style / whitespace fixes, while I was there.
2020-10-14 23:01:03 +03:00
Ozkan Sezer
222f026899 os/2: port from SDL2-2.0.4 to SDL2-2.0.5:
changes to SDL_os2audio.c, SDL_os2video.c, os2/SDL_systhread.c in order
to accomodate SDL2-2.0.5 changes.
- audio:  WaitDone() is gone, CloseDevice() interface changes.
- events / video:  DropFile() changes:
          SDL_DROPBEGIN and SDL_DROPCOMPLETE events, window IDs for drops.
- thread: struct SDL_Thread->stacksize
2020-10-14 23:01:03 +03:00
Ozkan Sezer
5f3f67b16b os2/SDL_sysfilesystem.c: use OS/2 api DosCreateDir() instead of mkdir().
mkdir() from watcom and emx differ - the latter being unix-ish, so this
change avoids ifdefs.
2020-10-14 23:01:03 +03:00
Ozkan Sezer
1b99d805db os2: updates from Andrey Vasilkin's 2020-09-07 sources. 2020-10-14 23:01:02 +03:00
Ozkan Sezer
aa790837eb os2: several warning fixes.
mostly those "W007: '&array' may not produce intended result" warnings
from Watcom, visible only in C++ mode.  one or two others here & there.
2020-10-14 23:01:02 +03:00
Ozkan Sezer
f9af19f51d os2: updates to SDL_systhread.c:
removed lots of garbage.  added SDL_PASSED_BEGINTHREAD_ENDTHREAD guard,
because the code requires it.
2020-10-14 23:01:02 +03:00
Ozkan Sezer
c218861946 os2: added a 2-byte padding to os2 SDL_PrivateAudioData 2020-10-14 23:01:01 +03:00
Ozkan Sezer
d1323eb0a9 os2: better error reporting from loadso 2020-10-14 23:01:01 +03:00
Ozkan Sezer
861ac81b37 os2: changes to debug macros 2020-10-14 23:01:01 +03:00
Ozkan Sezer
110a0f7bb1 os2: update include paths. add missing libc includes to geniconv. 2020-10-14 23:01:01 +03:00
Ozkan Sezer
74cfb81dbb os2: add port files for SDL2-2.0.4 from Andrey Vasilkin
only geniconv/iconv.h (was from LGPL libiconv) is replaced with a generic
minimal iconv.h based on public knowledge.
2020-10-14 23:01:00 +03:00
Ozkan Sezer
93e1449764 SDL_waylanddatamanager.c (mime_data_list_add): constify the buffer param
Fixes -Wdiscarded-qualifiers warnings from Wayland_data_source_add_data()
2020-10-14 15:50:04 +03:00
Sam Lantinga
b9cbea354f video: Refresh Windows display list on WM_DISPLAYCHANGE
- Displays may have been added, removed or changed and all cached monitor
  handles are invalidated as a result.

- Display events are handled in three steps:
  1. Mark all currently know displays as invalid
  2. Enumerate all displays, adding new ones and marking known displays as valid
  3. Remove all displays still invalid after enumeration

- Display connect/disconnect events are sent when displays are added or removed
  after initial setup
2020-10-13 21:08:20 -07:00
Sam Lantinga
a558409b2e Only include CoreHaptics if we're building with rumble support 2020-10-13 21:08:18 -07:00
Sam Lantinga
75d5be974c Fixed compiling with an older iOS SDK 2020-10-13 21:08:17 -07:00
Sam Lantinga
6b62494ee4 Added support for controller battery status on iOS 14 2020-10-13 21:08:15 -07:00
Sam Lantinga
1b31e9f6dc Added support for game controller rumble on iOS 14 2020-10-13 21:08:13 -07:00
Sam Lantinga
2d7b33cb41 Added support for the controller home button on iOS 14 2020-10-13 21:08:11 -07:00
Cameron Cawley
59022829f4 riscos: Implement SDL_OpenURL() 2020-10-11 17:32:32 +01:00
Ozkan Sezer
34a82fca49 SDL_cpuinfo.c (OS2): undefine HAVE_SYSCTLBYNAME 2020-10-10 20:50:02 +03:00
Sam Lantinga
b546db2f85 Only watch for display connect/disconnect events while the video subsystem is initialized 2020-10-09 12:58:28 -07:00
Ozkan Sezer
7991cc38bc dynapi: move SDL_SIMDRealloc down below, after SDL_GetPreferredLocales.
https://hg.libsdl.org/SDL/rev/884cb29cb80e  wrongly added it after its
family i.e. SDL_SIMDAlloc, not at the end of the list.
2020-10-09 21:40:28 +03:00
Ryan C. Gordon
b79832ba11 cocoa: Cut and paste from HTML strikes again! 2020-10-08 21:11:09 -04:00
Ozkan Sezer
19aaa2944d Fix https://bugzilla.libsdl.org/show_bug.cgi?id=5306
(Also see: https://bugzilla.libsdl.org/show_bug.cgi?id=4822)

Building the current tree against 10.8 SDK, clang emits the following warning:
src/video/cocoa/SDL_cocoawindow.m:1846:27: warning: instance method '-isOperatingSystemAtLeastVersion:' not found (return type defaults to 'id') [-Wobjc-method-access]
            ![processInfo isOperatingSystemAtLeastVersion:version]) {
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/MacOSX10.8.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSProcessInfo.h:20:12: note: receiver is instance of class declared here
@interface NSProcessInfo : NSObject {
           ^
1 warning generated.

isOperatingSystemAtLeastVersion is an 10.10 thing.
2020-10-09 04:00:00 +03:00
Ozkan Sezer
69fbd60d25 Fix https://bugzilla.libsdl.org/show_bug.cgi?id=4877#c2
loadNibNamed:owner:topLevelObjects is available on 10.8 and newer.
There is an issue report here about an app failing to function on
10.7 and earlier: https://discourse.libsdl.org/t/28179
2020-10-09 04:00:00 +03:00
Sam Lantinga
bd14f2676c Removed unused variable 2020-10-08 16:58:34 -07:00
Ozkan Sezer
d86a746542 SDL_video.c: fix whitespace 2020-10-09 02:55:00 +03:00
Sam Lantinga
76980e30f2 Added events for dynamically connecting and disconnecting displays, with an iOS implementation 2020-10-08 16:42:20 -07:00
Sam Lantinga
cd703b5628 Fixed whitespace 2020-10-08 16:41:48 -07:00
Ozkan Sezer
54bb9aaccb k_rem_pio2.c: fix typo in second memset(): iq, not q. fixes bug #5309. 2020-10-08 11:51:02 +03:00
Ryan C. Gordon
061256a3b3 metal: Clear the framebuffer if presenting without any other operations. 2020-10-07 14:45:24 -04:00
Ryan C. Gordon
003a16980c wav: Make sure the data size is a multiple of blockalign, not an exact match.
I _think_ this is a right thing to do; it fixes a .wav file I have here that
has blockalign==2 when channels==2 and bitspersample==16, which otherwise
would fail.
2020-10-06 11:07:50 -04:00
Ryan C. Gordon
4627426994 url: WinRT actually works now (and has been tested, hooray!). 2020-10-06 00:42:17 -04:00
Ryan C. Gordon
fc05a696ad url: Attempt #23235 at WinRT support... 2020-10-05 18:08:58 -04:00
Ryan C. Gordon
02addf135d url: Another attempt at WinRT implementation. 2020-10-05 18:01:47 -04:00
Ozkan Sezer
1f4b5d54ca windows/SDL_syslocale.c: make it build against older SDKs. 2020-10-06 00:20:20 +03:00
Ryan C. Gordon
7bec9df11a url: Add to Xcode project files, iOS/mac fixes. 2020-10-05 16:10:10 -04:00
Ryan C. Gordon
57e3003d3f url: Attempt at WinRT support. 2020-10-05 15:47:47 -04:00
Ryan C. Gordon
566479c8ef url: ShellExecuteW returns an HINSTANCE, so deal with that more correctly. 2020-10-05 15:37:37 -04:00
Ryan C. Gordon
ee56090d3d url: Cleanups and compiler warning fixes. 2020-10-05 15:03:44 -04:00
Ryan C. Gordon
cc158f2983 url: removed "extern" from function declaration. 2020-10-05 14:36:37 -04:00
Ryan C. Gordon
a3802cc533 url: Patched to compile on C89 compilers. 2020-10-05 14:30:33 -04:00
Ryan C. Gordon
0099e38a9a url: More win32 fixes. 2020-10-05 14:21:03 -04:00
Ryan C. Gordon
1f4fecc5c1 url: Patched to compile on Windows. 2020-10-05 14:07:32 -04:00
Ryan C. Gordon
777d0f19f8 url: patched to compile on macOS. 2020-10-05 14:06:25 -04:00
Ryan C. Gordon
d068d05aa5 url: Make sure Haiku's C++ implementation is flagged as 'extern "C"' 2020-10-05 14:01:08 -04:00
Ryan C. Gordon
bf9fcb539a url: The function is "SDL_Unsupported" not "SDL_Unimplemented" 2020-10-05 14:00:08 -04:00
Ryan C. Gordon
2d82cf78e1 url: put the Android bits in core/android 2020-10-05 13:59:03 -04:00
Ryan C. Gordon
efd665e2c7 Backed out changeset a43cb4e54949
Trying this a different way.
2020-10-05 13:56:45 -04:00
Ryan C. Gordon
913aa610b5 url: Include SDL_misc.h to get public function declaration. 2020-10-05 13:53:15 -04:00
Ryan C. Gordon
5f68812249 url: patched to compile on Android. 2020-10-05 13:52:52 -04:00
Ryan C. Gordon
84f1b95008 url: fixed wrong include. 2020-10-05 13:39:39 -04:00
Ryan C. Gordon
77c9d73b63 Removed SDL_AndroidOpenURL, added SDL_OpenURL.
Still needs to be wired into Xcode and Visual Studio projects.
2020-10-05 11:30:33 -04:00
Sylvain Becker
cd6670bff3 SDL_Surface refcount: fix memory leak when blitting between stack'ed surfaces
(see bug 5226)
2020-10-02 10:48:27 +02:00
Ozkan Sezer
883509fc84 ran gendynapi.pl after new (android-only) api additions. 2020-10-01 17:01:00 +03:00
Sylvain Becker
dd55bfe89c Android: add helper function to open an URL/URI (see bug 2783) 2020-10-01 14:41:09 +02:00
Sam Lantinga
45c644cc99 Added support for the MOGA XP5-X Plus 2020-09-28 21:19:45 -07:00
Manuel Alfayate Corchete
78c274cb5d kmsdrm: merge patches from Ozkan Sezer for removing c-99'isms and raising libgbm version reqeriments. 2020-09-26 19:18:09 +02:00
Sylvain Becker
955f3184f9 Fixed bug 5239 - Play audio on Android while backgrounded (Thanks Superfury)
Add hint SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO not to pause audio when
the app goes to background.
(It requires SDL_ANDROID_BLOCK_ON_PAUSE as "Non blocking")
2020-09-25 10:14:42 +02:00
Ryan C. Gordon
7ef188a1fb jack: Fixed memory leak on device close. 2020-09-19 14:01:57 -04:00
Cameron Gutman
9a769da04a X11: Remove our X11 error callback in X11_DeleteDevice()
If we don't remove it, we will infinitely recurse if X11_CreateDevice() is
called again and orig_x11_errhandler becomes X11_SafetyNetErrHandler().
2020-09-07 20:10:50 -07:00
Manuel Alfayate Corchete
9c342e76dd kmsdrm: merge heap buffer overflow and cursor creation patches from meyraud705. 2020-09-13 21:41:10 +02:00
Manuel Alfayate Corchete
0cb9bfa502 kmsdrm: less excessive error checkhing 2020-09-12 15:58:47 +02:00
Manuel Alfayate Corchete
5bed30dd61 kmsdrm: also do pending modeseting in SwapWindowDoubleBuffered(). 2020-09-12 04:56:55 +02:00
Manuel Alfayate Corchete
9e9227add3 kmsdrm: reimplement modesetting for fullscreen window scaling and AR-correction. 2020-09-12 04:52:56 +02:00
Manuel Alfayate Corchete
4575c6942a kmsdrm: delete ununsed variable. 2020-09-12 02:36:02 +02:00
Manuel Alfayate Corchete
01b0cf1c90 Backed out changeset 4a45d1a30d25
kmsdrm: Fake KMSDRM_SetDisplayMode() is needed for some programs after all.
2020-09-12 00:47:00 +02:00
Manuel Alfayate Corchete
7b67654872 kmsdrm: don't fool SDL into thinking that changing the physical videomode is done. 2020-09-12 00:16:08 +02:00
Manuel Alfayate Corchete
a6d182d326 kmsdrm: no need to reconnect/reactivate things in SwapWindowDoubleBuffered(). 2020-09-11 23:47:26 +02:00
Manuel Alfayate Corchete
47e2d0304e kmsdrm: greatly improve comments in SwapBuffersFenced() for future reference. 2020-09-10 23:26:02 +02:00
Ryan C. Gordon
3c6004feb7 kmsdrm: Choose how to swap buffers based on EGL extension availability. 2020-09-10 15:07:23 -04:00
Ryan C. Gordon
c7e761f872 kmsdrm: Patched to compile if EGL headers lack EGL_ANDROID_native_fence_sync. 2020-09-10 15:05:55 -04:00
Ryan C. Gordon
224aa45b59 kmsdrm: Implement GL_DefaultProfileConfig for Raspberry Pi compatibility.
If we think this might be a Raspberry Pi device, default to ES2. Otherwise,
accept SDL's higher-level defaults.
2020-09-10 15:04:35 -04:00
Ryan C. Gordon
092162ede7 video: Set up default before calling GL_DefaultProfileConfig().
This way, the implementation can opt to do nothing to accept SDL's defaults.
2020-09-10 15:02:51 -04:00
Ryan C. Gordon
e758dd53dc egl: Make SDL_EGL_HasExtension() available outside of SDL_egl.c. 2020-09-10 15:02:00 -04:00
Manuel Alfayate Corchete
055cad49b6 kmsdrm: no need to re-connect/reactivate things in SwapWindow() anymore because we use a dumb buffer on KMS buffers destruction now. 2020-09-10 02:15:53 +02:00
Manuel Alfayate Corchete
351219bfd8 kmsdrm: On VideoQuit(), only destroy dumb buffer if it exists. 2020-09-09 03:18:26 +02:00
Sam Lantinga
8709f67ebc Fixed bug 5215 - Fixing filenames passed to dlopen for OpenBSD
Brad Smith

Attached is a patch to use the proper filenames when trying to dlopen the respective shared libraries on OpenBSD.
2020-09-08 08:42:30 -07:00
Cameron Gutman
1b6de9a987 Fix SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH=1 on Metal windows
SDL_cocoametalview was consuming the first click rather than passing it
through to the SDLView underneath which overrides [NSView acceptsFirstMouse]
based on the user's SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH preference.
2020-09-05 15:01:45 -07:00
Manuel Alfayate Corchete
244d0ad854 kmsdrm: Tell SDL that mouse has entered the window via artificial event. Fixes sticky mouse in Scummvm. 2020-09-08 15:30:45 +02:00
Manuel Alfayate Corchete
550e153365 kmsdrm: No need to test for display driverdata when freeing a plane. 2020-09-08 02:42:32 +02:00
Manuel Alfayate Corchete
6e03fab982 kmsdrm: add temporary RPI4_COMPAT define to try RPI4+current Rasbian compatibility. 2020-09-07 23:15:33 +02:00
Manuel Alfayate Corchete
0f807fd607 kmsdrm: use a black dumb buffer for keeping the PRIMARY PLANE occupied when we destroy the KMS buffers, instead of using the TTY buffer, to avoid flickering. 2020-09-07 22:54:15 +02:00
Sylvain Becker
4d1c2a1857 Fix false compiler warning: initialize the variable 'memdiff' 2020-09-07 19:00:21 +02:00
Sylvain Becker
ebc12a2fd2 SDL_Surface refcount: destination surface keep track of surfaces
that are mapped to it and automatically invalidate them when it is freed

- refcount is kept so that an external application can still create a reference
to SDL_Surface.

- lock_data was un-used and is now renamed and used as a list keep track of the blitmap
2020-09-07 18:50:30 +02:00
Manuel Alfayate Corchete
cce6c60518 kmsdrm: fix errors when trying to free up videomode driverdata pointers on quit. 2020-09-07 01:33:04 +02:00
Manuel Alfayate Corchete
9501b1c698 kmsdrm: fix scaling for SDL_WINDOW_FULLSCREEN windows. 2020-09-07 00:18:13 +02:00
Manuel Alfayate Corchete
daa752b10e kmsdrm: fix first frame display: no need to wait for SwapWindow() for EGL surface creation. 2020-09-06 23:19:54 +02:00
Manuel Alfayate Corchete
68ac9349aa kmsdrm: more coherent returns for SwapWindow. 2020-09-06 12:48:39 +02:00
Manuel Alfayate Corchete
d3d9d432ac kmsdrm: Remove debug printfs in SwapWindow. 2020-09-06 12:17:27 +02:00
Manuel Alfayate Corchete
d7aebbd58f kmsdrm: Don't create surfaces until EGL context is available. 2020-09-06 12:08:22 +02:00
Sylvain Becker
97fad04551 Fixed bug 5278 - export SDL_AndroidRequestPermission() (Thanks Huki!) 2020-09-02 19:38:03 +02:00
Manuel Alfayate Corchete
f4e02a5c1b kmsdrm: Do NOT modify window size manually from the backend: doing so caused renderer scaling params miscalculation. 2020-08-31 19:17:17 +02:00
Manuel Alfayate Corchete
c09d1cee95 kmsdrm: Apply window reconfiguration in SetWindowSize(), too. 2020-08-28 23:04:00 +02:00
Manuel Alfayate Corchete
31b1794534 kmsdrm: use PLANE and CRTC to do hardware-driven window scaling and AR-correction. 2020-08-28 22:38:26 +02:00
Manuel Alfayate Corchete
fe3f97961b kmsdrm: unload EGL and GL lib only if using them. 2020-08-26 01:37:30 +02:00
Manuel Alfayate Corchete
9b43464d81 kmsdrm: Add programmer credits to the Atomic KMSDRM driver. 2020-08-25 16:30:23 +02:00
Manuel Alfayate Corchete
9316a8d979 kmsdrm: move FENCE FD props setting to SwapWindow(), where it belongs. 2020-08-25 16:18:49 +02:00
Manuel Alfayate Corchete
3f38009b2f kmsdrm: comment out atomic commit fast-debugging printf. 2020-08-25 15:40:36 +02:00
Manuel Alfayate Corchete
0d16761cbe kmsdrm: fix segfault on quit beacuse of freed _this->egl_data. 2020-08-25 05:53:13 +02:00
Manuel Alfayate Corchete
d43e666eed kmsdrm: Buffer management refactoring. Fixes for compatibility with more video drivers. 2020-08-25 04:05:36 +02:00
Manuel Alfayate Corchete
eade05ca03 kmsdrm: Finetune integer type usage. Add some comments. 2020-08-24 12:51:20 +02:00
Manuel Alfayate Corchete
a76f176361 kmsdrm: Move cursor plane setup and freeing to MouseInit() and MouseQuit(), for better consistency. 2020-08-24 01:10:11 +02:00
Manuel Alfayate Corchete
0d593d7ead kmsdrm: Add error control to plane prop setting function. Do most plane prop setting with a single function. 2020-08-23 23:44:07 +02:00
Manuel Alfayate Corchete
e06e9c35c8 kmsdrm: move cursor-related atomic helper functions and related struct typedefs to the SDL_kmsdrmmouse unit. 2020-08-23 11:26:55 +02:00
Manuel Alfayate Corchete
0b7b7721b9 kmsdrm: remove redundant function, use drm_atomic_setbuffers() for disconnecting planes instead. 2020-08-23 03:13:50 +02:00
Manuel Alfayate Corchete
16c04f266a kmsdrm: Init cursor surface on SetCursor() ONLY. Removal of dynamic modeset because it causes A LOT of problems with some kernel video drivers. Some refactoring and cleanups. 2020-08-23 02:58:57 +02:00
Manuel Alfayate Corchete
0d0ba111ae kmsdrm: correct parameter name. 2020-08-19 01:34:56 +02:00
Manuel Alfayate Corchete
5d32eda956 kmsdrm: implement smarter surface recreation function to be used in videomode changes. Other minor arrangements. 2020-08-19 01:31:22 +02:00
Manuel Alfayate Corchete
f79da81721 kmsdrm: free all connector, crtc and plane memory on KMSDRM_VideoQuit(). 2020-08-18 01:52:15 +02:00
Sylvain Becker
965b466ee8 Fixed bug 4297 - Android StrictMode policy. Remove APK expansion support
"In the second half of 2021, new apps will be required to publish with the Android App Bundle on Google Play"
(see https://developer.android.com/guide/app-bundle)
And "Android App Bundles don't support APK expansion (*.obb) files".
2020-08-17 19:50:20 +02:00
Manuel Alfayate Corchete
92cb9192e3 kmsdrm: move hardware cursor functionality to the ATOMIC interface. Disconnect the display plane from the GBM surface buffers before destroying the GBM surface. 2020-08-17 18:35:04 +02:00
Kai Krakow
c3ecf18cc4 Linux: Add hint for disabling deadzones 2020-07-21 23:38:42 +02:00
Tudor Brindus
c094332825 wayland: defer pointer confine creation until pointer unlock
It is a protocol error to attempt to create a pointer confine (i.e.
`SDL_SetWindowGrab`) while a locked pointer is active, and vice-versa.
Instead of aborting due to a protocol error, this commit makes SDL
gracefully downgrade locked pointers to confines when appropriate.
2020-07-21 13:14:24 -04:00
Ryan C. Gordon
a720d1a294 render: fixes to how we convert touch events for logical scaling.
We now handle HiDPI correctly, and touches are clamped to the viewport. So
if you are rendering to a logical 640x480 in a 720p window, and touch the
letterboxing at point (640,700), it will report the touch at (0.5,1.0) instead
of outside the documented range.
2020-08-09 00:55:39 -04:00
Manuel Alfayate Corchete
c437729b21 kmsdrm: separate requests in different functions so we only need one atomic commit for everything, as expected by atomic design. 2020-08-08 14:27:55 +02:00
Manuel Alfayate Corchete
3b9f1073c6 kmsdrm: wait for possible pending atomic commits before destroying surfaces, and before restoring video on quit. Move messages to the SDL_Log* functions. 2020-08-07 11:53:04 +02:00
Manuel Alfayate Corchete
96c99693a2 kmsdrm: wait for pending atomic commits before restoring videomode and crtc->buffer on VideoQuit, and simplify double-buffer SwapWindow() implementation. 2020-08-06 01:36:56 +02:00
Manuel Alfayate Corchete
09692b6170 kmsdrm: move videomode restoration on VideoQuit() to using the atomic interface instead of the legacy drmModeSetCrtc() function. Refactoring of get_plane_id(). 2020-08-05 18:55:22 +02:00
Manuel Alfayate Corchete
fc722b2d21 kmsdrm: free memory for plane, crtc and connector property tables on VideoQuit. 2020-08-05 15:28:51 +02:00
Manuel Alfayate Corchete
2d69ce08ba kmsdrm: double and triple buffered versions of SwapWindow() are now both reimplemented in atomic pageflipping versions, and can be selected via SDL_VIDEO_DOUBLE_BUFFER env variable. 2020-08-05 02:06:59 +02:00
Manuel Alfayate Corchete
8996ee1786 kmsdrm: update SwapWindow fn, moving it to triple-buffer. 2020-08-03 22:24:49 +02:00
Ryan C. Gordon
ea171c0564 winrt: Another attempt at getting this to compile.
IntPtr isn't a POD type like I thought, so hopefully we can just construct
one that works out? C++/CX is so weird.
2020-08-01 18:58:42 -04:00
Manuel Alfayate Corchete
b131661c6d kmsdrm: rewrite the new SwapWindow() fn to avoid tearing. Double-buffer only for now. 2020-08-01 18:23:34 +02:00
Ryan C. Gordon
282e4c65bf winrt: Patched to compile...?
Microsoft's C++/CX is weird, no idea if this will actually fix it.  :/
2020-07-31 19:42:23 -04:00
Manuel Alfayate Corchete
1a5503ce9f kmsdrm: Moved to the ATOMIC KMS/DRM interface for buffer swapping, leaving DRM-legacy behind. 2020-07-28 21:11:25 +02:00
Ryan C. Gordon
e410b34f92 stdlib: Corrected implementation of SDL_wcsncmp.
It was a copy/paste of SDL_strcmp, apparently, not SDL_strncmp, so it ignored
the maxlen parameter.

Thanks to Jack Powell for pointing this out!
2020-07-24 22:24:03 -04:00
RALOVICH, Kristof
c7eb557d89 kmsdrm: do not leak drmModeConnector
Previously conn was leaked on the success path (when available was
set to SDL_TRUE).
2020-07-20 10:09:07 -07:00
Manuel Alfayate Corchete
412b21b0e8 Rename the gbm device struct from gbm to gbm_dev for better readabilty. 2020-07-20 11:42:23 +02:00
RALOVICH, Kristof
155fdc7ac0 kmsdrm: settle with first card that has a connected connector
Previously the first card with non-empty connectors, encoders
and crtcs would be selected, however KMSDRM_VideoInit could still reject
it if the connector was not connected. This allow finding the first card
(in a multi GPU setup) that is actually connected to a display.
2020-07-19 21:48:17 -04:00
RALOVICH, Kristof
b78b88f7fb kmsdrm: fix typo 2020-07-19 21:46:41 -04:00
Manuel Alfayate Corchete
75fe4b14e3 Added comment about window creation behaviour in KMSDRM. 2020-07-19 19:53:57 +02:00
Manuel Alfayate Corchete
2f660c4fdd Delete windata variable no longer needed in KMSDR_SetDisplayMode(). 2020-07-19 19:11:02 +02:00
Manuel Alfayate Corchete
3a1d7d9c9a Surfaces have to be recreated immediately from KMSDRM_SetDisplayMode(). 2020-07-19 19:09:15 +02:00
Manuel Alfayate Corchete
b6a818b6a2 Fix SDL_Window recreation: drmModeSetCrtc() has to be called everytime the EGL and GBM surfaces are recreated. 2020-07-19 18:45:29 +02:00
Sam Lantinga
71e9df99c7 Fixed bug 5231 - Fix for hardware cursor: size and alpha-premultiplication.
Manuel Alfayate Corchete

I noticed pt2-clone had problems with it's optional hardware mouse on the KMSDRM backend: cursor had a transparent block around it.
So I was investigating and it seems that a GBM cursor needs it's pixels to be alpha-premultiplied instead of straight-alpha.
A
lso, I was previously relying on "manual testing" for the cursor size, but it's far better to use whatever the DRM driver recommends via drmGetCap(): any working driver should make a size recommendation via drmGetCap(), so that's what we use now. I took this decision because I found out that the AMDGPU driver reported working cursor sizes that would appear garbled on screen, and only the recommended cursor size works.
2020-07-19 08:55:01 -07:00
Ryan C. Gordon
b7a4fdd318 metal: Make sure we have a command buffer available before trying to present.
This fixes a case where you render to the backbuffer, then render to a render
target, set the current target back to the backbuffer, and then present
without drawing anything else; in this circumstance, the Present command
would never happen.

Fixes Bugzilla #5011.
2020-07-17 11:16:35 -04:00
Ryan C. Gordon
b5affd12e6 Patched to compile. 2020-07-16 13:28:59 -04:00
Ryan C. Gordon
3b38e61a7d winrt: Fix casting a pointer to int.
Fixes Bugzilla #5202.
2020-07-16 13:25:50 -04:00
Ryan C. Gordon
8babda2c20 egl: SDL_EGL_LoadLibaryOnly() shouldn't set _this->gl_config.driver_loaded = 1
This is handled in in the higher-level SDL_GL_LoadLibrary().

All uses of SDL_EGL_LoadLibrary (which calls the Only version) are just
target-specific wrappers for their own GL_LoadLibrary hook, with two
exceptions which now handle driver_loaded correctly (although it's
questionable if these init-if-no-one-did-it-correctly-already code blocks
should exist at all, fwiw).

Fixes Bugzilla #5190.
2020-07-16 13:18:19 -04:00
Sam Lantinga
cab1a715f5 Fixed bug 5233 - PS3 Gamepad Motion Control not correctly ignored on Linux
Igor Morgado

PS3 Controller motion sensor string is being reported as

`Gasia Co.,Ltd PS(R) Gamepad Motion Sensors`

But `src/joystick/SDL_gamecontroller.c` line1690 only ignores if matches the string  `Controller Motion Sensors`.

```
#if defined(__LINUX__)
    if (name && SDL_strstr(name, "Controller Motion Sensors")) {
        /* Don't treat the PS3 and PS4 motion controls as a separate game controller */
        return SDL_TRUE;
    }
#endif
```

Therefore, SDL is mapping 2 Game controllers instead one.

Maybe reduce the substring to match `Motion Sensors` instead.


A simple log from my application is shown below:

INFO: Game controller device 0 - PS3 Controller:PS3 Controller found.
INFO: Controller 0: Player 0: 054c:0268:8111 - PS3 Controller - PS3 Controller - Gasia Co.,Ltd PS(R) Gamepad
INFO: Game controller device 1 - PS3 Controller:PS3 Controller found.
INFO: Controller 1: Player 1: 054c:0268:8111 - PS3 Controller - PS3 Controller - Gasia Co.,Ltd PS(R) Gamepad Motion Sensors
2020-07-15 10:15:52 -07:00
M Stoeckl
a78b9763f1 Reuse Wayland connection from availability check 2020-07-14 19:18:16 -04:00
M Stoeckl
8669a87f05 Reuse X11 connection from availability check
Instead of creating an X11 connection to test that X11 is available,
closing the connection, and then reconnecting for real, use the same
connection to handle both cases.

The X11 connection retry delay mechanism in the case where X11 is
dynamically loaded has been removed. It was only necessary to avoid
authetnication token reuse from the XOpenDisplay call that used to
exist in X11_Available. Now that this call is only made once, it
is no longer needed.

Also drop unused and inapplicable code from a comment.
***
2020-07-14 21:13:27 -04:00
M Stoeckl
052a13738d Merge VideoBootStrap::available into VideoBootStrap::create
The two are only ever called together, and combining them makes it possible
to eliminate redundant symbol loading and redundant attempts to connect
to a display server.
2020-07-12 19:11:15 -04:00
Ozkan Sezer
49ec65587a fix bug #5228 -- Add AltiVec detection for FreeBSD.
thanks Piotr Kubaj.
2020-07-11 08:10:02 +03:00
stfx
b162629546 cmake: Fix building with -DSDL_HAPTIC=Off 2020-07-08 17:28:34 +02:00
Ryan C. Gordon
0e98040d43 joystick: Linux joysticks now recover better from dropped events.
Fixes Bugzilla #4830.
2020-06-28 16:23:05 -04:00
Sylvain Beucler
e594a6738a emscripten: Introduce SDL_HINT_EMSCRIPTEN_ASYNCIFY
See https://github.com/emscripten-core/emscripten/issues/10746

and

https://github.com/emscripten-ports/SDL2/pull/112

Fixes Bugzilla #4997.
2020-06-27 16:25:47 -04:00
Sylvain Beucler
01af7b0254 emscripten: support pseudo-synchronous screen refresh and events update using asyncify 2020-06-27 16:22:50 -04:00
Ryan C. Gordon
694fea8ad8 video: Make SDL_CreateWindow use SDL_Init(SDL_INIT_VIDEO), not SDL_VideoInit.
Otherwise, the video subsystem won't deinitialize during SDL_Quit().

Fixes Bugzilla #5067.
2020-06-26 21:37:29 -04:00
Ryan C. Gordon
1947ca7028 video: Changed SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS to default to FALSE.
Fixes Bugzilla #5106.  (and probably many others, too!)
2020-06-26 20:16:43 -04:00
Sam Lantinga
ce293eed8d Fixed bug 5208 - Fix libGL loading on OpenBSD 2020-06-23 10:12:24 -07:00
Sam Lantinga
c2b8530591 Fixed bug 5209 - cpuinfo recognize OpenBSD ARM
Brad Smith

OpenBSD/arm only supports ARMv7 and and not any CPUs that do not support NEON.
2020-06-23 10:09:29 -07:00
Ozkan Sezer
4ba0a84718 core/linux/SDL_threadprio.c: fix build against older glibc versions 2020-06-22 23:24:02 +03:00
Sam Lantinga
b9f55b6d80 Fixed bug 5199 - Fix KMSDRM_CreateWindow() segfault when starting L?VE2D engine.
Manuel Alfayate Corchete

This small patch fixes the KMSDRM_CreateSurfaces() call in KMSDRM_CreateWindow(), that was segfaulting deeper into SDL internals because the windata->viddata pointer wasn't set before the KMSDRM_CreateSurfaces() call.
So that's what this small patch does.

Now, L?VE2D works perfectly well on the Raspberry Pi 3, instead of just segfaulting.
2020-06-19 10:37:14 -07:00
Sam Lantinga
56622f9c92 Fixed bug 5126 - MinGW compile error SDL_windowssensor.c
Martin Gerhardy

SDL_windowssensor.c includes InitGuid.h - but it should be initguid.h
2020-06-17 10:09:07 -07:00
James Legg
f1d5ced167 x11: Fix spurious keyboard focus events 2020-06-17 12:48:40 +01:00
Sam Lantinga
48989e2a87 Reverted comment change in previous commit 2020-06-17 08:47:27 -07:00
Sam Lantinga
a7ff6e9615 Fixed overflow in surface pitch calculation 2020-06-17 08:44:45 -07:00
stfx
efe0935904 Fix compile without DIRECTX 2020-06-15 10:31:16 +02:00
Ozkan Sezer
163896543f fix watcom build of SDL_test_common.c 2020-06-14 12:05:56 +03:00
Ethan Lee
2aa8974f97 Add SDL_SIMDRealloc 2020-06-11 12:03:33 -04:00
Sam Lantinga
20aada0efc Fixed bug 5170 - Build fails when using Visual Studio 2017 with Windows 10 SDK 10.0.19041.0 in uwp
JackBoosY

In src/video/winrt/SDL_winrtgamebar.cpp line 55:

    virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
        __FIEventHandler_1_IInspectable *handler,
        Windows::Foundation::EventRegistrationToken *token) = 0;

The macro __FIEventHandler_1_IInspectable defined in windows.fondation.h(Windows10 SDK 10.0.17763.0) line 3576:
#define __FIVector_1_Windows__CFoundation__CPoint ABI::Windows::Foundation::Collections::__FIVector_1_Windows__CFoundation__CPoint_t

but no longer exists in Windows 10 SDK 10.0.19041.0.
After searching this macro in the sdk include path, I found that it was defined in many header files. But it should be replaced in windows.system.h .
2020-06-10 09:38:43 -07:00
Sam Lantinga
44f50c647e Fixed bug 5171 - PollEvent impacts performance in 2.0.12
On some systems, GetClipCursor() impacts performance when called frequently, so only call it every once in a while to make sure we haven't lost our capture.
2020-06-09 21:47:41 -07:00
Sam Lantinga
511a9702fc Fixed whitespace 2020-06-09 21:43:00 -07:00
Sam Lantinga
aefe19ff08 Added support for the NACON Revolution Pro Controller 3 and the GameStop PS4 Fun Controller 2020-06-09 11:31:39 -07:00
Sam Lantinga
6f241bd520 Fixed build 2020-06-09 10:47:29 -07:00
Sam Lantinga
086be21e7a ControllerList: add support for NACON asymetric controller and Revolution 3, Hori mini wireless ps4 controller, and 2 PDP switch controllers 2020-06-09 10:47:27 -07:00
Sam Lantinga
3b76109f64 ControllerList: remove giotek controller from list - vid/pid appears to be reused in bunch of devies including ones with different fw/protocol and treating as ps4 controller breaks them. 2020-06-09 10:47:25 -07:00
Sam Lantinga
a9cfac3835 Controller: Deadzone improvements 2020-06-09 10:47:23 -07:00
Sam Lantinga
9fa8d6d0be Define constants not available on older kernels 2020-06-08 17:07:55 -07:00
Sam Lantinga
3ac24bfc1a Fixed mouse drag with an external mouse on iOS 2020-06-08 17:01:50 -07:00
Sam Lantinga
ff53521bc6 Fixed Bluetooth audio output on Apple TV 2020-06-04 12:26:57 -07:00
Sam Lantinga
cced5eb937 Fixed bug 5169 - Can not build current sources because of recent thread management changes
Manuel Alfayate Corchete

I'm trying to build SDL2 with threads support here in GNU/Linux, both X86 and ARM, and it does not seem to be possible ATM:


/home/manuel/src/SDLLLL/src/core/linux/SDL_threadprio.c:233:26: error: 'rtkit_max_realtime_priority' undeclared (first use in this function)
2020-06-04 09:23:18 -07:00
Sam Lantinga
958c42827c Fixed build warning 2020-06-04 09:13:49 -07:00
Ryan C. Gordon
60435712f2 video: Set window->surface NULL after freeing it.
Otherwise, when SDL_CreateWindowFramebuffer() is called again, it will return
the free'd surface instead of creating a new one.
2020-06-03 16:42:19 -04:00
Sam Lantinga
eea0b0e088 Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen
meyraud705

Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
2020-06-02 17:08:31 -07:00
Cameron Gutman
134362e745 Enable Xbox One HIDAPI driver on macOS
The Xbox One HIDAPI driver is required on macOS for Xbox One S Bluetooth
support since https://hg.libsdl.org/SDL/rev/10c3a10908e9
2020-04-25 19:15:51 -07:00
Sam Lantinga
ac1f174ad5 Fixed bug 5167 - Memory leak in GuessXInputDevice
meyraud705

Variable 'devices' is not freed if function GuessXInputDevice, in SDL_xinputjoystick.c, return early.
2020-06-02 17:02:37 -07:00
Sam Lantinga
d48c97c4a4 Fixed bug 5147 - KMSDRM: SetWindowFullscreen() failing with SDL_WINDOW_FULLSCREEN_DESKTOP
Manuel Alfayate Corchete

This patch is needed so programs that do this work as expected:
1) Start in a different video mode than the mode used by the system and then...
2) Try to go fullscreen with the mode originally used by the system via SetWindowFullScreen() with the SDL_WINDOW_FULLSCREEN_DESKTOP flag.

An example would be pt2-clone in https://github.com/8bitbubsy/pt2-clone.
This program does this:

Starts with:

video.window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
    SDL_WINDOWPOS_CENTERED, screenW, screenH, windowFlags);


and then, *IF* the user has configured it in fullscreen mode in its .ini, it tries to go fullscreen with the desktop mode:

SDL_SetWindowFullscreen(video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);


This sequence of operations is currently failing because SDL_SetDisplayModeForDisplay() in SDL_video.c fails because display->desktop_mode is not being initialized with its correct value: SetDisplayMode() in SDL_kmsdrmvideo.c will not be able to set the mode because it detects the mode to have a driverdata of 0x0 ("if (!modedata)") and rightfully returns an error.

So, the included patch fixes this small problem, and programs that first change the video mode and then try to go fullscreen with the system video mode will now work.
The patch simply fixes an small omission, but its really needed now that dynamic video mode changing was implemented on the KMSDRM backend.
2020-06-02 16:57:20 -07:00
Sam Lantinga
9325b22ef0 Fixed bug 5113 - SDL_UpdateWindowSurfaceRects BitBlt the entire surface on Win32
Ryan C. Gordon

As discussed here:
https://discourse.libsdl.org/t/question-about-implementation-of-sdl-updatewindowsurfacerects/27561

"As you can see this function [WIN_UpdateWindowFramebuffer, in src/video/windows/SDL_windowsframebuffer.c] calls BitBlt on entire screen, even though it accepts the rects. Rects variable is not even used in this function at all. Now my question is why is that the case?"
2020-05-29 21:26:32 -07:00
Sam Lantinga
d000c1cd6d Fixed bug 5155 - HIDAPI_JoystickDisconnected incorrect array shift
Anthony Pesch

I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward.

The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
2020-05-29 21:22:11 -07:00
Cameron Gutman
77b0dad271 cocoa: Change Caps Lock behavior to toggle instead of locking
It currently behaves like a locking key which is pressed
when Caps Lock is enabled and released when disabled. This
means that apps that trigger events on Caps Lock key down will
only fire these events every other time Caps Lock is pressed.
2020-05-25 20:55:29 -07:00
Sam Lantinga
bdfd1b68ba Fixed bug 5146 - SDL_RenderFillRect doesn't work in DirectFB
Lacky

It looks like refactoring of SDL2 internal API has broken SDL_RenderFillRect for DirectFB. In new version function SDL_RenderFillRect returns 0, but rectangle is not visible.

Replacing "count" with "len" in the argument list for SDL_memcpy in DirectFB_QueueFillRects fixes problem.
2020-05-29 16:02:49 -07:00
Tudor Brindus
a6ca61d732 wayland: update pointer position on initial enter event 2020-05-21 00:06:09 -04:00
Sam Lantinga
ae9ff11bae The zero happens at a higher level now 2020-05-29 14:54:07 -07:00
Sam Lantinga
39c958bbaa Initialize the raw_map before getting controller mappings from the driver 2020-05-29 14:48:39 -07:00
Sam Lantinga
2db049473b Fixed variable names to be consistent across functions 2020-05-29 14:48:05 -07:00
Sam Lantinga
345b4d7e14 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification
Jan Bujak

I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL.

Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this:

https://www.kernel.org/doc/html/v4.15/input/gamepad.html

Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments.

Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.)

With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
2020-05-29 13:37:21 -07:00
James Legg
e2dbed9cfe SDL_blit: Fix undefined bitshift operations
Arithmatic operations promote Uint8 to signed int. If the top bit of a
Uint8 is set, and it is left shifted 24 places, then the result is not
representable in a signed 32 bit int. This would be undefined behaviour
on systems where int is 32 bits.
2020-05-29 13:05:37 +01:00
Brendan Shanks
032fa681a8 Add Logitech G29 to steering wheel list 2020-04-24 14:03:30 -07:00
Ryan C. Gordon
aa259ed52d wayland: Changed output removal in handle_surface_leave()
No longer needs an extra malloc, handles unexpected cases like the same
output being listed twice.
2020-05-28 15:18:41 -04:00
Ryan C. Gordon
ce7ae4ec8d wayland: Move buffer copy into mime_data_list_add()
It makes it clearer who owns the memory, and more reasonable to free it on
failure in the creating function.

(and, of course, pacifies static analysis.)
2020-05-28 14:57:10 -04:00
Ryan C. Gordon
22da9d4d77 wayland: assert that mmap() didn't return NULL.
In practice, it never _would_, but in theory it _might_, so this assertion
tells the static analyzer not to worry about it.
2020-05-28 14:47:55 -04:00
Sam Lantinga
1a1f1704a2 Don't include the iOS joystick driver if joysticks are disabled 2020-05-27 10:35:43 -07:00
Sam Lantinga
57149c2410 Fixed building with --disable-joystick on iOS 2020-05-27 10:27:20 -07:00
Sam Lantinga
cf01ee1694 Fixed building with --disable-joystick on Linux 2020-05-27 10:27:04 -07:00
Sam Lantinga
e9f567c707 Fixed building on iOS with MFI controllers disabled 2020-05-27 10:14:08 -07:00
Sam Lantinga
97ca96bdee Use nil instead of NULL for Objective-C objects 2020-05-27 10:13:01 -07:00
Sam Lantinga
03a7abf80c Fixed building with --disable-joystick on macOS 2020-05-27 09:57:26 -07:00
Sam Lantinga
af5eb56c76 Fixed uninitialized variable warning 2020-05-27 09:28:03 -07:00
Sam Lantinga
31916f11aa Fixed compiler warning building on FreeBSD 2020-05-27 09:22:12 -07:00
Sam Lantinga
bcbaa4ec1f If there isn't a GetGlobalMouseState() implementation, fall back to the normal one. 2020-05-26 16:34:50 -07:00
Sam Lantinga
437577f91e Fixed bug 5141 - KMSDRM: manage SDL_GetGlobalMouseState()
Manuel Alfayate Corchete

On the KMSDRM backend, there is no such thing as a desktop, yet some programs could (and DO) use SDL_GetGlobalMouseState().
So I think its good idea that, in KMSDRM, it returns the same mouse coordinates anyway as SDL_GetMouseState() would return. There is nothing else it could return, as far as I can understand, since there is no desktop anyway.
This small patch does precisely that.
2020-05-26 16:29:26 -07:00
Sam Lantinga
1df0a1e497 Fixed bug 5140 - KMSDRM: Dynamic vsync toggle does not work
Manuel Alfayate Corchete

The KMSDRM backend was doing things wrong because of some small (but important) misconceptions on how KMS/DRM works: to implement a largely broken non-vsync refresh mechanism, the SwapWindow() function was issuing new pageflips before previous ones had completed, thus causing EBUSY returns, buffer mismanagement, etc... resulting in general breakage on vsync disabling from apps, that would not allow vsync to work again without KMSDRM video re-initialization.
To further clarify, on most DRM drivers async pageflips are NOT working nowadays, so all issued pageflips will complete on next VBLANK, NOT ASAP (calling drmModePageFlip() with the DRM_MODE_PAGE_FLIP_ASYNC flag will return error).

The old code was assuming that can just issue a synchronous (=on VBLANK) pageflip and then pass a 0 timeout to the pull() function so we do not wait for the pageflip event, thinking that this will lead to correct non-vsynced screen updates from the program: That is plain wrong.
Each pageflip has to be waite before issuing a new one, ALWAYS. And if we do not support ASYNC pageflips on the DRM driver level, then we are forced to wait for the next VBLANK. There is no way around it.

I have also added many comments on the KMSDRM code. This is needed for future reference for me or others who may need to look at this code: KMS/DRM terminology regarding what SYNC and ASYNC mean in pageflip terms, and where to do certain things and why, is not trivial. It is not desirable or possible to invest time on researching the same concepts every time there is need to dive into this code. So please leave all these comments in the patch.
2020-05-26 16:27:00 -07:00
Sam Lantinga
15294e2121 Fixed iOS build 2020-05-26 13:54:47 -07:00
Sam Lantinga
cc2fe84d73 Getting closer. 2020-05-26 13:19:48 -07:00
Sam Lantinga
0713c5790d More Linux fixes. 2020-05-26 13:19:44 -07:00
Sam Lantinga
c7d1dab1fe Rename Linux-only variable. 2020-05-26 13:19:41 -07:00
Sam Lantinga
b820a81ffb Include SDL_hints.h. 2020-05-26 13:19:35 -07:00
Sam Lantinga
de866e6606 Include SDL_hint.h. 2020-05-26 13:19:29 -07:00